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

Integration #24

Merged
merged 46 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
102b622
Created Manager and ManagerReview
FirdavsAX Oct 5, 2024
51699a7
Merge remote-tracking branch 'origin/integration' into 11-create-mana…
FirdavsAX Oct 6, 2024
bf43868
Added Manager And ManagerReview
FirdavsAX Oct 6, 2024
e306d39
fixed
FirdavsAX Oct 6, 2024
2aa99f5
changed configuration to sealed
FirdavsAX Oct 6, 2024
251afb1
added assign to role logics to create user account service
FirdavsAX Oct 7, 2024
6ccb86e
Added
FirdavsAX Oct 7, 2024
6c41434
Merge pull request #17 from DiyorMarket/Add-Assign-Role
Mirazyzz Oct 17, 2024
128d811
Merge pull request #16 from DiyorMarket/11-create-manager-and-manager…
Mirazyzz Oct 17, 2024
943b75c
Merge pull request #23 from DiyorMarket/master
Mirazyzz Oct 22, 2024
5770677
add employee filtering by position & enum support for swagger
Mirazyzz Oct 23, 2024
bfcdf92
add endpoint to fetch drivers by status
Mirazyzz Oct 25, 2024
09a37d1
update JWt token generation to use user Id
Mirazyzz Oct 25, 2024
e259616
integrate SignalR with Doctor Review
Mirazyzz Oct 25, 2024
6ba1d4f
add car endpoints
Mirazyzz Oct 26, 2024
4d584ae
Update Review Type names
Mirazyzz Oct 26, 2024
d410564
add endpoint to fetch current check point for driver
Mirazyzz Oct 26, 2024
c4d1212
add confirmation method for SignalR
Mirazyzz Oct 26, 2024
c4e9f3a
publish SignalR message on reviews
Mirazyzz Oct 26, 2024
d6cedb9
update contracts
Mirazyzz Oct 26, 2024
bed6f4e
set default values for query parameters
Mirazyzz Oct 26, 2024
46f83e7
add endpoint to fetch reviews for driver
Mirazyzz Oct 26, 2024
5e6a6fd
add default oil marks to db
Mirazyzz Oct 28, 2024
6318050
add GET endpoint for oil marks
Mirazyzz Oct 28, 2024
793e705
add monthly limit property to Car
Mirazyzz Oct 30, 2024
a7a9d52
add background service for resetting monthly limit
Mirazyzz Oct 30, 2024
c436e07
separate each review method for SignalR
Mirazyzz Oct 30, 2024
2c836bf
improve code quality and consistency
Mirazyzz Oct 30, 2024
6fb8c7a
remove debug info
Mirazyzz Oct 30, 2024
cd4970c
code review fixes
Mirazyzz Oct 31, 2024
46e64d7
Merge pull request #25 from DiyorMarket/signalR-integration
Mirazyzz Oct 31, 2024
6cee3b9
implement review history service
Mirazyzz Nov 1, 2024
e9313ca
rename mileage property in dispatcher review
Mirazyzz Nov 1, 2024
fdd36de
include logs folder
Mirazyzz Nov 10, 2024
d990cf4
implement CRUD operations for Cars
Mirazyzz Nov 10, 2024
50f864e
implement CRUD operations for Oil Marks
Mirazyzz Nov 10, 2024
cd8fa49
minor code quality improvements
Mirazyzz Nov 10, 2024
18a9a88
register validators & mappings
Mirazyzz Nov 10, 2024
605a1aa
Update DispatcherReviewService.cs
Mirazyzz Nov 10, 2024
a0db18c
eagerly load doctors & driver in history service
Mirazyzz Nov 10, 2024
2f03c11
allow cancelling check point
Mirazyzz Nov 10, 2024
9a50d0d
remove dead code, fix invalid logics & update mappings
Mirazyzz Nov 10, 2024
445de1e
update car limits & indicators
Mirazyzz Nov 10, 2024
a222959
fix auth controller namespace
Mirazyzz Nov 10, 2024
97451da
seed database only during testing
Mirazyzz Nov 11, 2024
5f10200
Merge pull request #26 from DiyorMarket/history-endpoints
Mirazyzz Nov 11, 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
5 changes: 5 additions & 0 deletions CheckDrive.Api/CheckDrive.Api/CheckDrive.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
<PackageReference Include="Serilog.Sinks.File" Version="6.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.0" />
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="6.9.0" />
<PackageReference Include="Syncfusion.XlsIO.Net.Core" Version="27.1.50" />
</ItemGroup>

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

<ItemGroup>
<Folder Include="logs\" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using CheckDrive.Application.Constants;
using CheckDrive.Application.DTOs.Account;
using CheckDrive.Application.Interfaces;
using CheckDrive.Domain.Enums;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;

Expand All @@ -18,9 +19,9 @@ public AccountsController(IAccountService service)
}

