Skip to content

Commit f0d38b5

Browse files
authored
Merge pull request #24 from DiyorMarket/integration
Integration
2 parents 80e705c + 5f10200 commit f0d38b5

File tree

104 files changed

+7715
-408
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

104 files changed

+7715
-408
lines changed

CheckDrive.Api/CheckDrive.Api/CheckDrive.Api.csproj

+5
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
2525
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
2626
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
27+
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.9.0" />
2728
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="27.1.50" />
2829
</ItemGroup>
2930

@@ -33,4 +34,8 @@
3334
<ProjectReference Include="..\CheckDrive.TestDataCreator\CheckDrive.TestDataCreator.csproj" />
3435
</ItemGroup>
3536

37+
<ItemGroup>
38+
<Folder Include="logs\" />
39+
</ItemGroup>
40+
3641
</Project>

CheckDrive.Api/CheckDrive.Api/Controllers/AccountsController.cs

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using CheckDrive.Application.Constants;
22
using CheckDrive.Application.DTOs.Account;
33
using CheckDrive.Application.Interfaces;
4+
using CheckDrive.Domain.Enums;
45
using Microsoft.AspNetCore.Authorization;
56
using Microsoft.AspNetCore.Mvc;
67

@@ -18,9 +19,9 @@ public AccountsController(IAccountService service)
1819
}
1920

2021
[HttpGet]
21-
public async Task<ActionResult<List<AccountDto>>> GetAsync()
22+
public async Task<ActionResult<List<AccountDto>>> GetAsync(EmployeePosition? position)
2223
{
23-
var accounts = await _service.GetAsync();
24+
var accounts = await _service.GetAsync(position);
2425

2526
return Ok(accounts);
2627
}

CheckDrive.Api/CheckDrive.Api/Controllers/Auth/AuthController.cs CheckDrive.Api/CheckDrive.Api/Controllers/AuthController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
using CheckDrive.Application.Interfaces.Auth;
33
using Microsoft.AspNetCore.Mvc;
44

5-
namespace CheckDrive.Api.Controllers.Auth;
5+
namespace CheckDrive.Api.Controllers;
66

77
[Route("api/auth")]
88
[ApiController]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using CheckDrive.Application.DTOs.Car;
2+
using CheckDrive.Application.Interfaces;
3+
using CheckDrive.Application.QueryParameters;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace CheckDrive.Api.Controllers;
7+
8+
[Route("api/cars")]
9+
[ApiController]
10+
public class CarsController : ControllerBase
11+
{
12+
private readonly ICarService _carService;
13+
14+
public CarsController(ICarService carService)
15+
{
16+
_carService = carService;
17+
}
18+
19+
[HttpGet]
20+
public async Task<ActionResult<List<CarDto>>> GetAllAsync(CarQueryParameters queryParameters)
21+
{
22+
var cars = await _carService.GetAllAsync(queryParameters);
23+
24+
return Ok(cars);
25+
}
26+
27+
[HttpGet("{id:int}", Name = "GetCarByIdAsync")]
28+
public async Task<ActionResult<CarDto>> GetByIdAsync(int id)
29+
{
30+
var car = await _carService.GetByIdAsync(id);
31+
32+
return Ok(car);
33+
}
34+
35+
[HttpPost]
36+
public async Task<ActionResult<CarDto>> CreateAsync(CreateCarDto car)
37+
{
38+
var createdCar = await _carService.CreateAsync(car);
39+
40+
return CreatedAtAction("GetCarByIdAsync", createdCar, new { id = createdCar.Id });
41+
}
42+
43+
[HttpPut("{id:int}")]
44+
public async Task<ActionResult<CarDto>> UpdateAsync(int id, UpdateCarDto car)
45+
{
46+
if (id != car.Id)
47+
{
48+
return BadRequest($"Route parameter id: {id} does not match with body parameter id: {car.Id}.");
49+
}
50+
51+
var updatedCar = await _carService.UpdateAsync(car);
52+
53+
return Ok(updatedCar);
54+
}
55+
56+
[HttpDelete("{id:int}")]
57+
public async Task<ActionResult> DeleteAsync(int id)
58+
{
59+
await _carService.DeleteAsync(id);
60+
61+
return NoContent();
62+
}
63+
}

CheckDrive.Api/CheckDrive.Api/Controllers/CheckPointsController.cs

