Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update doctor page #53

Merged
merged 237 commits into from
Jun 29, 2024
Merged
Changes from all commits
Commits
Show all changes
237 commits
Select commit Hold shift + click to select a range
fd35227
Deleted ErrorViewModel class
SharifovDeveloper May 7, 2024
5019340
Created Account class
SharifovDeveloper May 7, 2024
85eeb0a
Created Car class
SharifovDeveloper May 7, 2024
835f7f8
Created Disparcher class
SharifovDeveloper May 7, 2024
3e80acf
Created DispatcherReview class
SharifovDeveloper May 7, 2024
170fbb0
Created Doctor class
SharifovDeveloper May 7, 2024
c994166
Created DoctorReview class
SharifovDeveloper May 7, 2024
d6090ab
Created Driver class
SharifovDeveloper May 7, 2024
b2daeaf
Created Mechanic class
SharifovDeveloper May 7, 2024
caaccc4
Created MechanicAcceptance class
SharifovDeveloper May 7, 2024
d099159
Created MechanicHandover class
SharifovDeveloper May 7, 2024
1dffce1
Created Operator class
SharifovDeveloper May 7, 2024
175d82c
Created OperatorReview class
SharifovDeveloper May 7, 2024
4aafbf5
Created Role class
SharifovDeveloper May 7, 2024
f1681d4
Created Status enum
SharifovDeveloper May 7, 2024
53b7883
Created Technician class
SharifovDeveloper May 7, 2024
9af41f3
Fixed code
SharifovDeveloper May 7, 2024
d1bbd7c
Deleted HomeController
SharifovDeveloper May 7, 2024
2eeb211
Upgrade all models
AzamatG17 May 8, 2024
ae059ff
Merge pull request #12 from DiyorMarket/CreateModels
AzamatG17 May 8, 2024
d21ede8
Create Dashboard
AzamatG17 May 8, 2024
49f59cd
Create SideBar and install syncfusion pakeges and use key
AzamatG17 May 8, 2024
e634523
Created Responses class
SharifovDeveloper May 8, 2024
2e720ed
Created GetBaseResponse class
SharifovDeveloper May 8, 2024
0e9f89d
Created GetAccountResponse class
SharifovDeveloper May 8, 2024
d763804
Created GetCarResponse class
SharifovDeveloper May 8, 2024
56f95a9
Created GetDispatcherResponse class
SharifovDeveloper May 8, 2024
4efd26b
Created GetDispatcherReviewResponse
SharifovDeveloper May 9, 2024
2ae5453
Created GetDoctorResponse
SharifovDeveloper May 9, 2024
4a44b74
Created GetDoctorReviewResponse
SharifovDeveloper May 9, 2024
19fc202
Created GetMechanicResponse
SharifovDeveloper May 9, 2024
ca01056
Created GetMechanicAcceptanceResponse
SharifovDeveloper May 9, 2024
243d050
Created GetMechanicAcceptanceResponse
SharifovDeveloper May 9, 2024
b50347b
Created GetOperatorResponse
SharifovDeveloper May 9, 2024
afbd6e7
Created GetOperatorReviewResponse
SharifovDeveloper May 9, 2024
81f5194
Created GetRoleResponse
SharifovDeveloper May 9, 2024
6b3fb7f
Created GetStatusResponse
SharifovDeveloper May 9, 2024
cc47d22
Removed StatusResponse
SharifovDeveloper May 9, 2024
e0bd1ad
Created GetTechnicianResponse
SharifovDeveloper May 9, 2024
a7d4011
Merge pull request #14 from DiyorMarket/CreateResponse
SharifovDeveloper May 9, 2024
f954714
Created Stores file
SharifovDeveloper May 9, 2024
af7772f
Merge branch 'integration' into Create-Data-Stores
SharifovDeveloper May 9, 2024
d19cd24
Created Stores file
SharifovDeveloper May 9, 2024
4543605
Created IAccountDataStore
SharifovDeveloper May 9, 2024
81950e2
Created MockAccountDataStore
SharifovDeveloper May 9, 2024
bda34c6
Created Accounts file and Moved IAccountDataStore and MockAccountData…
SharifovDeveloper May 9, 2024
c59e7d7
Created Cars file
SharifovDeveloper May 9, 2024
04ada09
Created ICarDataStore
SharifovDeveloper May 9, 2024
91206ff
Created MockDataStore
SharifovDeveloper May 9, 2024
f3926ce
Created Dispatchers file
SharifovDeveloper May 9, 2024
e6661bb
Created IDispatcherDataStore
SharifovDeveloper May 9, 2024
5fa6938
Created MockDispatcherDataStore
SharifovDeveloper May 9, 2024
d5a4e33
Created IDispatcherReviewDataStore
SharifovDeveloper May 9, 2024
15b4aac
Created MockDispatcherReviewDataStore
SharifovDeveloper May 9, 2024
d1bd414
Upgrate Layout and Dashboard pages
AzamatG17 May 9, 2024
23f0e94
Instal Syncfusion and Awesome
AzamatG17 May 9, 2024
6a9c741
Merge branch 'integration' into 6-generate-dashboard-page-for-admin
AzamatG17 May 9, 2024
18238d9
Created Doctors file
SharifovDeveloper May 9, 2024
b607c16
Created IDoctorsDataStore
SharifovDeveloper May 9, 2024
0bebde5
Created MockDoctorDataStore
SharifovDeveloper May 9, 2024
af59710
Merge pull request #16 from DiyorMarket/6-generate-dashboard-page-for…
AzamatG17 May 9, 2024
650f4c7
Add Helpers
Nabiddinov May 9, 2024
36bbd26
Merge branch 'integration' into create-helpers
SharifovDeveloper May 9, 2024
ca15e13
Merge pull request #18 from DiyorMarket/create-helpers
Nabiddinov May 9, 2024
6b7d27e
Created DoctorReviews file
SharifovDeveloper May 10, 2024
1d60b73
Created IDoctorReviewDataStore
SharifovDeveloper May 10, 2024
26476e9
Created MockDoctorReviewDataStore
SharifovDeveloper May 10, 2024
d0f237b
Created Drivers file
SharifovDeveloper May 10, 2024
31e0a8d
Created IDriverDataStore
SharifovDeveloper May 10, 2024
08c3fe4
Created MockDriverDataStore
SharifovDeveloper May 10, 2024
d0c77cc
Created Mechanics file
SharifovDeveloper May 10, 2024
5ed1725
Created IMechanicDataStore
SharifovDeveloper May 10, 2024
d516063
Created MockMechanicDataStore
SharifovDeveloper May 10, 2024
2656f9c
Created IMechanicAcceptanceDataStore
SharifovDeveloper May 10, 2024
ab7609c
Created MockMechanicAcceptanceDataStore
SharifovDeveloper May 10, 2024
c215f04
Create ApiExceptions
AzamatG17 May 10, 2024
f0798d4
Generate ApiException Filter
AzamatG17 May 10, 2024
42d3a84
Register Exception to StartUp
AzamatG17 May 10, 2024
a18ae76
Merge branch 'integration' into Create-apiexception
AzamatG17 May 10, 2024
0bd003a
Created MechanicHandovers file
SharifovDeveloper May 10, 2024
33ddc54
Created IMechanicHandoverDataStore
SharifovDeveloper May 10, 2024
122dd1d
Created MockMechanicHandoverDataStore
SharifovDeveloper May 10, 2024
a715494
Created Operators file
SharifovDeveloper May 10, 2024
745dfd4
Created IOperatorDataStore
SharifovDeveloper May 10, 2024
c01f175
Created MockOperatorDataStore
SharifovDeveloper May 10, 2024
8890adc
Created OperatorReviews file
SharifovDeveloper May 10, 2024
798de2d
Created IOperatorReviewDataStore
SharifovDeveloper May 10, 2024
5ced26f
Created MockOperatorReviewDataStore
SharifovDeveloper May 10, 2024
7274464
Created Roles file
SharifovDeveloper May 10, 2024
67ba223
Created IRoleDataStore
SharifovDeveloper May 10, 2024
9a02340
Created MockMechanicDataStore
SharifovDeveloper May 10, 2024
ffd369e
Created Technician file
SharifovDeveloper May 10, 2024
6839ef1
Created ITechnicianDataStore
SharifovDeveloper May 10, 2024
6c53b53
Created MockTechnicianDataStore
SharifovDeveloper May 10, 2024
8dc8e88
Merge branch 'integration' into Create-Data-Stores
SharifovDeveloper May 10, 2024
9a16c9c
Merge pull request #21 from DiyorMarket/Create-apiexception
AzamatG17 May 10, 2024
7052c60
Create Configurations file for constants
AzamatG17 May 10, 2024
93e9040
Merge pull request #23 from DiyorMarket/Create-Configurations-file-fo…
AzamatG17 May 10, 2024
a64e10d
Merge pull request #22 from DiyorMarket/Create-Data-Stores
SharifovDeveloper May 10, 2024
eb13983
Generate ApiClient for connect with API
AzamatG17 May 10, 2024
752a75c
Squashed commit of the following:
AzamatG17 May 10, 2024
badf81b
Merge branch 'integration' into genereate-apiclient-for-connect-with-api
AzamatG17 May 10, 2024
c2a9f80
Squashed commit of the following:
AzamatG17 May 10, 2024
ad369ad
Create Mapping method for DataStores
AzamatG17 May 10, 2024
6357e22
Add Mapping for ApiClient
AzamatG17 May 10, 2024
d812321
And register for StartUp.
AzamatG17 May 10, 2024
6d1d249
Merge pull request #26 from DiyorMarket/genereate-apiclient-for-conne…
AzamatG17 May 10, 2024
3b7530b
Merge branch 'integration' into Add-ConfigureDataStores-for-Mapping
AzamatG17 May 10, 2024
948cc73
Merge pull request #27 from DiyorMarket/Add-ConfigureDataStores-for-M…
AzamatG17 May 11, 2024
3a43129
Created Account controller
SharifovDeveloper May 11, 2024
c9cd79a
Created CarController
SharifovDeveloper May 11, 2024
dfe1fc4
Created DispatcherController
SharifovDeveloper May 11, 2024
cd686fe
Created DoctorsController and rename controllers name
SharifovDeveloper May 11, 2024
645e810
Created DispatcherReviewsController
SharifovDeveloper May 11, 2024
80cba06
Created DoctorReviewsController
SharifovDeveloper May 11, 2024
64bb9dd
Created DriversController
SharifovDeveloper May 11, 2024
cf3a07d
Created MechanicsController
SharifovDeveloper May 11, 2024
e88f6b9
Created MechanicAcceptancesController
SharifovDeveloper May 11, 2024
65b25e7
Created MechanicHandoversController
SharifovDeveloper May 11, 2024
a97a690
Created OpeartorsController
SharifovDeveloper May 11, 2024
5f39d5d
Created OperatorReviewsController
SharifovDeveloper May 11, 2024
d1b49c0
Created RolesController
SharifovDeveloper May 11, 2024
0f1bb6b
Created TechniciansController
SharifovDeveloper May 11, 2024
10f0162
Corrected services.AddScoped<ITechnicianDataStore, MockTechnicianData…
SharifovDeveloper May 11, 2024
88fdce8
cleared unnecessary usings
SharifovDeveloper May 11, 2024
9de8d6d
Merge pull request #28 from DiyorMarket/CreateControllers
SharifovDeveloper May 12, 2024
c82aa1b
Upgrade Syncfusion key
AzamatG17 May 13, 2024
0d12227
Merge pull request #31 from DiyorMarket/Upgrade-Syncfusion-key
AzamatG17 May 13, 2024
771fa13
Add example data for Dashboard
AzamatG17 May 13, 2024
07ebfa9
Add example data for Dashboard
AzamatG17 May 13, 2024
ef4c961
Upgrade
AzamatG17 May 13, 2024
43ba64e
Merge pull request #32 from DiyorMarket/Add-example-date-for-dashboar…
AzamatG17 May 13, 2024
9468a4b
Creating SideBar
khojianvar May 14, 2024
e73eeeb
Merge pull request #33 from DiyorMarket/create-sidebar
khojianvar May 14, 2024
eea73b7
Update-sidebar
khojianvar May 14, 2024
9e9fdc2
Merge pull request #34 from DiyorMarket/update-sidebar
khojianvar May 14, 2024
ca50aae
update code
khojianvar May 16, 2024
fd17c35
Genarete Driver page
AzamatG17 May 18, 2024
40db7b2
Merge pull request #35 from DiyorMarket/update-sidebar
AzamatG17 May 18, 2024
e80d4f8
Squashed commit of the following:
AzamatG17 May 18, 2024
ec2346c
Update SideBar
diyorzz May 19, 2024
3a7fd25
Create Accounts Index
diyorzz May 19, 2024
8bf8f79
Merge pull request #36 from DiyorMarket/Update-SideBar-And-Create-Acc…
SharifovDeveloper May 19, 2024
69bf7ea
CRUD operations
khojianvar May 20, 2024
0638989
Update "Ishchilar" page
diyorzz May 20, 2024
523ebd7
Merge branch 'integration' into Generate-operator-page-for-admin
AzamatG17 May 20, 2024
ab2f3f3
Improve "Ishchi" Page
diyorzz May 20, 2024
a046644
Delete Mock DataStores
AzamatG17 May 20, 2024
862a7f0
Instal ApiContracts and upgrade DashBoard
AzamatG17 May 20, 2024
68a6f3c
Upgrade Controllers
AzamatG17 May 20, 2024
957cbcf
Change Configure DataStore
AzamatG17 May 20, 2024
9b3c85e
Upgrade Response
AzamatG17 May 20, 2024
73303b4
change SideBar
AzamatG17 May 20, 2024
954f900
Create OperatorReview DataStore
AzamatG17 May 20, 2024
96ddfa2
Created Mechanics file
SharifovDeveloper May 20, 2024
723dc78
UpdateOperator DataStore
AzamatG17 May 20, 2024
d5e4217
Create OperatorReview Page
AzamatG17 May 20, 2024
06121aa
Merge pull request #37 from DiyorMarket/Generate-operator-page-for-admin
AzamatG17 May 20, 2024
f8548ee
Created ViewModels file
SharifovDeveloper May 21, 2024
9121734
Created MechanicViewModel
SharifovDeveloper May 21, 2024
1c7f8e9
Make ApiClient methods asynchronous
SharifovDeveloper May 21, 2024
4d9f2b3
Updated IMechanicDataStore
SharifovDeveloper May 21, 2024
e447ed7
Made Drivers Stores classes asynchronous
SharifovDeveloper May 21, 2024
ddf5391
Make Account classes asynchronous
SharifovDeveloper May 21, 2024
7b9f4e5
Make Drivers controller asynchronous
SharifovDeveloper May 21, 2024
fde88f6
Car-page
khojianvar May 21, 2024
188908f
Synchronous codes
SharifovDeveloper May 21, 2024
b46c1ea
Updated Index
SharifovDeveloper May 21, 2024
583107f
Installed last version contacts package
SharifovDeveloper May 21, 2024
c2aff04
Updated GetMechanicAcceptance response
SharifovDeveloper May 21, 2024
e085021
Update mechanicAcceptances controller
SharifovDeveloper May 21, 2024
21078b6
Updated
SharifovDeveloper May 21, 2024
1b8c29d
Added async keyword to methods
SharifovDeveloper May 21, 2024
7d8fa37
updated
SharifovDeveloper May 21, 2024
9dbe45c
Corrected
SharifovDeveloper May 21, 2024
652a424
Corrected IMechanicAcceptanceDataStore
SharifovDeveloper May 21, 2024
8a3cf9f
today's last commit
SharifovDeveloper May 21, 2024
9f2f0b5
Creating-Car-View
khojianvar May 22, 2024
83dc5de
Update "Ishchilar" page
diyorzz May 22, 2024
d3a038d
Update Role to RoleDTOs
diyorzz May 22, 2024
11c3e20
Merge branch 'integration' into Car-page-for-admin
khojianvar May 23, 2024
2f461ac
index
khojianvar May 23, 2024
c10bb2a
Merge pull request #39 from DiyorMarket/Car-page-for-admin
khojianvar May 23, 2024
208c8d9
Updated
SharifovDeveloper May 23, 2024
f184caf
Improve "Ishchilar" page
diyorzz May 23, 2024
17da96d
Creating-PersonalPage
khojianvar May 24, 2024
a45a653
Improve Account Create ,Edit and List
diyorzz May 24, 2024
be1c7d4
Merge pull request #40 from DiyorMarket/Car-page-for-admin
khojianvar May 24, 2024
ba4d6e3
Improve AccountController
diyorzz May 24, 2024
a2528b3
Update Create page
diyorzz May 24, 2024
82ec159
Update delete properties to uzbek
diyorzz May 24, 2024
cb9fe4e
Update Details page to uzbek
diyorzz May 24, 2024
38b66a4
Update Edit page to uzbek
diyorzz May 24, 2024
369fa19
Update create bottom location
diyorzz May 24, 2024
7c30a8c
Updated
SharifovDeveloper May 25, 2024
5602dd1
Created MechanicHandovers View
SharifovDeveloper May 25, 2024
233ea14
Updated HandoverResponse
SharifovDeveloper May 25, 2024
b1d44cf
Updated handovers datastore
SharifovDeveloper May 25, 2024
8c26a06
Update MechanicHandoverController
SharifovDeveloper May 25, 2024
2391a74
Updated
SharifovDeveloper May 26, 2024
ca8066d
Improve Edit Page
diyorzz May 27, 2024
efed406
Improve Delete page
diyorzz May 27, 2024
a75da0d
Delete unnecessary lines
diyorzz May 27, 2024
c3f71b5
Merge pull request #41 from DiyorMarket/Improve-Ishchillar-page
khojianvar May 27, 2024
0284439
Completed Mechanic
SharifovDeveloper May 28, 2024
9c4e178
Merge branch 'integration' into Mechanic
SharifovDeveloper May 28, 2024
9ebc6da
Merge pull request #42 from DiyorMarket/Mechanic
SharifovDeveloper May 28, 2024
82ea7e1
Fixed all errors
SharifovDeveloper May 28, 2024
fec4bd2
Merge pull request #43 from DiyorMarket/FixedIntegration
SharifovDeveloper May 28, 2024
aa7e38f
Add-Pagination
diyorzz May 28, 2024
71802ec
Improve "Ishchilar" page
diyorzz May 28, 2024
0399d17
Merge pull request #44 from DiyorMarket/Add-Pagination-and-improve-Is…
diyorzz May 28, 2024
4ae253f
Updated MechanicAcceptance index view
SharifovDeveloper May 28, 2024
cdf5d5e
Delete unnecessary method in AccountController
diyorzz May 28, 2024
09a59db
Add Search and Fix some problems
diyorzz May 28, 2024
57baf61
Merge pull request #45 from DiyorMarket/Upgrade-Avtomobillar-page
diyorzz May 28, 2024
a1e0ba1
Added Pagination
SharifovDeveloper May 28, 2024
462a222
Added pagination to Handover
SharifovDeveloper May 28, 2024
48bc744
removed unnecessary mechanic section
SharifovDeveloper May 28, 2024
df23629
Added details for mechanicAcceptances
SharifovDeveloper May 29, 2024
b042c8c
Improves mechanicAcceptances
SharifovDeveloper May 29, 2024
02bc9cf
Added Details for MechanicHandover
SharifovDeveloper May 29, 2024
c59450d
Updated Mechanic acceptances
SharifovDeveloper May 29, 2024
7605867
Fix "Avtobillar" page location "Yaratish" bottom
diyorzz May 29, 2024
b81c01d
Merge pull request #46 from DiyorMarket/ImprovMechanicPages
SharifovDeveloper May 29, 2024
da0425d
Merge pull request #47 from DiyorMarket/Fix-Avtomobillar-page-location
diyorzz May 29, 2024
b024367
Personal_Doctors_Page
khojianvar May 28, 2024
fa0e780
update
khojianvar May 29, 2024
0e1455b
Merge pull request #48 from DiyorMarket/Car-page-for-admin
khojianvar May 29, 2024
52bc830
Updated-code
khojianvar May 30, 2024
acfaf31
Merge pull request #50 from DiyorMarket/Doctor-page-update
khojianvar May 30, 2024
fa44bf4
fix apiClient
diyorzz May 31, 2024
169a7ce
Merge pull request #51 from DiyorMarket/Fix-ApiClient-probelem
AzamatG17 May 31, 2024
774480d
Update NuGet Package
diyorzz Jun 2, 2024
74d1638
Add coulmn to Cars page
diyorzz Jun 2, 2024
a66cc5f
Merge pull request #52 from DiyorMarket/Add-new-column-to-Cars-page
diyorzz Jun 2, 2024
e1ccfbd
Completed DoctorPage
Nabiddinov Jun 2, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CheckDrive.Web/CheckDrive.Web.sln
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.9.34728.123
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CheckDrive.Web", "CheckDrive.Web\CheckDrive.Web.csproj", "{7F91792F-530C-4443-AC8D-04D956B346F4}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CheckDrive.Web", "CheckDrive.Web\CheckDrive.Web.csproj", "{7F91792F-530C-4443-AC8D-04D956B346F4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
33 changes: 32 additions & 1 deletion CheckDrive.Web/CheckDrive.Web/CheckDrive.Web.csproj
Original file line number Diff line number Diff line change
@@ -1,9 +1,40 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<Compile Remove="Controllers\**" />
<Content Remove="Controllers\**" />
<EmbeddedResource Remove="Controllers\**" />
<None Remove="Controllers\**" />
<Compile Include="Controllers\AccountsController.cs" />
<Compile Include="Controllers\CarsController.cs" />
<Compile Include="Controllers\DashboardController.cs" />
<Compile Include="Controllers\DispatcherReviewsController.cs" />
<Compile Include="Controllers\DispatchersController.cs" />
<Compile Include="Controllers\DoctorReviewsController.cs" />
<Compile Include="Controllers\DoctorsController.cs" />
<Compile Include="Controllers\DriversController.cs" />
<Compile Include="Controllers\PersonalDoctorReviewsController.cs" />
<Compile Include="Controllers\RolesController.cs" />
<Compile Include="Controllers\MechanicAcceptancesController.cs" />
<Compile Include="Controllers\MechanicHandoversController.cs" />
<Compile Include="Controllers\MechanicsController.cs" />
<Compile Include="Controllers\OperatorReviewsController.cs" />
<Compile Include="Controllers\OperatorsController.cs" />
<Compile Include="Controllers\TechniciansController.cs" />

<PackageReference Include="CheckDrive.ApiContracts" Version="1.2.1" />
<PackageReference Include="CheckDrive.DTOs" Version="1.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.4" />
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="8.0.2" />
<PackageReference Include="Syncfusion.EJ2.AspNet.Core" Version="25.1.42" />
<PackageReference Include="Syncfusion.Licensing" Version="25.2.3" />

</ItemGroup>

</Project>
8 changes: 8 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Constants/Configurations.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
namespace CheckDrive.Web.Constants
{
public static class Configurations
{
public const string JwtToken = "JwtToken";
public const string SynfusionLicenseKey = "Mgo+DSMBMAY9C3t2UFhhQlJBfVldWnxLflFyVWRTelx6cF1WESFaRnZdRl1mSH1TfkBgWXhXeXdV";
}
}
131 changes: 131 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/AccountsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Role;
using CheckDrive.Web.Stores.Accounts;
using CheckDrive.Web.Stores.Roles;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;

namespace CheckDrive.Web.Controllers
{
public class AccountsController : Controller
{
private readonly IAccountDataStore _accountDataStore;
private readonly IRoleDataStore _roleStore;
public AccountsController(IAccountDataStore accountDataStore, IRoleDataStore roleDataStore)
{
_roleStore = roleDataStore;
_accountDataStore = accountDataStore;
}

public async Task<IActionResult> Index(string? searchString, int? roleId, DateTime? birthDate, int? pageNumber)
{
var accounts = await _accountDataStore.GetAccountsAsync(searchString, roleId, birthDate, pageNumber);

var roles = await GETRoles();

roles.Insert(0, new RoleDto
{
Id = 0,
Name = "Barcha ishchilar",
});
var selectedRole = roles[0];

if (roleId.HasValue && roleId != 0)
{
selectedRole = roles.FirstOrDefault(x => x.Id == roleId);
}

ViewBag.Accounts = accounts.Data;
ViewBag.Roles = roles;

ViewBag.PageSize = accounts.PageSize;
ViewBag.PageCount = accounts.TotalPages;
ViewBag.TotalCount = accounts.TotalCount;
ViewBag.CurrentPage = accounts.PageNumber;
ViewBag.HasPreviousPage = accounts.HasPreviousPage;
ViewBag.HasNextPage = accounts.HasNextPage;

ViewBag.SearchString = searchString;
ViewBag.CurrentRoleId = roleId;
ViewBag.SelectedRole = selectedRole;

return View();
}
public async Task<IActionResult> Details(int id)
{
var account = await _accountDataStore.GetAccountAsync(id);
if (account == null)
{
return NotFound();
}
return View(account);
}
public async Task<IActionResult> Create()
{
var roles = await GETRoles();
ViewBag.Roles = new SelectList(roles, "Id", "Name");
return View();
}
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Login,Password,PhoneNumber,FirstName,LastName,Bithdate,RoleId")]
AccountForCreateDto account)
{
if (ModelState.IsValid)
{
await _accountDataStore.CreateAccountAsync(account);
return RedirectToAction(nameof(Index));
}
return View(account);
}

public async Task<IActionResult> Edit(int id)
{
var account = await _accountDataStore.GetAccountAsync(id);
if (account == null)
{
return NotFound();
}

return View(account);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Login,Password,PhoneNumber,FirstName,LastName,Bithdate,RoleId")]
AccountForUpdateDto account)
{
if (ModelState.IsValid)
{
await _accountDataStore.UpdateAccountAsync(id, account);
return RedirectToAction(nameof(Index));
}
return View(account);
}

public async Task<IActionResult> Delete(int id)
{
var account = await _accountDataStore.GetAccountAsync(id);
if (account == null)
{
return NotFound();
}
return View(account);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _accountDataStore.DeleteAccountAsync(id);
return RedirectToAction(nameof(Index));
}

private async Task<List<RoleDto>> GETRoles()
{
var roleResponse = await _roleStore.GetRoles();
var roles = roleResponse.Data.ToList();

Check warning on line 127 in CheckDrive.Web/CheckDrive.Web/Controllers/AccountsController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'List<RoleDto> Enumerable.ToList<RoleDto>(IEnumerable<RoleDto> source)'.
return roles;
}
}
}
120 changes: 120 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/CarsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using CheckDrive.ApiContracts.Car;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Cars;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class CarsController : Controller
{
private readonly ICarDataStore _carDataStore;

public CarsController(ICarDataStore carDataStore)
{
_carDataStore = carDataStore;
}

public async Task<IActionResult> Index(string? searchString,int? pageNumber)
{
var cars = await _carDataStore.GetCars(searchString,pageNumber);

ViewBag.SearchString = searchString;
ViewBag.Cars = cars.Data;

ViewBag.PageSize = cars.PageSize;
ViewBag.PageCount = cars.TotalPages;
ViewBag.TotalCount = cars.TotalCount;
ViewBag.CurrentPage = cars.PageNumber;
ViewBag.HasPreviousPage = cars.HasPreviousPage;
ViewBag.HasNextPage = cars.HasNextPage;
return View();
}

public async Task<IActionResult> Details(int id)
{
var car = await _carDataStore.GetCar(id);
if (car == null)
{
return NotFound();
}
return View(car);
}

public async Task<IActionResult> DetailsForMechanicAcceptance(int id)
{
var car = await _carDataStore.GetCar(id);
if (car == null)
{
return NotFound();
}
return PartialView("_CarDetailsForMechanicAcceptance", car);
}

public async Task<IActionResult> DetailsForMechanicHandover(int id)
{
var car = await _carDataStore.GetCar(id);
if (car == null)
{
return NotFound();
}
return PartialView("_CarDetailsForMechanicHandover", car);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Model,Color,Number,RemainingFuel,MeduimFuelConsumption,FuelTankCapacity,ManufacturedYear")] CarForCreateDto car)
{
if (ModelState.IsValid)
{
await _carDataStore.CreateCar(car);
return RedirectToAction(nameof(Index));
}
return View(car);
}

public async Task<IActionResult> Edit(int id)
{
var car = await _carDataStore.GetCar(id);
if (car == null)
{
return NotFound();
}
return View(car);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Model,Color,Number,RemainingFuel,MeduimFuelConsumption,FuelTankCapacity,ManufacturedYear")] CarForUpdateDto car)
{
if (ModelState.IsValid)
{
await _carDataStore.UpdateCar(id, car);
return RedirectToAction(nameof(Index));
}
return View(car);
}

public async Task<IActionResult> Delete(int id)
{
var car = await _carDataStore.GetCar(id);
if (car == null)
{
return NotFound();
}
return View(car);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _carDataStore.DeleteCar(id);
return RedirectToAction(nameof(Index));
}
}
}
36 changes: 36 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DashboardController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DashboardController : Controller
{
public IActionResult Index()
{
List<SplineChartData> SplineData = new List<SplineChartData>
{
new SplineChartData { Days = "Yanvar", MaxTemp = 15, AvgTemp = 10, MinTemp = 2 },
new SplineChartData { Days = "Febral", MaxTemp = 22, AvgTemp = 18, MinTemp = 12 },
new SplineChartData { Days = "Mart", MaxTemp = 32, AvgTemp = 28, MinTemp = 22 },
new SplineChartData { Days = "Aprel", MaxTemp = 31, AvgTemp = 28, MinTemp = 23 },
new SplineChartData { Days = "May", MaxTemp = 29, AvgTemp = 26, MinTemp = 19 },
new SplineChartData { Days = "Iyun", MaxTemp = 24, AvgTemp = 20, MinTemp = 13 },
new SplineChartData { Days = "Iyul", MaxTemp = 18, AvgTemp = 15, MinTemp = 8 },
new SplineChartData { Days = "Avgust", MaxTemp = 18, AvgTemp = 23, MinTemp = 13 },
new SplineChartData { Days = "Sentabr", MaxTemp = 6, AvgTemp = 23, MinTemp = 3 },
new SplineChartData { Days = "Oktabr", MaxTemp = 23, AvgTemp = 15, MinTemp = 8 },
new SplineChartData { Days = "Noyabr", MaxTemp = 13, AvgTemp = 11, MinTemp = 17 },
new SplineChartData { Days = "Dekabr", MaxTemp = 12, AvgTemp = 21, MinTemp = 10 },
};
ViewBag.SplineData = SplineData;
return View();
}

public class SplineChartData
{
public string Days;

Check warning on line 30 in CheckDrive.Web/CheckDrive.Web/Controllers/DashboardController.cs

GitHub Actions / build

Non-nullable field 'Days' must contain a non-null value when exiting constructor. Consider declaring the field as nullable.
public double MaxTemp;
public double AvgTemp;
public double MinTemp;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.DispatcherReviews;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DispatcherReviewsController : Controller
{
private readonly IDispatcherReviewDataStore _dispatcherReviewDataStore;

public DispatcherReviewsController(IDispatcherReviewDataStore dispatcherReviewDataStore)
{
_dispatcherReviewDataStore = dispatcherReviewDataStore;
}

public async Task<IActionResult> Index()
{
var reviews = await _dispatcherReviewDataStore.GetDispatcherReviews();
return View(reviews);
}

public async Task<IActionResult> Details(int id)
{
var review = await _dispatcherReviewDataStore.GetDispatcherReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("FuelSpended,DistanceCovered,Date,DispatcherId,OperatorId,MechanicId,DriverId")] DispatcherReview dispatcherReview)
{
if (ModelState.IsValid)
{
await _dispatcherReviewDataStore.CreateDispatcherReview(dispatcherReview);
return RedirectToAction(nameof(Index));
}
return View(dispatcherReview);
}

public async Task<IActionResult> Edit(int id)
{
var review = await _dispatcherReviewDataStore.GetDispatcherReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,FuelSpended,DistanceCovered,Date,DispatcherId,OperatorId,MechanicId,DriverId")] DispatcherReview dispatcherReview)
{
if (id != dispatcherReview.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _dispatcherReviewDataStore.UpdateDispatcherReview(id, dispatcherReview);
}
catch (Exception)
{
if (!await DispatcherReviewExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(dispatcherReview);
}

public async Task<IActionResult> Delete(int id)
{
var review = await _dispatcherReviewDataStore.GetDispatcherReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _dispatcherReviewDataStore.DeleteDispatcherReview(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DispatcherReviewExists(int id)
{
var review = await _dispatcherReviewDataStore.GetDispatcherReview(id);
return review != null;
}
}
}
114 changes: 114 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DispatchersController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Dispatchers;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DispatchersController : Controller
{
private readonly IDispatcherDataStore _dispatcherDataStore;

public DispatchersController(IDispatcherDataStore dispatcherDataStore)
{
_dispatcherDataStore = dispatcherDataStore;
}

public async Task<IActionResult> Index()
{
var dispatchers = await _dispatcherDataStore.GetDispatchers();
return View(dispatchers);
}

public async Task<IActionResult> Details(int id)
{
var dispatcher = await _dispatcherDataStore.GetDispatcher(id);
if (dispatcher == null)
{
return NotFound();
}
return View(dispatcher);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] Dispatcher dispatcher)
{
if (ModelState.IsValid)
{
await _dispatcherDataStore.CreateDispatcher(dispatcher);
return RedirectToAction(nameof(Index));
}
return View(dispatcher);
}

public async Task<IActionResult> Edit(int id)
{
var dispatcher = await _dispatcherDataStore.GetDispatcher(id);
if (dispatcher == null)
{
return NotFound();
}
return View(dispatcher);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,AccountId")] Dispatcher dispatcher)
{
if (id != dispatcher.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _dispatcherDataStore.UpdateDispatcher(id, dispatcher);
}
catch (Exception)
{
if (!await DispatcherExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(dispatcher);
}

public async Task<IActionResult> Delete(int id)
{
var dispatcher = await _dispatcherDataStore.GetDispatcher(id);
if (dispatcher == null)
{
return NotFound();
}
return View(dispatcher);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _dispatcherDataStore.DeleteDispatcher(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DispatcherExists(int id)
{
var dispatcher = await _dispatcherDataStore.GetDispatcher(id);
return dispatcher != null;
}
}
}
134 changes: 134 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DoctorReviewsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
using CheckDrive.ApiContracts.DoctorReview;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.DoctorReviews;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DoctorReviewsController : Controller
{
private readonly IDoctorReviewDataStore _doctorReviewDataStore;

public DoctorReviewsController(IDoctorReviewDataStore doctorReviewDataStore)
{
_doctorReviewDataStore = doctorReviewDataStore;
}

public async Task<IActionResult> Index(int? pageNumber)
{
var response = await _doctorReviewDataStore.GetDoctorReviews(pageNumber);

ViewBag.PageSize = response.PageSize;
ViewBag.PageCount = response.TotalPages;
ViewBag.TotalCount = response.TotalCount;
ViewBag.CurrentPage = response.PageNumber;
ViewBag.HasPreviousPage = response.HasPreviousPage;
ViewBag.HasNextPage = response.HasNextPage;

var doctorReviews = response.Data.Select(r => new

Check warning on line 28 in CheckDrive.Web/CheckDrive.Web/Controllers/DoctorReviewsController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<<anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>> Enumerable.Select<DoctorReviewDto, <anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>>(IEnumerable<DoctorReviewDto> source, Func<DoctorReviewDto, <anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>> selector)'.
{
r.Id,
r.DriverName,
r.DoctorName,
IsHealthy = r.IsHealthy ? "Sog`lom" : "Kasal",
r.Comments
}).ToList();

ViewBag.DoctorsReview = doctorReviews;

return View();
}

public async Task<IActionResult> Details(int id)
{
var review = await _doctorReviewDataStore.GetDoctorReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("IsHealthy,Comments,Date,DriverId,DoctorId")] DoctorReviewForCreateDto doctorReview)
{
if (ModelState.IsValid)
{
await _doctorReviewDataStore.CreateDoctorReview(doctorReview);
return RedirectToAction(nameof(Index));
}
return View(doctorReview);
}

public async Task<IActionResult> Edit(int id)
{
var review = await _doctorReviewDataStore.GetDoctorReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,IsHealthy,Comments,Date,DriverId,DoctorId")] DoctorReviewForUpdateDto doctorReview)
{
if (id != doctorReview.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _doctorReviewDataStore.UpdateDoctorReview(id, doctorReview);
}
catch (Exception)
{
if (!await DoctorReviewExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(doctorReview);
}

public async Task<IActionResult> Delete(int id)
{
var review = await _doctorReviewDataStore.GetDoctorReview(id);
if (review == null)
{
return NotFound();
}
return View(review);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _doctorReviewDataStore.DeleteDoctorReview(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DoctorReviewExists(int id)
{
var review = await _doctorReviewDataStore.GetDoctorReview(id);
return review != null;
}
}
}
116 changes: 116 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DoctorsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Doctor;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Doctors;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DoctorsController : Controller
{
private readonly IDoctorDataStore _doctorDataStore;

public DoctorsController(IDoctorDataStore doctorDataStore)
{
_doctorDataStore = doctorDataStore;
}

public async Task<IActionResult> Index()
{
var doctors = await _doctorDataStore.GetDoctors();
return View(doctors);
}

public async Task<IActionResult> Details(int id)
{
var doctor = await _doctorDataStore.GetDoctor(id);
if (doctor == null)
{
return NotFound();
}
return View(doctor);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] DoctorForCreateDto doctor)
{
if (ModelState.IsValid)
{
await _doctorDataStore.CreateDoctor(doctor);
return RedirectToAction(nameof(Index));
}
return View(doctor);
}

public async Task<IActionResult> Edit(int id)
{
var doctor = await _doctorDataStore.GetDoctor(id);
if (doctor == null)
{
return NotFound();
}
return View(doctor);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,AccountId")] AccountForUpdateDto doctor)
{
if (id != doctor.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _doctorDataStore.UpdateDoctor(id, doctor);
}
catch (Exception)
{
if (!await DoctorExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(doctor);
}

public async Task<IActionResult> Delete(int id)
{
var doctor = await _doctorDataStore.GetDoctor(id);
if (doctor == null)
{
return NotFound();
}
return View(doctor);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _doctorDataStore.DeleteDoctor(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DoctorExists(int id)
{
var doctor = await _doctorDataStore.GetDoctor(id);
return doctor != null;
}
}
}
113 changes: 113 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/DriversController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Driver;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Drivers;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class DriversController(IDriverDataStore driverDataStore) : Controller
{
private readonly IDriverDataStore _driverDataStore = driverDataStore;

public async Task<IActionResult> Index()
{
var drivers = await _driverDataStore.GetDriversAsync();

ViewBag.Drivers = drivers;
return View();
}

public async Task<IActionResult> Details(int id)
{
var driver = await _driverDataStore.GetDriverAsync(id);
if (driver == null)
{
return NotFound();
}
return View(driver);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] DriverForCreateDto driver)
{
if (ModelState.IsValid)
{
await _driverDataStore.CreateDriverAsync(driver);
return RedirectToAction(nameof(Index));
}
return View(driver);
}

public async Task<IActionResult> Edit(int id)
{
var driver = await _driverDataStore.GetDriverAsync(id);
if (driver == null)
{
return NotFound();
}
return View(driver);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,AccountId")] AccountForUpdateDto driver)
{
if (id != driver.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _driverDataStore.UpdateDriverAsync(id, driver);
}
catch (Exception)
{
if (!await DriverExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(driver);
}

public async Task<IActionResult> Delete(int id)
{
var driver = await _driverDataStore.GetDriverAsync(id);
if (driver == null)
{
return NotFound();
}
return View(driver);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _driverDataStore.DeleteDriverAsync(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DriverExists(int id)
{
var driver = await _driverDataStore.GetDriverAsync(id);
return driver != null;
}
}
}
30 changes: 0 additions & 30 deletions CheckDrive.Web/CheckDrive.Web/Controllers/HomeController.cs

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
using CheckDrive.ApiContracts;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Cars;
using CheckDrive.Web.Stores.MechanicAcceptances;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class MechanicAcceptancesController : Controller
{
private readonly IMechanicAcceptanceDataStore _mechanicAcceptanceDataStore;
private readonly ICarDataStore _carDataStore;

public MechanicAcceptancesController(IMechanicAcceptanceDataStore mechanicAcceptanceDataStore, ICarDataStore carDataStore)
{
_mechanicAcceptanceDataStore = mechanicAcceptanceDataStore;
_carDataStore = carDataStore;
}

public async Task<IActionResult> Index(int? pageNumber)
{

var response = await _mechanicAcceptanceDataStore.GetMechanicAcceptancesAsync(pageNumber);

ViewBag.PageSize = response.PageSize;
ViewBag.PageCount = response.TotalPages;
ViewBag.TotalCount = response.TotalCount;
ViewBag.CurrentPage = response.PageNumber;
ViewBag.HasPreviousPage = response.HasPreviousPage;
ViewBag.HasNextPage = response.HasNextPage;

var mechanicAcceptances = response.Data.Select(r => new

Check warning on line 32 in CheckDrive.Web/CheckDrive.Web/Controllers/MechanicAcceptancesController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<<anonymous type: int Id, string IsAccepted, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>> Enumerable.Select<MechanicAcceptanceDto, <anonymous type: int Id, string IsAccepted, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>>(IEnumerable<MechanicAcceptanceDto> source, Func<MechanicAcceptanceDto, <anonymous type: int Id, string IsAccepted, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>> selector)'.
{
r.Id,
IsAccepted = r.IsAccepted ? "Qabul qilindi" : "Rad etildi",
r.Comments,
Status = ((StatusForDto)r.Status) switch
{
StatusForDto.Pending => "Pending",
StatusForDto.Completed => "Completed",
StatusForDto.Rejected => "Rejected",
StatusForDto.Unassigned => "Unassigned",
_ => "Unknown Status"
},
r.Date,
r.Distance,
r.DriverName,
r.MechanicName,
r.CarName,
r.CarId
}).ToList();


ViewBag.MechanicAcceptances = mechanicAcceptances;

return View();
}
public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("IsAccepted,Comments,Status,Date,Distance")] MechanicAcceptance mechanicAcceptance)
{
if (ModelState.IsValid)
{
await _mechanicAcceptanceDataStore.CreateMechanicAcceptanceAsync(mechanicAcceptance);
return RedirectToAction(nameof(Index));
}
return View(mechanicAcceptance);
}

public async Task<IActionResult> Edit(int id)
{
var mechanicAcceptance = await _mechanicAcceptanceDataStore.GetMechanicAcceptanceAsync(id);
if (mechanicAcceptance == null)
{
return NotFound();
}
return View(mechanicAcceptance);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,IsAccepted,Comments,Status,Date,Distance")] MechanicAcceptance mechanicAcceptance)
{
if (id != mechanicAcceptance.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _mechanicAcceptanceDataStore.UpdateMechanicAcceptanceAsync(id, mechanicAcceptance);
}
catch (Exception)
{
if (!await MechanicAcceptanceExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(mechanicAcceptance);
}

public async Task<IActionResult> Delete(int id)
{
var mechanicAcceptance = await _mechanicAcceptanceDataStore.GetMechanicAcceptanceAsync(id);
if (mechanicAcceptance == null)
{
return NotFound();
}
return View(mechanicAcceptance);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _mechanicAcceptanceDataStore.DeleteMechanicAcceptanceAsync(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> MechanicAcceptanceExists(int id)
{
var mechanicAcceptance = await _mechanicAcceptanceDataStore.GetMechanicAcceptanceAsync(id);
return mechanicAcceptance != null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,152 @@
using CheckDrive.ApiContracts;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.MechanicHandovers;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class MechanicHandoversController : Controller
{
private readonly IMechanicHandoverDataStore _mechanicHandoverDataStore;

public MechanicHandoversController(IMechanicHandoverDataStore mechanicHandoverDataStore)
{
_mechanicHandoverDataStore = mechanicHandoverDataStore;
}

public async Task<IActionResult> Index(int? pageNumber)
{

var response = await _mechanicHandoverDataStore.GetMechanicHandoversAsync(pageNumber);

ViewBag.PageSize = response.PageSize;
ViewBag.PageCount = response.TotalPages;
ViewBag.TotalCount = response.TotalCount;
ViewBag.CurrentPage = response.PageNumber;
ViewBag.HasPreviousPage = response.HasPreviousPage;
ViewBag.HasNextPage = response.HasNextPage;

var mechanicHandovers = response.Data.Select(r => new

Check warning on line 29 in CheckDrive.Web/CheckDrive.Web/Controllers/MechanicHandoversController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<<anonymous type: int Id, string IsHanded, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>> Enumerable.Select<MechanicHandoverDto, <anonymous type: int Id, string IsHanded, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>>(IEnumerable<MechanicHandoverDto> source, Func<MechanicHandoverDto, <anonymous type: int Id, string IsHanded, string Comments, string Status, DateTime Date, double Distance, string DriverName, string MechanicName, string CarName, int CarId>> selector)'.
{
r.Id,
IsHanded = r.IsHanded ? "Qabul qilindi" : "Rad etildi",
r.Comments,
Status = ((StatusForDto)r.Status) switch
{
StatusForDto.Pending => "Pending",
StatusForDto.Completed => "Completed",
StatusForDto.Rejected => "Rejected",
StatusForDto.Unassigned => "Unassigned",
_ => "Unknown Status"
},
r.Date,
r.Distance,
r.DriverName,
r.MechanicName,
r.CarName,
r.CarId
}).ToList();

if (mechanicHandovers == null)
{
return BadRequest();
}

ViewBag.MechanicHandovers = mechanicHandovers;

return View();
}

public async Task<IActionResult> Details(int id)
{
var mechanicHandover = await _mechanicHandoverDataStore.GetMechanicHandoverAsync(id);
if (mechanicHandover == null)
{
return NotFound();
}
return View(mechanicHandover);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("IsHanded,Comments,Status,Date,MechanicId,CarId,DriverId")] MechanicHandover mechanicHandover)
{
if (ModelState.IsValid)
{
await _mechanicHandoverDataStore.CreateMechanicHandoverAsync(mechanicHandover);
return RedirectToAction(nameof(Index));
}
return View(mechanicHandover);
}

public async Task<IActionResult> Edit(int id)
{
var mechanicHandover = await _mechanicHandoverDataStore.GetMechanicHandoverAsync(id);
if (mechanicHandover == null)
{
return NotFound();
}
return View(mechanicHandover);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,IsHanded,Comments,Status,Date,MechanicId,CarId,DriverId")] MechanicHandover mechanicHandover)
{
if (id != mechanicHandover.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _mechanicHandoverDataStore.UpdateMechanicHandoverAsync(id, mechanicHandover);
}
catch (Exception)
{
if (!await MechanicHandoverExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(mechanicHandover);
}

public async Task<IActionResult> Delete(int id)
{
var mechanicHandover = await _mechanicHandoverDataStore.GetMechanicHandoverAsync(id);
if (mechanicHandover == null)
{
return NotFound();
}
return View(mechanicHandover);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _mechanicHandoverDataStore.DeleteMechanicHandoverAsync(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> MechanicHandoverExists(int id)
{
var mechanicHandover = await _mechanicHandoverDataStore.GetMechanicHandoverAsync(id);
return mechanicHandover != null;
}
}
}
114 changes: 114 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/MechanicsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Mechanics;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class MechanicsController : Controller
{
private readonly IMechanicDataStore _mechanicDataStore;

public MechanicsController(IMechanicDataStore mechanicDataStore)
{
_mechanicDataStore = mechanicDataStore;
}

public async Task<IActionResult> Index()
{
var mechanics = await _mechanicDataStore.GetMechanicsAsync();
return View(mechanics);
}

public async Task<IActionResult> Details(int id)
{
var mechanic = await _mechanicDataStore.GetMechanicAsync(id);
if (mechanic == null)
{
return NotFound();
}
return View(mechanic);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] Mechanic mechanic)
{
if (ModelState.IsValid)
{
await _mechanicDataStore.CreateMechanicAsync(mechanic);
return RedirectToAction(nameof(Index));
}
return View(mechanic);
}

public async Task<IActionResult> Edit(int id)
{
var mechanic = await _mechanicDataStore.GetMechanicAsync(id);
if (mechanic == null)
{
return NotFound();
}
return View(mechanic);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,AccountId")] Mechanic mechanic)
{
if (id != mechanic.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _mechanicDataStore.UpdateMechanicAsync(id, mechanic);
}
catch (Exception)
{
if (!await MechanicExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(mechanic);
}

public async Task<IActionResult> Delete(int id)
{
var mechanic = await _mechanicDataStore.GetMechanicAsync(id);
if (mechanic == null)
{
return NotFound();
}
return View(mechanic);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _mechanicDataStore.DeleteMechanicAsync(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> MechanicExists(int id)
{
var mechanic = await _mechanicDataStore.GetMechanicAsync(id);
return mechanic != null;
}
}
}
118 changes: 118 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/OperatorReviewsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.OperatorReviews;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class OperatorReviewsController(IOperatorReviewDataStore operatorReviewDataStore) : Controller
{
private readonly IOperatorReviewDataStore _operatorReviewDataStore = operatorReviewDataStore;

public async Task<IActionResult> Index()
{

var operatorReviews = await _operatorReviewDataStore.GetOperatorsReviews();

if (operatorReviews is null)
{
return BadRequest();
}

ViewBag.OperatorsReview = operatorReviews.Data;
return View();

}

public async Task<IActionResult> Details(int id)
{
var operatorReview = await _operatorReviewDataStore.GetOperatorReview(id);
if (operatorReview == null)
{
return NotFound();
}
return View(operatorReview);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("OilAmount,Comments,Status,Date,OperatorId,DriverId")] OperatorReview operatorReview)
{
if (ModelState.IsValid)
{
await _operatorReviewDataStore.CreateOperatorReview(operatorReview);
return RedirectToAction(nameof(Index));
}
return View(operatorReview);
}

public async Task<IActionResult> Edit(int id)
{
var operatorReview = await _operatorReviewDataStore.GetOperatorReview(id);
if (operatorReview == null)
{
return NotFound();
}
return View(operatorReview);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,OilAmount,Comments,Status,Date,OperatorId,DriverId")] OperatorReview operatorReview)
{
if (id != operatorReview.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _operatorReviewDataStore.UpdateOperatorReview(id, operatorReview);
}
catch (Exception)
{
if (!await OperatorReviewExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(operatorReview);
}

public async Task<IActionResult> Delete(int id)
{
var operatorReview = await _operatorReviewDataStore.GetOperatorReview(id);
if (operatorReview == null)
{
return NotFound();
}
return View(operatorReview);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _operatorReviewDataStore.DeleteOperatorReview(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> OperatorReviewExists(int id)
{
var operatorReview = await _operatorReviewDataStore.GetOperatorReview(id);
return operatorReview != null;
}
}
}
120 changes: 120 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/OperatorsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Accounts;
using CheckDrive.Web.Stores.Operators;
using CheckDrive.Web.Stores.Roles;
using Microsoft.AspNetCore.Mvc;
using Syncfusion.EJ2.PivotView;

namespace CheckDrive.Web.Controllers
{
public class OperatorsController : Controller
{
private readonly IOperatorDataStore _operatorDataStore;
private readonly IAccountDataStore _accountDataStore;
private readonly IRoleDataStore _roleDataStore;

public OperatorsController(IOperatorDataStore operatorDataStore, IAccountDataStore accountDataStore, IRoleDataStore roleDataStore)
{
_operatorDataStore = operatorDataStore;
_accountDataStore = accountDataStore;
_roleDataStore = roleDataStore;
}

public async Task<IActionResult> Index()

Check warning on line 23 in CheckDrive.Web/CheckDrive.Web/Controllers/OperatorsController.cs

GitHub Actions / build

This async method lacks 'await' operators and will run synchronously. Consider using the 'await' operator to await non-blocking API calls, or 'await Task.Run(...)' to do CPU-bound work on a background thread.
{
return View();
}

public async Task<IActionResult> Details(int id)
{
var @operator = await _operatorDataStore.GetOperator(id);
if (@operator == null)
{
return NotFound();
}
return View(@operator);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] Operator @operator)
{
if (ModelState.IsValid)
{
await _operatorDataStore.CreateOperator(@operator);
return RedirectToAction(nameof(Index));
}
return View(@operator);
}

public async Task<IActionResult> Edit(int id)
{
var @operator = await _operatorDataStore.GetOperator(id);
if (@operator == null)
{
return NotFound();
}
return View(@operator);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,AccountId")] Operator @operator)
{
if (id != @operator.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _operatorDataStore.UpdateOperator(id, @operator);
}
catch (Exception)
{
if (!await OperatorExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(@operator);
}

public async Task<IActionResult> Delete(int id)
{
var @operator = await _operatorDataStore.GetOperator(id);
if (@operator == null)
{
return NotFound();
}
return View(@operator);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _operatorDataStore.DeleteOperator(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> OperatorExists(int id)
{
var @operator = await _operatorDataStore.GetOperator(id);
return @operator != null;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,169 @@
using CheckDrive.ApiContracts.DoctorReview;
using CheckDrive.Web.Stores.DoctorReviews;
using CheckDrive.Web.Stores.Doctors;
using CheckDrive.Web.Stores.Drivers;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;

namespace CheckDrive.Web.Controllers
{
public class PersonalDoctorReviewsController : Controller
{
private readonly IDoctorReviewDataStore _doctorReviewDataStore;
private readonly IDoctorDataStore _doctorDataStore;
private readonly IDriverDataStore _driverDataStore;

public PersonalDoctorReviewsController(IDoctorReviewDataStore doctorReviewDataStore, IDoctorDataStore doctorDataStore, IDriverDataStore driverDataStore)
{
_doctorReviewDataStore = doctorReviewDataStore;
_doctorDataStore = doctorDataStore;
_driverDataStore = driverDataStore;
}

public IActionResult HelloPage()
{
return View();
}

public async Task<IActionResult> Index(int? pageNumber)
{
var response = await _doctorReviewDataStore.GetDoctorReviews( pageNumber);
var doctorReviews = response.Data.Select(r => new

Check warning on line 31 in CheckDrive.Web/CheckDrive.Web/Controllers/PersonalDoctorReviewsController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<<anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>> Enumerable.Select<DoctorReviewDto, <anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>>(IEnumerable<DoctorReviewDto> source, Func<DoctorReviewDto, <anonymous type: int Id, string DriverName, string DoctorName, string IsHealthy, string Comments>> selector)'.
{
r.Id,
r.DriverName,
r.DoctorName,
IsHealthy = r.IsHealthy ? "Sog`lom" : "Kasal",
r.Comments
}).ToList();

ViewBag.DoctorsReview = doctorReviews;

return View();
}

public async Task<IActionResult> Details(int id)
{
var doctorReview = await _doctorReviewDataStore.GetDoctorReview(id);
if (doctorReview == null)
{
return NotFound();
}
return View(doctorReview);
}

public async Task<IActionResult> Create()
{
var doctors = await GETDoctors();
var drivers = await GETDrivers();

ViewBag.Drivers = new SelectList(drivers, "Value", "Text");
ViewBag.Doctors = new SelectList(doctors, "Value", "Text");

return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("IsHealthy,Comments,Date,DriverId,DoctorId")] DoctorReviewForCreateDto doctorReview)
{
if (ModelState.IsValid)
{
await _doctorReviewDataStore.CreateDoctorReview(doctorReview);
return RedirectToAction(nameof(Index));
}
return View(doctorReview);
}

public async Task<IActionResult> Edit(int id)
{
var doctorReview = await _doctorReviewDataStore.GetDoctorReview(id);
if (doctorReview == null)
{
return NotFound();
}
return View(doctorReview);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,IsHealthy,Comments,Date,DriverId,DoctorId")] DoctorReviewForUpdateDto doctorReview)
{
if (id != doctorReview.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
try
{
await _doctorReviewDataStore.UpdateDoctorReview(id, doctorReview);
}
catch (Exception)
{
if (!await DoctorReviewExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(doctorReview);
}

public async Task<IActionResult> Delete(int id)
{
var doctorReview = await _doctorReviewDataStore.GetDoctorReview(id);
if (doctorReview == null)
{
return NotFound();
}
return View(doctorReview);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _doctorReviewDataStore.DeleteDoctorReview(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> DoctorReviewExists(int id)
{
var doctorReview = await _doctorReviewDataStore.GetDoctorReview(id);
return doctorReview != null;
}

private async Task<List<SelectListItem>> GETDrivers()
{
var driverResponse = await _driverDataStore.GetDriversAsync();
var drivers = driverResponse.Data

Check warning on line 146 in CheckDrive.Web/CheckDrive.Web/Controllers/PersonalDoctorReviewsController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<SelectListItem> Enumerable.Select<DriverDto, SelectListItem>(IEnumerable<DriverDto> source, Func<DriverDto, SelectListItem> selector)'.
.Select(d => new SelectListItem
{
Value = d.Id.ToString(),
Text = $"{d.FirstName} {d.LastName}"
})
.ToList();
return drivers;
}

private async Task<List<SelectListItem>> GETDoctors()
{
var doctorResponse = await _doctorDataStore.GetDoctors();
var doctors = doctorResponse.Data

Check warning on line 159 in CheckDrive.Web/CheckDrive.Web/Controllers/PersonalDoctorReviewsController.cs

GitHub Actions / build

Possible null reference argument for parameter 'source' in 'IEnumerable<SelectListItem> Enumerable.Select<DoctorDto, SelectListItem>(IEnumerable<DoctorDto> source, Func<DoctorDto, SelectListItem> selector)'.
.Select(d => new SelectListItem
{
Value = d.Id.ToString(),
Text = $"{d.FirstName} {d.LastName}"
})
.ToList();
return doctors;
}
}
}
112 changes: 112 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/RolesController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
using CheckDrive.ApiContracts.Role;
using CheckDrive.DTOs.Role;
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Roles;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class RolesController : Controller
{
private readonly IRoleDataStore _roleDataStore;

public RolesController(IRoleDataStore roleDataStore)
{
_roleDataStore = roleDataStore;
}

public async Task<IActionResult> Index()
{
var roles = await _roleDataStore.GetRoles();
return View(roles);
}

public async Task<IActionResult> Details(int id)
{
var role = await _roleDataStore.GetRole(id);
if (role == null)
{
return NotFound();
}
return View(role);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("Name")] ApiContracts.Role.RoleForCreateDto role)
{
if (ModelState.IsValid)
{
await _roleDataStore.CreateRole(role);
return RedirectToAction(nameof(Index));
}
return View(role);
}

public async Task<IActionResult> Edit(int id)
{
var role = await _roleDataStore.GetRole(id);
if (role == null)
{
return NotFound();
}
return View(role);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id,Name")] ApiContracts.Role.RoleForCreateDto role)
{

if (ModelState.IsValid)
{
try
{
await _roleDataStore.UpdateRole(id, role);
}
catch (Exception)
{
if (!await RoleExists(id))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction(nameof(Index));
}
return View(role);
}

public async Task<IActionResult> Delete(int id)
{
var role = await _roleDataStore.GetRole(id);
if (role == null)
{
return NotFound();
}
return View(role);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _roleDataStore.DeleteRole(id);
return RedirectToAction(nameof(Index));
}

private async Task<bool> RoleExists(int id)
{
var role = await _roleDataStore.GetRole(id);
return role != null;
}
}
}
92 changes: 92 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Controllers/TechniciansController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
using CheckDrive.Web.Models;
using CheckDrive.Web.Stores.Technicians;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Web.Controllers
{
public class TechniciansController : Controller
{
private readonly ITechnicianDataStore _technicianDataStore;

public TechniciansController(ITechnicianDataStore technicianDataStore)
{
_technicianDataStore = technicianDataStore;
}
public async Task<IActionResult> Index()
{
var technicians = await _technicianDataStore.GetTechnicians();
return View(technicians);
}

public async Task<IActionResult> Details(int id)
{
var technician = await _technicianDataStore.GetTechnician(id);
if (technician == null)
{
return NotFound();
}
return View(technician);
}

public IActionResult Create()
{
return View();
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("AccountId")] Technician technician)
{
if (ModelState.IsValid)
{
await _technicianDataStore.CreateTechnician(technician);
return RedirectToAction(nameof(Index));
}
return View(technician);
}

public async Task<IActionResult> Edit(int id)
{
var technician = await _technicianDataStore.GetTechnician(id);
if (technician == null)
{
return NotFound();
}
return View(technician);
}

[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("Id, AccountId")] Technician technician)
{
if (id != technician.Id)
{
return NotFound();
}

if (ModelState.IsValid)
{
await _technicianDataStore.UpdateTechnician(id, technician);
return RedirectToAction(nameof(Index));
}
return View(technician);
}
public async Task<IActionResult> Delete(int id)
{
var technician = await _technicianDataStore.GetTechnician(id);
if (technician == null)
{
return NotFound();
}
return View(technician);
}

[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
await _technicianDataStore.DeleteTechnician(id);
return RedirectToAction(nameof(Index));
}
}
}
20 changes: 20 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Exceptions/ApiException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System.Net;

namespace CheckDrive.Web.Exceptions
{
public class ApiException : Exception
{
public HttpStatusCode StatusCode { get; private set; }

public ApiException(HttpStatusCode statusCode) : base()
{
StatusCode = statusCode;
}

public ApiException(HttpStatusCode statusCode, string message) :
base(message)
{
StatusCode = statusCode;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using CheckDrive.Web.Service;
using CheckDrive.Web.Stores.Accounts;
using CheckDrive.Web.Stores.Cars;
using CheckDrive.Web.Stores.DispatcherReviews;
using CheckDrive.Web.Stores.Dispatchers;
using CheckDrive.Web.Stores.DoctorReviews;
using CheckDrive.Web.Stores.Doctors;
using CheckDrive.Web.Stores.Drivers;
using CheckDrive.Web.Stores.MechanicAcceptances;
using CheckDrive.Web.Stores.MechanicHandovers;
using CheckDrive.Web.Stores.Mechanics;
using CheckDrive.Web.Stores.OperatorReviews;
using CheckDrive.Web.Stores.Operators;
using CheckDrive.Web.Stores.Roles;
using CheckDrive.Web.Stores.Technicians;

namespace CheckDrive.Web.Extensions
{
public static class ConfigureServiceExtensions
{
public static IServiceCollection ConfigureDataStores(this IServiceCollection services)
{
services.AddScoped<IAccountDataStore, AccountDataStore>();
services.AddScoped<ICarDataStore, CarDataStore>();
services.AddScoped<IDispatcherReviewDataStore, MockDispatcherReviewDataStore>();
services.AddScoped<IDispatcherDataStore, MockDispatcherDataStore>();
services.AddScoped<IDoctorDataStore, DoctorDataStore>();
services.AddScoped<IDoctorReviewDataStore, DoctorReviewDataStore>();
services.AddScoped<IDriverDataStore, DriverDataStore>();
services.AddScoped<IMechanicAcceptanceDataStore, MechanicAcceptanceDataStore>();
services.AddScoped<IMechanicHandoverDataStore, MechanicHandoverDataStore>();
services.AddScoped<IMechanicDataStore, MechanicDataStore>();
services.AddScoped<IOperatorReviewDataStore, OperatorReviewDataStore>();
services.AddScoped<IOperatorDataStore, OperatorDataStore>();
services.AddScoped<IRoleDataStore, RoleDataStore>();
services.AddScoped<ITechnicianDataStore, MockTechnicianDataStore>();

return services;
}

public static IServiceCollection ConfigureServices(this IServiceCollection services)
{
services.AddSingleton<ApiClient>();

return services;
}
}
}
24 changes: 24 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Filters/ApiExceptionFilter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using CheckDrive.Web.Exceptions;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Filters;

namespace CheckDrive.Web.Filters
{
public class ApiExceptionFilter : IExceptionFilter
{
public void OnException(ExceptionContext context)
{
if (context.Exception is ApiException exception)
{
int statusCode = (int)exception.StatusCode;
context.Result = new RedirectToActionResult("Error", "Home", new { statusCode });
context.ExceptionHandled = true;
}
else
{
context.Result = new RedirectToActionResult("Error", "Home", new { statusCode = 500 });
context.ExceptionHandled = true;
}
}
}
}
36 changes: 36 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Helpers/PaginatedList.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.EntityFrameworkCore;

namespace CheckDrive.Web.Helpers
{
public class PaginatedList<T> : List<T>
{
public int PageIndex { get; private set; }
public int TotalPages { get; private set; }

public PaginatedList(List<T> items, int count, int pageIndex, int pageSize)
{
PageIndex = pageIndex;
TotalPages = (int)Math.Ceiling(count / (double)pageSize);

AddRange(items);
}

public bool HasPreviousPage => PageIndex > 1;

public bool HasNextPage => PageIndex < TotalPages;

public static async Task<PaginatedList<T>> CreateAsync(IQueryable<T> source, int pageIndex, int pageSize)
{
var count = await source.CountAsync();
var items = await source.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToListAsync();
return new PaginatedList<T>(items, count, pageIndex, pageSize);
}

public static PaginatedList<T> Create(IQueryable<T> source, int pageIndex, int pageSize)
{
var count = source.Count();
var items = source.Skip((pageIndex - 1) * pageSize).Take(pageSize).ToList();
return new PaginatedList<T>(items, count, pageIndex, pageSize);
}
}
}
24 changes: 24 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Account.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
namespace CheckDrive.Web.Models
{
public class Account
{
public int Id { get; set; }
public string Login { get; set; }
public string Password { get; set; }
public string PhoneNumber { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public DateTime Bithdate { get; set; }

public string RoleName { get; set; }
public Role Role { get; set; }

public virtual ICollection<Dispatcher> Dispatchers { get; set; }
public virtual ICollection<Operator> Operators { get; set; }
public virtual ICollection<Mechanic> Mechanics { get; set; }
public virtual ICollection<Driver> Drivers { get; set; }
public virtual ICollection<Doctor> Doctors { get; set; }
public virtual ICollection<Technician> Technicians { get; set; }
}
}

16 changes: 16 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Car.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace CheckDrive.Web.Models
{
public class Car
{
public int Id { get; set; }
public string Model { get; set; }
public string Color { get; set; }
public string Number { get; set; }
public double MeduimFuelConsumption { get; set; }
public double RemainingFuel { get; set; }
public double FuelTankCapacity { get; set; }
public int ManufacturedYear { get; set; }

public virtual ICollection<MechanicHandover> MechanicHandovers { get; set; }
}
}
11 changes: 11 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Dispatcher.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace CheckDrive.Web.Models
{
public class Dispatcher
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }

public virtual ICollection<DispatcherReview> DispetcherReviews { get; set; }
}
}
19 changes: 19 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/DispatcherReview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
namespace CheckDrive.Web.Models
{
public class DispatcherReview
{
public int Id { get; set; }
public double FuelSpended { get; set; }
public double DistanceCovered { get; set; }
public DateTime Date { get; set; }

public int DispatcherId { get; set; }
public Dispatcher Dispatcher { get; set; }
public int OperatorId { get; set; }
public Operator Operator { get; set; }
public int MechanicId { get; set; }
public Mechanic Mechanic { get; set; }
public int DriverId { get; set; }
public Driver Driver { get; set; }
}
}
11 changes: 11 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Doctor.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace CheckDrive.Web.Models
{
public class Doctor
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }

public virtual ICollection<DoctorReview> DoctorReviews { get; set; }
}
}
15 changes: 15 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/DoctorReview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
namespace CheckDrive.Web.Models
{
public class DoctorReview
{
public int Id { get; set; }
public bool IsHealthy { get; set; }
public string? Comments { get; set; }
public DateTime Date { get; set; }

public int DriverId { get; set; }
public Driver Driver { get; set; }
public int DoctorId { get; set; }
public Doctor Doctor { get; set; }
}
}
14 changes: 14 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Driver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
namespace CheckDrive.Web.Models
{
public class Driver
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }

public virtual ICollection<DispatcherReview> DispetcherReviews { get; set; }
public virtual ICollection<DoctorReview> DoctorReviews { get; set; }
public virtual ICollection<MechanicHandover> MechanicHandovers { get; set; }
public virtual ICollection<OperatorReview> OperatorReviews { get; set; }
}
}
8 changes: 0 additions & 8 deletions CheckDrive.Web/CheckDrive.Web/Models/ErrorViewModel.cs

This file was deleted.

12 changes: 12 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Mechanic.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CheckDrive.Web.Models
{
public class Mechanic
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }

public virtual ICollection<DispatcherReview> DispetcherReviews { get; set; }
public virtual ICollection<MechanicHandover> MechanicHandovers { get; set; }
}
}
16 changes: 16 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/MechanicAcceptance.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace CheckDrive.Web.Models
{
public class MechanicAcceptance
{
public int Id { get; set; }

public bool IsAccepted { get; set; }
public string? Comments { get; set; }
public Status Status { get; set; }
public DateTime Date { get; set; }
public double Distance { get; set; }

public int MechanicHandoverId { get; set; }
public MechanicHandover MechanicHandover { get; set; }
}
}
20 changes: 20 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/MechanicHandover.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace CheckDrive.Web.Models
{
public class MechanicHandover
{
public int Id { get; set; }
public bool IsHanded { get; set; }
public string? Comments { get; set; }
public Status Status { get; set; }
public DateTime Date { get; set; }

public int MechanicId { get; set; }
public Mechanic Mechanic { get; set; }
public int CarId { get; set; }
public Car Car { get; set; }
public int DriverId { get; set; }
public Driver Driver { get; set; }

public virtual ICollection<MechanicAcceptance> MechanicAcceptances { get; set; }
}
}
12 changes: 12 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Operator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
namespace CheckDrive.Web.Models
{
public class Operator
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }

public virtual ICollection<DispatcherReview> DispetcherReviews { get; set; }
public virtual ICollection<OperatorReview> OperatorReviews { get; set; }
}
}
16 changes: 16 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/OperatorReview.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
namespace CheckDrive.Web.Models
{
public class OperatorReview
{
public int Id { get; set; }
public double OilAmount { get; set; }
public string? Comments { get; set; }
public Status Status { get; set; }
public DateTime Date { get; set; }

public int OperatorId { get; set; }
public Operator Operator { get; set; }
public int DriverId { get; set; }
public Driver Driver { get; set; }
}
}
10 changes: 10 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Role.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CheckDrive.Web.Models
{
public class Role
{
public int Id { get; set; }
public string Name { get; set; }

public virtual ICollection<Account> Accounts { get; set; }
}
}
10 changes: 10 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Status.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
namespace CheckDrive.Web.Models
{
public enum Status
{
Pending,
Completed,
Rejected,
Unassigned
}
}
9 changes: 9 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Models/Technician.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace CheckDrive.Web.Models
{
public class Technician
{
public int Id { get; set; }
public int AccountId { get; set; }
public Account Account { get; set; }
}
}
15 changes: 13 additions & 2 deletions CheckDrive.Web/CheckDrive.Web/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
using CheckDrive.Web.Constants;
using CheckDrive.Web.Extensions;
using CheckDrive.Web.Filters;


var builder = WebApplication.CreateBuilder(args);

// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Services.AddControllersWithViews(options =>
options.Filters.Add(new ApiExceptionFilter()));
builder.Services.ConfigureDataStores();
builder.Services.ConfigureServices();
builder.Services.AddHttpContextAccessor();

Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(Configurations.SynfusionLicenseKey);

var app = builder.Build();

@@ -22,6 +33,6 @@

app.MapControllerRoute(
name: "default",
pattern: "{controller=Home}/{action=Index}/{id?}");
pattern: "{controller=Dashboard}/{action=index}/{id?}");

app.Run();
8 changes: 8 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetAccountResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.ApiContracts.Account;

namespace CheckDrive.Web.Responses
{
public class GetAccountResponse : GetBaseResponse<AccountDto>
{
}
}
13 changes: 13 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetBaseResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace CheckDrive.Web.Responses
{
public abstract class GetBaseResponse<T>
{
public IEnumerable<T>? Data { get; set; }
public int PageNumber { get; set; }
public int PageSize { get; set; }
public bool HasNextPage { get; set; }
public bool HasPreviousPage { get; set; }
public int TotalPages { get; set; }
public int TotalCount { get; set; }
}
}
8 changes: 8 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetCarResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetCarResponse : GetBaseResponse<Car>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using Microsoft.AspNetCore.Components;

namespace CheckDrive.Web.Responses
{
public class GetDispatcherResponse : GetBaseResponse<Dispatcher>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetDispatcherReviewResponse : GetBaseResponse<DispatcherReview>
{
}
}
8 changes: 8 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetDoctorResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.ApiContracts.Doctor;

namespace CheckDrive.Web.Responses
{
public class GetDoctorResponse : GetBaseResponse<DoctorDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using CheckDrive.ApiContracts.DoctorReview;
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetDoctorReviewResponse : GetBaseResponse<DoctorReviewDto>
{
}
}
9 changes: 9 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetDriverResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using CheckDrive.ApiContracts.Driver;
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetDriverResponse : GetBaseResponse<DriverDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CheckDrive.Web.Responses
{
public class GetMechanicAcceptanceResponse : GetBaseResponse<ApiContracts.MechanicAcceptance.MechanicAcceptanceDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CheckDrive.Web.Responses
{
public class GetMechanicHandoverResponse : GetBaseResponse<ApiContracts.MechanicHandover.MechanicHandoverDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
namespace CheckDrive.Web.Responses
{
public class GetMechanicResponse : GetBaseResponse<ApiContracts.Mechanic.MechanicDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetOperatorResponse : GetBaseResponse<Operator>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetOperatorReviewResponse : GetBaseResponse<ApiContracts.OperatorReview.OperatorReviewDto>
{
}
}
9 changes: 9 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Responses/GetRoleResponse.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using CheckDrive.ApiContracts.Role;
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetRoleResponse : GetBaseResponse<RoleDto>
{
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Responses
{
public class GetTechnicianResponse : GetBaseResponse<Technician>
{
}
}
94 changes: 94 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Service/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
using CheckDrive.Web.Constants;
using CheckDrive.Web.Exceptions;

namespace CheckDrive.Web.Service
{
public class ApiClient
{
private const string baseUrl = "https://v1n3bj45-7111.euw.devtunnels.ms/api";

private readonly HttpClient _client = new();
private readonly IHttpContextAccessor _contextAccessor;

public ApiClient(IHttpContextAccessor contextAccessor)
{
_client.BaseAddress = new Uri(baseUrl);
_client.DefaultRequestHeaders.Add("Accept", "application/json");
_contextAccessor = contextAccessor ?? throw new ArgumentNullException(nameof(contextAccessor));
}

public async Task<HttpResponseMessage> GetAsync(string url)
{
string token = string.Empty;
var request = new HttpRequestMessage(HttpMethod.Get, _client.BaseAddress?.AbsolutePath + "/" + url);
_contextAccessor.HttpContext?.Request.Cookies.TryGetValue(Configurations.JwtToken, out token);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

var response = await _client.SendAsync(request);

if (!response.IsSuccessStatusCode)
{
throw new ApiException(response.StatusCode, $"Error fetching url: {url}");
}

return response;
}

public async Task<HttpResponseMessage> PostAsync(string url, string data)
{
string token = string.Empty;
var request = new HttpRequestMessage(HttpMethod.Post, _client.BaseAddress?.AbsolutePath + "/" + url)
{
Content = new StringContent(data, System.Text.Encoding.UTF8, "application/json")
};
_contextAccessor.HttpContext?.Request.Cookies.TryGetValue(Configurations.JwtToken, out token);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

var response = await _client.SendAsync(request);

if (!response.IsSuccessStatusCode)
{
throw new ApiException(response.StatusCode, $"Error fetching url: {url}");
}

return response;
}

public async Task<HttpResponseMessage> PutAsync(string url, string data)
{
string token = string.Empty;
var request = new HttpRequestMessage(HttpMethod.Put, _client.BaseAddress?.AbsolutePath + "/" + url)
{
Content = new StringContent(data, System.Text.Encoding.UTF8, "application/json")
};
_contextAccessor.HttpContext?.Request.Cookies.TryGetValue(Configurations.JwtToken, out token);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

var response = await _client.SendAsync(request);

if (!response.IsSuccessStatusCode)
{
throw new ApiException(response.StatusCode, $"Error fetching url: {url}");
}

return response;
}

public async Task<HttpResponseMessage> DeleteAsync(string url)
{
string token = string.Empty;
var request = new HttpRequestMessage(HttpMethod.Delete, _client.BaseAddress?.AbsolutePath + "/" + url);
_contextAccessor.HttpContext?.Request.Cookies.TryGetValue(Configurations.JwtToken, out token);
request.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", token);

var response = await _client.SendAsync(request);

if (!response.IsSuccessStatusCode)
{
throw new ApiException(response.StatusCode, $"Error fetching url: {url}");
}

return response;
}
}
}
111 changes: 111 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Accounts/AccountDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.Web.Responses;
using CheckDrive.Web.Service;
using Newtonsoft.Json;
using System.Text;

namespace CheckDrive.Web.Stores.Accounts
{
public class AccountDataStore : IAccountDataStore
{
private readonly ApiClient _api;

public AccountDataStore(ApiClient apiClient)
{
_api = apiClient;
}


public async Task<GetAccountResponse> GetAccountsAsync(string? searchString, int? roleId, DateTime? birthDate, int? pageNumber)
{
StringBuilder query = new("");

if (birthDate is not null)
{
query.Append($"birthDate={birthDate.Value.ToString("MM/dd/yyyy")}&");
}
if (!string.IsNullOrWhiteSpace(searchString))
{
query.Append($"searchString={searchString}&");
}
if (roleId is not null)
{
query.Append($"roleId={roleId}&");
}
if (pageNumber != null)
{
query.Append($"pageNumber={pageNumber}");
}

var response = await _api.GetAsync("accounts?" + query.ToString());

if (!response.IsSuccessStatusCode)
{
throw new Exception("Could not fetch accounts.");
}


var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<GetAccountResponse>(json);

return result;
}

public async Task<AccountDto> GetAccountAsync(int id)

{
var response = await _api.GetAsync($"accounts/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not fetch account with id: {id}.");
}

var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<AccountDto>(json);

return result;
}

public async Task<AccountDto> CreateAccountAsync(AccountForCreateDto account)
{
var json = JsonConvert.SerializeObject(account);
var response = await _api.PostAsync("accounts", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error creating account.");
}

var jsonResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<AccountDto>(jsonResponse);
}



public async Task<AccountDto> UpdateAccountAsync(int id, AccountForUpdateDto account)
{
var json = JsonConvert.SerializeObject(account);
var response = await _api.PutAsync($"accounts/{account.Id}", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error updating account.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<AccountDto>(jsonResponse);
}

public async Task DeleteAccountAsync(int id)
{
var response = await _api.DeleteAsync($"accounts/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not delete account with id: {id}.");
}
}
}
}
14 changes: 14 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Accounts/IAccountDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.Web.Responses;

namespace CheckDrive.Web.Stores.Accounts
{
public interface IAccountDataStore
{
Task<GetAccountResponse> GetAccountsAsync(string? searchString, int? roleId, DateTime? birthDate, int? pageNumber);
Task<AccountDto> GetAccountAsync(int id);
Task<AccountDto> CreateAccountAsync(AccountForCreateDto account);
Task<AccountDto> UpdateAccountAsync(int id, AccountForUpdateDto account);
Task DeleteAccountAsync(int id);
}
}
100 changes: 100 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Cars/CarDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
using CheckDrive.ApiContracts.Car;
using CheckDrive.Web.Responses;
using CheckDrive.Web.Service;
using Newtonsoft.Json;
using System.Text;
using static Microsoft.EntityFrameworkCore.DbLoggerCategory;

namespace CheckDrive.Web.Stores.Cars
{
public class CarDataStore : ICarDataStore
{
private readonly ApiClient _api;

public CarDataStore(ApiClient apiClient)
{
_api = apiClient;
}

public async Task<GetCarResponse> GetCars(string? searchString,int? pageNumber)
{
StringBuilder query = new("");

if (!string.IsNullOrWhiteSpace(searchString))
{
query.Append($"searchString={searchString}&");
}
if (pageNumber != null)
{
query.Append($"pageNumber={pageNumber}");
}

var response = await _api.GetAsync("cars?" + query.ToString());

if (!response.IsSuccessStatusCode)
{
throw new Exception("Could not fetch cars.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<GetCarResponse>(json);

return result;
}

public async Task<CarDto> GetCar(int id)
{
var response = await _api.GetAsync($"cars/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not fetch car with id: {id}.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<CarDto>(json);

return result;
}

public async Task<CarDto> CreateCar(CarForCreateDto carForCreate)
{
var json = JsonConvert.SerializeObject(carForCreate);
var response = await _api.PostAsync("cars", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error creating cars.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<CarDto>(jsonResponse);
}

public async Task<CarDto> UpdateCar(int id, CarForUpdateDto car)
{
var json = JsonConvert.SerializeObject(car);
var response = await _api.PutAsync($"cars/{car.Id}", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error updating cars.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<CarDto>(jsonResponse);
}

public async Task DeleteCar(int id)
{
var response = await _api.DeleteAsync($"cars/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not delete car with id: {id}.");
}
}
}
}
14 changes: 14 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Cars/ICarDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using CheckDrive.ApiContracts.Car;
using CheckDrive.Web.Responses;

namespace CheckDrive.Web.Stores.Cars
{
public interface ICarDataStore
{
Task<GetCarResponse> GetCars(string? searchString, int? pageNumber);
Task<CarDto> GetCar(int id);
Task<CarDto> CreateCar(CarForCreateDto carForCreate);
Task<CarDto> UpdateCar(int id, CarForUpdateDto car);
Task DeleteCar(int id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Stores.DispatcherReviews
{
public interface IDispatcherReviewDataStore
{
Task<List<DispatcherReview>> GetDispatcherReviews();
Task<DispatcherReview> GetDispatcherReview(int id);
Task<DispatcherReview> CreateDispatcherReview(DispatcherReview review);
Task<DispatcherReview> UpdateDispatcherReview(int id, DispatcherReview review);
Task DeleteDispatcherReview(int id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Stores.DispatcherReviews
{
public class MockDispatcherReviewDataStore : IDispatcherReviewDataStore
{
private readonly List<DispatcherReview> _reviews;

public MockDispatcherReviewDataStore()
{
_reviews = new List<DispatcherReview>
{
new DispatcherReview { Id = 1, FuelSpended = 50, DistanceCovered = 100, Date = DateTime.Now },
new DispatcherReview { Id = 2, FuelSpended = 60, DistanceCovered = 120, Date = DateTime.Now.AddDays(-1) },
};
}

public async Task<List<DispatcherReview>> GetDispatcherReviews()
{
await Task.Delay(100);
return _reviews.ToList();
}

public async Task<DispatcherReview> GetDispatcherReview(int id)
{
await Task.Delay(100);
return _reviews.FirstOrDefault(r => r.Id == id);
}

public async Task<DispatcherReview> CreateDispatcherReview(DispatcherReview review)
{
await Task.Delay(100);
review.Id = _reviews.Max(r => r.Id) + 1;
_reviews.Add(review);
return review;
}

public async Task<DispatcherReview> UpdateDispatcherReview(int id, DispatcherReview review)
{
await Task.Delay(100);
var existingReview = _reviews.FirstOrDefault(r => r.Id == id);
if (existingReview != null)
{
existingReview.FuelSpended = review.FuelSpended;
existingReview.DistanceCovered = review.DistanceCovered;
existingReview.Date = review.Date;
}
return existingReview;
}

public async Task DeleteDispatcherReview(int id)
{
await Task.Delay(100);
var reviewToRemove = _reviews.FirstOrDefault(r => r.Id == id);
if (reviewToRemove != null)
{
_reviews.Remove(reviewToRemove);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Stores.Dispatchers
{
public interface IDispatcherDataStore
{
Task<List<Dispatcher>> GetDispatchers();
Task<Dispatcher> GetDispatcher(int id);
Task<Dispatcher> CreateDispatcher(Dispatcher dispatcher);
Task<Dispatcher> UpdateDispatcher(int id, Dispatcher dispatcher);
Task DeleteDispatcher(int id);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
using CheckDrive.Web.Models;

namespace CheckDrive.Web.Stores.Dispatchers
{
public class MockDispatcherDataStore : IDispatcherDataStore
{
private readonly List<Dispatcher> _dispatchers;

public MockDispatcherDataStore()
{
_dispatchers = new List<Dispatcher>
{
new Dispatcher { Id = 1, AccountId = 1 },
new Dispatcher { Id = 2, AccountId = 2 },
};
}

public async Task<List<Dispatcher>> GetDispatchers()
{
await Task.Delay(100);
return _dispatchers.ToList();
}

public async Task<Dispatcher> GetDispatcher(int id)
{
await Task.Delay(100);
return _dispatchers.FirstOrDefault(d => d.Id == id);
}

public async Task<Dispatcher> CreateDispatcher(Dispatcher dispatcher)
{
await Task.Delay(100);
dispatcher.Id = _dispatchers.Max(d => d.Id) + 1;
_dispatchers.Add(dispatcher);
return dispatcher;
}

public async Task<Dispatcher> UpdateDispatcher(int id, Dispatcher dispatcher)
{
await Task.Delay(100);
var existingDispatcher = _dispatchers.FirstOrDefault(d => d.Id == id);
if (existingDispatcher != null)
{
existingDispatcher.AccountId = dispatcher.AccountId;
}
return existingDispatcher;
}

public async Task DeleteDispatcher(int id)
{
await Task.Delay(100);
var dispatcherToRemove = _dispatchers.FirstOrDefault(d => d.Id == id);
if (dispatcherToRemove != null)
{
_dispatchers.Remove(dispatcherToRemove);
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
using System.Text;
using CheckDrive.ApiContracts.DoctorReview;
using CheckDrive.Web.Models;
using CheckDrive.Web.Responses;
using CheckDrive.Web.Service;
using Newtonsoft.Json;

namespace CheckDrive.Web.Stores.DoctorReviews
{
public class DoctorReviewDataStore(ApiClient api) : IDoctorReviewDataStore
{
private readonly ApiClient _api = api;

public async Task<GetDoctorReviewResponse> GetDoctorReviews(int? pageNumber)
{
StringBuilder query = new("");

if (pageNumber != null)
{
query.Append($"pageNumber={pageNumber}");
}
var response = await _api.GetAsync("doctors/reviews?" + query.ToString());

if (!response.IsSuccessStatusCode)
{
throw new Exception("Could not fetch doctorReviews.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<GetDoctorReviewResponse>(json);

return result;
}

public async Task<DoctorReviewDto> GetDoctorReview(int id)
{
var response = await _api.GetAsync($"doctors/review/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not fetch doctorReview with id: {id}.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<DoctorReviewDto>(json);

return result;
}

public async Task<DoctorReviewDto> CreateDoctorReview(DoctorReviewForCreateDto review)
{
var json = JsonConvert.SerializeObject(review);
var response = await _api.PostAsync("doctors/review", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error creating doctorReviews.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<DoctorReviewDto>(jsonResponse);
}

public async Task<DoctorReview> UpdateDoctorReview(int id, DoctorReviewForUpdateDto review)
{
var json = JsonConvert.SerializeObject(review);
var response = await _api.PutAsync($"doctors/review/{review.Id}", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error updating doctorReview.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<DoctorReview>(jsonResponse);
}

public async Task DeleteDoctorReview(int id)
{
throw new NotImplementedException();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using CheckDrive.ApiContracts.DoctorReview;
using CheckDrive.Web.Models;
using CheckDrive.Web.Responses;

namespace CheckDrive.Web.Stores.DoctorReviews
{
public interface IDoctorReviewDataStore
{
Task<GetDoctorReviewResponse> GetDoctorReviews(int? pageNumber);
Task<DoctorReviewDto> GetDoctorReview(int id);
Task<DoctorReviewDto> CreateDoctorReview(DoctorReviewForCreateDto review);
Task<DoctorReview> UpdateDoctorReview(int id, DoctorReviewForUpdateDto review);
Task DeleteDoctorReview(int id);
}
}
88 changes: 88 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Doctors/DoctorDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Doctor;
using CheckDrive.Web.Responses;
using CheckDrive.Web.Service;
using Newtonsoft.Json;

namespace CheckDrive.Web.Stores.Doctors
{
public class DoctorDataStore : IDoctorDataStore
{
private readonly ApiClient _api;

public DoctorDataStore(ApiClient apiClient)
{
_api = apiClient;
}

public async Task<GetDoctorResponse> GetDoctors()
{
var response = await _api.GetAsync("doctors");

if (!response.IsSuccessStatusCode)
{
throw new Exception("Could not fetch doctors.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<GetDoctorResponse>(json);

return result;
}

public async Task<DoctorDto> GetDoctor(int id)
{
var response = await _api.GetAsync($"doctors/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not fetch doctor with id: {id}.");
}

var json = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();
var result = JsonConvert.DeserializeObject<DoctorDto>(json);

return result;
}

public async Task<DoctorDto> CreateDoctor(DoctorForCreateDto doctorForCreate)
{
var json = JsonConvert.SerializeObject(doctorForCreate);
var response = await _api.PostAsync("doctors", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error creating doctors.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<DoctorDto>(jsonResponse);
}

public async Task<DoctorDto> UpdateDoctor(int id, AccountForUpdateDto doctorForUpdate)
{
var json = JsonConvert.SerializeObject(doctorForUpdate);
var response = await _api.PutAsync($"doctors/{doctorForUpdate.Id}", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error updating doctors.");
}

var jsonResponse = response.Content.ReadAsStringAsync().GetAwaiter().GetResult();

return JsonConvert.DeserializeObject<DoctorDto>(jsonResponse);
}

public async Task DeleteDoctor(int id)
{
var response = await _api.DeleteAsync($"doctors/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not delete doctor with id: {id}.");
}
}
}
}
15 changes: 15 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Doctors/IDoctorsDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Doctor;
using CheckDrive.Web.Responses;

namespace CheckDrive.Web.Stores.Doctors
{
public interface IDoctorDataStore
{
Task<GetDoctorResponse> GetDoctors();
Task<DoctorDto> GetDoctor(int id);
Task<DoctorDto> CreateDoctor(DoctorForCreateDto doctorForCreate);
Task<DoctorDto> UpdateDoctor(int id, AccountForUpdateDto doctorForUpdate);
Task DeleteDoctor(int id);
}
}
86 changes: 86 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Drivers/DriverDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Driver;
using CheckDrive.Web.Responses;
using CheckDrive.Web.Service;
using Newtonsoft.Json;

namespace CheckDrive.Web.Stores.Drivers
{
public class DriverDataStore : IDriverDataStore
{
private readonly ApiClient _api;

public DriverDataStore(ApiClient apiClient)
{
_api = apiClient;
}

public async Task<GetDriverResponse> GetDriversAsync()
{
var response = await _api.GetAsync("drivers");

if (!response.IsSuccessStatusCode)
{
throw new Exception("Could not fetch drivers.");
}

var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<GetDriverResponse>(json);

return result;
}

public async Task<DriverDto> GetDriverAsync(int id)
{
var response = await _api.GetAsync($"drivers/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not fetch driver with id: {id}.");
}

var json = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<DriverDto>(json);

return result;
}

public async Task<DriverDto> CreateDriverAsync(DriverForCreateDto driverForCreate)
{
var json = JsonConvert.SerializeObject(driverForCreate);
var response = await _api.PostAsync("drivers", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error creating driver.");
}

var jsonResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<DriverDto>(jsonResponse);
}

public async Task<DriverDto> UpdateDriverAsync(int id, AccountForUpdateDto driverForUpdate)
{
var json = JsonConvert.SerializeObject(driverForUpdate);
var response = await _api.PutAsync($"drivers/{driverForUpdate.Id}", json);

if (!response.IsSuccessStatusCode)
{
throw new Exception("Error updating driver.");
}

var jsonResponse = await response.Content.ReadAsStringAsync();
return JsonConvert.DeserializeObject<DriverDto>(jsonResponse);
}

public async Task DeleteDriverAsync(int id)
{
var response = await _api.DeleteAsync($"drivers/{id}");

if (!response.IsSuccessStatusCode)
{
throw new Exception($"Could not delete driver with id: {id}.");
}
}
}
}
15 changes: 15 additions & 0 deletions CheckDrive.Web/CheckDrive.Web/Stores/Drivers/IDriverDataStore.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using CheckDrive.ApiContracts.Account;
using CheckDrive.ApiContracts.Driver;
using CheckDrive.Web.Responses;

namespace CheckDrive.Web.Stores.Drivers
{
public interface IDriverDataStore
{
Task<GetDriverResponse> GetDriversAsync();
Task<DriverDto> GetDriverAsync(int id);
Task<DriverDto> CreateDriverAsync(DriverForCreateDto driverForCreate);
Task<DriverDto> UpdateDriverAsync(int id, AccountForUpdateDto driverForUpdate);
Task DeleteDriverAsync(int id);
}
}
Loading