[HttpGet]
public async Task<ActionResult<List<AccountDto>>> GetAsync()
public async Task<ActionResult<List<AccountDto>>> GetAsync(EmployeePosition? position)
{
var accounts = await _service.GetAsync();
var accounts = await _service.GetAsync(position);

return Ok(accounts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using CheckDrive.Application.Interfaces.Auth;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Api.Controllers.Auth;
namespace CheckDrive.Api.Controllers;

[Route("api/auth")]
[ApiController]
Expand Down
63 changes: 63 additions & 0 deletions CheckDrive.Api/CheckDrive.Api/Controllers/CarsController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using CheckDrive.Application.DTOs.Car;
using CheckDrive.Application.Interfaces;
using CheckDrive.Application.QueryParameters;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Api.Controllers;

[Route("api/cars")]
[ApiController]
public class CarsController : ControllerBase
{
private readonly ICarService _carService;

public CarsController(ICarService carService)
{
_carService = carService;
}

[HttpGet]
public async Task<ActionResult<List<CarDto>>> GetAllAsync(CarQueryParameters queryParameters)
{
var cars = await _carService.GetAllAsync(queryParameters);

return Ok(cars);
}

[HttpGet("{id:int}", Name = "GetCarByIdAsync")]
public async Task<ActionResult<CarDto>> GetByIdAsync(int id)
{
var car = await _carService.GetByIdAsync(id);

return Ok(car);
}

[HttpPost]
public async Task<ActionResult<CarDto>> CreateAsync(CreateCarDto car)
{
var createdCar = await _carService.CreateAsync(car);

return CreatedAtAction("GetCarByIdAsync", createdCar, new { id = createdCar.Id });
}

[HttpPut("{id:int}")]
public async Task<ActionResult<CarDto>> UpdateAsync(int id, UpdateCarDto car)
{
if (id != car.Id)
{
return BadRequest($"Route parameter id: {id} does not match with body parameter id: {car.Id}.");
}

var updatedCar = await _carService.UpdateAsync(car);

return Ok(updatedCar);
}

[HttpDelete("{id:int}")]
public async Task<ActionResult> DeleteAsync(int id)
{
await _carService.DeleteAsync(id);

return NoContent();
}
}
16 changes: 16 additions & 0 deletions CheckDrive.Api/CheckDrive.Api/Controllers/CheckPointsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,20 @@ public async Task<ActionResult<List<CheckPointDto>>> GetCheckPointsAsync([FromQu

return Ok(checkPoints);
}

[HttpGet("drivers/{driverId:int}/current")]
public async Task<ActionResult<CheckPointDto>> GetCurrentCheckPointByDriverIdAsync(int driverId)
{
var checkPoint = await _service.GetCurrentCheckPointByDriverIdAsync(driverId);

return Ok(checkPoint);
}

[HttpPut("{id:int}/cancel")]
public async Task<ActionResult<CheckPointDto>> CancelCheckPoint(int id)
{
await _service.CancelCheckPointAsync(id);

return NoContent();
}
}
33 changes: 33 additions & 0 deletions CheckDrive.Api/CheckDrive.Api/Controllers/DriversController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
using CheckDrive.Application.DTOs.Driver;
using CheckDrive.Application.Interfaces;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Api.Controllers;

[Route("api/drivers")]
[ApiController]
public class DriversController : ControllerBase
{
private readonly IDriverService _driverService;

public DriversController(IDriverService driverService)
{
_driverService = driverService ?? throw new ArgumentNullException(nameof(driverService));
}

[HttpGet]
public async Task<ActionResult<List<DriverDto>>> GetAvailableDriversAsync()
{
var drivers = await _driverService.GetAvailableDriversAsync();

return Ok(drivers);
}

[HttpPost("reviews")]
public async Task<IActionResult> CreateReviewConfirmation(DriverReviewConfirmationDto confirmationDto)
{
await _driverService.CreateReviewConfirmation(confirmationDto);

return NoContent();
}
}
63 changes: 63 additions & 0 deletions CheckDrive.Api/CheckDrive.Api/Controllers/OilMarksController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using CheckDrive.Application.DTOs.OilMark;
using CheckDrive.Application.Interfaces;
using CheckDrive.Application.QueryParameters;
using Microsoft.AspNetCore.Mvc;

namespace CheckDrive.Api.Controllers;

[Route("api/oilMarks")]
[ApiController]
public class OilMarksController : ControllerBase
{
private readonly IOilMarkService _oilMarkService;

public OilMarksController(IOilMarkService oilMarkService)
{
_oilMarkService = oilMarkService ?? throw new ArgumentNullException(nameof(oilMarkService));
}

[HttpGet]
public async Task<ActionResult<List<OilMarkDto>>> GetAsync(OilMarkQueryParameters queryParameters)
{
var oilMarks = await _oilMarkService.GetAllAsync(queryParameters);

return Ok(oilMarks);
}

[HttpGet("{id:int}", Name = "GetOilMarkById")]
public async Task<ActionResult<OilMarkDto>> GetByIdAsync(int id)
{
var oilMark = await _oilMarkService.GetByIdAsync(id);

return oilMark;
}

[HttpPost]
public async Task<ActionResult<OilMarkDto>> CreateAsync(CreateOilMarkDto oilMark)
{
var createdOilMark = await _oilMarkService.CreateAsync(oilMark);

return CreatedAtAction("GetOilMarkById", oilMark, new { id = createdOilMark.Id });
}

[HttpPut("{id:int}")]
public async Task<ActionResult<OilMarkDto>> UpdateAsync(int id, UpdateOilMarkDto oilMark)
{
if (id != oilMark.Id)
{
return BadRequest($"Route parameter id: {id} does not match with body parameter id: {oilMark.Id}.");
}

var updatedOilMark = await _oilMarkService.UpdateAsync(oilMark);

return Ok(updatedOilMark);
}

[HttpDelete("{id:int}")]
public async Task<ActionResult> DeleteAsync(int id)
{
await _oilMarkService.DeleteAsync(id);

return NoContent();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace CheckDrive.Api.Controllers.Reviews;

[Route("api/reviews/dispatcher/{dispatcherId:int}")]
[Route("api/reviews/dispatchers/{dispatcherId:int}")]
[ApiController]
public class DispatcherReviewsController : ControllerBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
using Microsoft.AspNetCore.Mvc;
using CheckDrive.Application.DTOs.CheckPoint;
using CheckDrive.Application.DTOs.DoctorReview;
using CheckDrive.Application.DTOs.OperatorReview;
using CheckDrive.Application.DTOs.Review;
using CheckDrive.Application.Interfaces.Review;

namespace CheckDrive.Api.Controllers.Reviews;

[Route("api/reviews/histories")]
[ApiController]
public class ReviewHistoriesController : ControllerBase
{
private readonly IReviewHistoryService _historyService;

public ReviewHistoriesController(IReviewHistoryService historyService)
{
_historyService = historyService ?? throw new ArgumentNullException(nameof(historyService));
}

[HttpGet("drivers/{driverId:int}")]
public async Task<ActionResult<List<CheckPointDto>>> GetDriverHistoriesAsync(int driverId)
{
var reviews = await _historyService.GetDriverHistoriesAsync(driverId);

return Ok(reviews);
}

[HttpGet("doctors/{doctorId:int}")]
public async Task<ActionResult<List<DoctorReviewDto>>> GetDoctorHistoriesAsync(int doctorId)
{
var reviews = await _historyService.GetDoctorHistoriesAsync(doctorId);

return Ok(reviews);
}

[HttpGet("mechanics/{mechanicId:int}")]
public async Task<ActionResult<List<MechanicReviewHistoryDto>>> GetMechanicHistoriesAsync(int mechanicId)
{
var reviews = await _historyService.GetMechanicHistoriesAsync(mechanicId);

return Ok(reviews);
}

[HttpGet("operators/{operatorId:int}")]
public async Task<ActionResult<List<OperatorReviewDto>>> GetOperatorHistoriesAsync(int operatorId)
{
var reviews = await _historyService.GetOperatorHistoriesAsync(operatorId);

return Ok(reviews);
}
}
17 changes: 12 additions & 5 deletions CheckDrive.Api/CheckDrive.Api/Extensions/DependencyInjection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
using Newtonsoft.Json.Converters;
using Newtonsoft.Json.Serialization;
using System.Text;
using CheckDrive.Api.Filters;

namespace CheckDrive.Api.Extensions;

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

services.AddSingleton<FileExtensionContentTypeProvider>();
services.AddSignalR(options =>
{
options.EnableDetailedErrors = true;
});

AddControllers(services);
AddSwagger(services);
Expand Down Expand Up @@ -56,15 +59,19 @@ private static void AddSwagger(IServiceCollection services)
.AddSwaggerGen(setup =>
{
setup.SwaggerDoc("v1", new OpenApiInfo { Title = "Check-Drive API", Version = "v1" });

setup.SchemaFilter<EnumSchemaFilter>();
});
})
.AddSwaggerGenNewtonsoftSupport();
}

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

if (jwtOptions is null)
{
throw new InvalidOperationException("Could not load JWT configurations.");
}

services
.AddAuthentication(options =>
{
Expand All @@ -84,7 +91,7 @@ private static void AddAuthentication(IServiceCollection services, IConfiguratio
ValidateLifetime = true,
ValidateIssuerSigningKey = true,
IssuerSigningKey = new SymmetricSecurityKey(
Encoding.UTF8.GetBytes(jwtOptions!.SecretKey))
Encoding.UTF8.GetBytes(jwtOptions.SecretKey))
};

options.Events = new JwtBearerEvents
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using CheckDrive.Api.Helpers;
using CheckDrive.Api.Middlewares;
using CheckDrive.Application.Constants;
using CheckDrive.Domain.Interfaces;
using CheckDrive.TestDataCreator.Configurations;
using Microsoft.AspNetCore.Identity;
Expand Down Expand Up @@ -28,4 +27,7 @@ public static IApplicationBuilder UseDatabaseSeeder(this WebApplication app)

return app;
}

public static bool IsTesting(this IHostEnvironment environment)
=> environment.IsEnvironment("Testing");
}
23 changes: 0 additions & 23 deletions CheckDrive.Api/CheckDrive.Api/Filters/EnumSchemaFilter.cs

This file was deleted.

Loading
Loading