+16
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,20 @@ public async Task<ActionResult<List<CheckPointDto>>> GetCheckPointsAsync([FromQu
2323

2424
return Ok(checkPoints);
2525
}
26+
27+
[HttpGet("drivers/{driverId:int}/current")]
28+
public async Task<ActionResult<CheckPointDto>> GetCurrentCheckPointByDriverIdAsync(int driverId)
29+
{
30+
var checkPoint = await _service.GetCurrentCheckPointByDriverIdAsync(driverId);
31+
32+
return Ok(checkPoint);
33+
}
34+
35+
[HttpPut("{id:int}/cancel")]
36+
public async Task<ActionResult<CheckPointDto>> CancelCheckPoint(int id)
37+
{
38+
await _service.CancelCheckPointAsync(id);
39+
40+
return NoContent();
41+
}
2642
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using CheckDrive.Application.DTOs.Driver;
2+
using CheckDrive.Application.Interfaces;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace CheckDrive.Api.Controllers;
6+
7+
[Route("api/drivers")]
8+
[ApiController]
9+
public class DriversController : ControllerBase
10+
{
11+
private readonly IDriverService _driverService;
12+
13+
public DriversController(IDriverService driverService)
14+
{
15+
_driverService = driverService ?? throw new ArgumentNullException(nameof(driverService));
16+
}
17+
18+
[HttpGet]
19+
public async Task<ActionResult<List<DriverDto>>> GetAvailableDriversAsync()
20+
{
21+
var drivers = await _driverService.GetAvailableDriversAsync();
22+
23+
return Ok(drivers);
24+
}
25+
26+
[HttpPost("reviews")]
27+
public async Task<IActionResult> CreateReviewConfirmation(DriverReviewConfirmationDto confirmationDto)
28+
{
29+
await _driverService.CreateReviewConfirmation(confirmationDto);
30+
31+
return NoContent();
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
using CheckDrive.Application.DTOs.OilMark;
2+
using CheckDrive.Application.Interfaces;
3+
using CheckDrive.Application.QueryParameters;
4+
using Microsoft.AspNetCore.Mvc;
5+
6+
namespace CheckDrive.Api.Controllers;
7+
8+
[Route("api/oilMarks")]
9+
[ApiController]
10+
public class OilMarksController : ControllerBase
11+
{
12+
private readonly IOilMarkService _oilMarkService;
13+
14+
public OilMarksController(IOilMarkService oilMarkService)
15+
{
16+
_oilMarkService = oilMarkService ?? throw new ArgumentNullException(nameof(oilMarkService));
17+
}
18+
19+
[HttpGet]
20+
public async Task<ActionResult<List<OilMarkDto>>> GetAsync(OilMarkQueryParameters queryParameters)
21+
{
22+
var oilMarks = await _oilMarkService.GetAllAsync(queryParameters);
23+
24+
return Ok(oilMarks);
25+
}
26+
27+
[HttpGet("{id:int}", Name = "GetOilMarkById")]
28+
public async Task<ActionResult<OilMarkDto>> GetByIdAsync(int id)
29+
{
30+
var oilMark = await _oilMarkService.GetByIdAsync(id);
31+
32+
return oilMark;
33+
}
34+
35+
[HttpPost]
36+
public async Task<ActionResult<OilMarkDto>> CreateAsync(CreateOilMarkDto oilMark)
37+
{
38+
var createdOilMark = await _oilMarkService.CreateAsync(oilMark);
39+
40+
return CreatedAtAction("GetOilMarkById", oilMark, new { id = createdOilMark.Id });
41+
}
42+
43+
[HttpPut("{id:int}")]
44+
public async Task<ActionResult<OilMarkDto>> UpdateAsync(int id, UpdateOilMarkDto oilMark)
45+
{
46+
if (id != oilMark.Id)
47+
{
48+
return BadRequest($"Route parameter id: {id} does not match with body parameter id: {oilMark.Id}.");
49+
}
50+
51+
var updatedOilMark = await _oilMarkService.UpdateAsync(oilMark);
52+
53+
return Ok(updatedOilMark);
54+
}
55+
56+
[HttpDelete("{id:int}")]
57+
public async Task<ActionResult> DeleteAsync(int id)
58+
{
59+
await _oilMarkService.DeleteAsync(id);
60+
61+
return NoContent();
62+
}
63+
}

CheckDrive.Api/CheckDrive.Api/Controllers/Reviews/DispatcherReviewsController.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
namespace CheckDrive.Api.Controllers.Reviews;
66

7-
[Route("api/reviews/dispatcher/{dispatcherId:int}")]
7+
[Route("api/reviews/dispatchers/{dispatcherId:int}")]
88
[ApiController]
99
public class DispatcherReviewsController : ControllerBase
1010
{
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using CheckDrive.Application.DTOs.CheckPoint;
3+
using CheckDrive.Application.DTOs.DoctorReview;
4+
using CheckDrive.Application.DTOs.OperatorReview;
5+
using CheckDrive.Application.DTOs.Review;
6+
using CheckDrive.Application.Interfaces.Review;
7+
8+
namespace CheckDrive.Api.Controllers.Reviews;
9+
10+
[Route("api/reviews/histories")]
11+
[ApiController]
12+
public class ReviewHistoriesController : ControllerBase
13+
{
14+
private readonly IReviewHistoryService _historyService;
15+
16+
public ReviewHistoriesController(IReviewHistoryService historyService)
17+
{
18+
_historyService = historyService ?? throw new ArgumentNullException(nameof(historyService));
19+
}
20+
21+
[HttpGet("drivers/{driverId:int}")]
22+
public async Task<ActionResult<List<CheckPointDto>>> GetDriverHistoriesAsync(int driverId)
23+
{
24+
var reviews = await _historyService.GetDriverHistoriesAsync(driverId);
25+
26+
return Ok(reviews);
27+
}
28+
29+
[HttpGet("doctors/{doctorId:int}")]
30+
public async Task<ActionResult<List<DoctorReviewDto>>> GetDoctorHistoriesAsync(int doctorId)
31+
{
32+
var reviews = await _historyService.GetDoctorHistoriesAsync(doctorId);
33+
34+
return Ok(reviews);
35+
}
36+
37+
[HttpGet("mechanics/{mechanicId:int}")]
38+
public async Task<ActionResult<List<MechanicReviewHistoryDto>>> GetMechanicHistoriesAsync(int mechanicId)
39+
{
40+
var reviews = await _historyService.GetMechanicHistoriesAsync(mechanicId);
41+
42+
return Ok(reviews);
43+
}
44+
45+
[HttpGet("operators/{operatorId:int}")]
46+
public async Task<ActionResult<List<OperatorReviewDto>>> GetOperatorHistoriesAsync(int operatorId)
47+
{
48+
var reviews = await _historyService.GetOperatorHistoriesAsync(operatorId);
49+
50+
return Ok(reviews);
51+
}
52+
}

CheckDrive.Api/CheckDrive.Api/Extensions/DependencyInjection.cs

+12-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
using Newtonsoft.Json.Converters;
1010
using Newtonsoft.Json.Serialization;
1111
using System.Text;
12-
using CheckDrive.Api.Filters;
1312

1413
namespace CheckDrive.Api.Extensions;
1514

@@ -21,6 +20,10 @@ public static IServiceCollection ConfigureServices(this IServiceCollection servi
2120
services.RegisterInfrastructure(configuration);
2221

2322
services.AddSingleton<FileExtensionContentTypeProvider>();
23+
services.AddSignalR(options =>
24+
{
25+
options.EnableDetailedErrors = true;
26+
});
2427

2528
AddControllers(services);
2629
AddSwagger(services);
@@ -56,15 +59,19 @@ private static void AddSwagger(IServiceCollection services)
5659
.AddSwaggerGen(setup =>
5760
{
5861
setup.SwaggerDoc("v1", new OpenApiInfo { Title = "Check-Drive API", Version = "v1" });
59-
60-
setup.SchemaFilter<EnumSchemaFilter>();
61-
});
62+
})
63+
.AddSwaggerGenNewtonsoftSupport();
6264
}
6365

6466
private static void AddAuthentication(IServiceCollection services, IConfiguration configuration)
6567
{
6668
var jwtOptions = configuration.GetSection(nameof(JwtOptions)).Get<JwtOptions>();
6769

70+
if (jwtOptions is null)
71+
{
72+
throw new InvalidOperationException("Could not load JWT configurations.");
73+
}
74+
6875
services
6976
.AddAuthentication(options =>
7077
{
@@ -84,7 +91,7 @@ private static void AddAuthentication(IServiceCollection services, IConfiguratio
8491
ValidateLifetime = true,
8592
ValidateIssuerSigningKey = true,
8693
IssuerSigningKey = new SymmetricSecurityKey(
87-
Encoding.UTF8.GetBytes(jwtOptions!.SecretKey))
94+
Encoding.UTF8.GetBytes(jwtOptions.SecretKey))
8895
};
8996

9097
options.Events = new JwtBearerEvents

CheckDrive.Api/CheckDrive.Api/Extensions/StartupExtensions.cs

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
using CheckDrive.Api.Helpers;
22
using CheckDrive.Api.Middlewares;
3-
using CheckDrive.Application.Constants;
43
using CheckDrive.Domain.Interfaces;
54
using CheckDrive.TestDataCreator.Configurations;
65
using Microsoft.AspNetCore.Identity;
@@ -28,4 +27,7 @@ public static IApplicationBuilder UseDatabaseSeeder(this WebApplication app)
2827

2928
return app;
3029
}
30+
31+
public static bool IsTesting(this IHostEnvironment environment)
32+
=> environment.IsEnvironment("Testing");
3133
}

CheckDrive.Api/CheckDrive.Api/Filters/EnumSchemaFilter.cs

-23
This file was deleted.

0 commit comments

Comments
 (0)