diff --git a/OneBus.API/Controllers/DashboardController.cs b/OneBus.API/Controllers/DashboardController.cs
new file mode 100644
index 0000000..ef321df
--- /dev/null
+++ b/OneBus.API/Controllers/DashboardController.cs
@@ -0,0 +1,57 @@
+using Microsoft.AspNetCore.Authorization;
+using Microsoft.AspNetCore.Mvc;
+using OneBus.API.Extensions;
+using OneBus.Application.DTOs.Dashboard;
+using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons.Result;
+using Swashbuckle.AspNetCore.Annotations;
+
+namespace OneBus.API.Controllers
+{
+ [Route("api/v1/dashboards")]
+ [ApiController]
+ [Produces("application/json")]
+ [Authorize]
+ [SwaggerTag("Controlador responsável por listar Dashboards")]
+ public class DashboardController : ControllerBase
+ {
+ private readonly IDashboardService _dashboardService;
+
+ public DashboardController(IDashboardService dashboardService)
+ {
+ _dashboardService = dashboardService;
+ }
+
+ ///
+ /// Obter status dos funcionários
+ ///
+ ///
+ /// GET de status dos funcionários
+ ///
+ ///
+ /// Status dos funcionários categorizados
+ /// Status dos funcionários categorizados com sucesso
+ [HttpGet("employees")]
+ [ProducesResponseType(typeof(SuccessResult), StatusCodes.Status200OK)]
+ public async Task GetEmployeeStatusAsync(CancellationToken cancellationToken = default)
+ {
+ return (await _dashboardService.GetEmployeeStatusAsync(cancellationToken)).ToActionResult();
+ }
+
+ ///
+ /// Obter status dos veículos
+ ///
+ ///
+ /// GET de status dos veículos
+ ///
+ ///
+ /// Status dos veículos categorizados
+ /// Status dos veículos categorizados com sucesso
+ [HttpGet("vehicles")]
+ [ProducesResponseType(typeof(SuccessResult), StatusCodes.Status200OK)]
+ public async Task GetVehicleStatusAsync(CancellationToken cancellationToken = default)
+ {
+ return (await _dashboardService.GetVehicleStatusAsync(cancellationToken)).ToActionResult();
+ }
+ }
+}
diff --git a/OneBus.API/Controllers/EmployeeController.cs b/OneBus.API/Controllers/EmployeeController.cs
index af4d0b2..52b16a3 100644
--- a/OneBus.API/Controllers/EmployeeController.cs
+++ b/OneBus.API/Controllers/EmployeeController.cs
@@ -134,7 +134,7 @@ public async Task GetByIdAsync([FromRoute] long id, CancellationT
/// Status disponíveis
/// Status retornados com sucesso
[HttpGet("status")]
- [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
public IActionResult GetStatus()
{
return _employeeService.GetStatus().ToActionResult();
diff --git a/OneBus.API/Controllers/LineController.cs b/OneBus.API/Controllers/LineController.cs
index 029d3ea..10ae33a 100644
--- a/OneBus.API/Controllers/LineController.cs
+++ b/OneBus.API/Controllers/LineController.cs
@@ -10,7 +10,6 @@
namespace OneBus.API.Controllers
{
- [NonController]
[Route("api/v1/lines")]
[ApiController]
[Produces("application/json")]
@@ -102,7 +101,7 @@ public async Task DeleteAsync([FromRoute] long id, CancellationTo
/// Linhas paginadas e filtradas com sucesso
[HttpGet]
[ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
- public async Task GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
+ public async Task GetPaginedAsync([FromQuery] LineFilter filter, CancellationToken cancellationToken = default)
{
return (await _lineService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}
@@ -125,5 +124,35 @@ public async Task GetByIdAsync([FromRoute] long id, CancellationT
{
return (await _lineService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
+
+ ///
+ /// Listar tipos de linhas
+ ///
+ ///
+ /// GET de tipos de linhas
+ ///
+ /// Tipos de linhas disponíveis
+ /// Tipos de linhas retornadas com sucesso
+ [HttpGet("types")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetVehicleTypes()
+ {
+ return _lineService.GetLineTypes().ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de direção
+ ///
+ ///
+ /// GET de tipos de direção
+ ///
+ /// Tipos de direção disponíveis
+ /// Tipos de direção retornadas com sucesso
+ [HttpGet("directionTypes")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetDirectionTypes()
+ {
+ return _lineService.GetDirectionTypes().ToActionResult();
+ }
}
}
diff --git a/OneBus.API/Controllers/LineTimeController.cs b/OneBus.API/Controllers/LineTimeController.cs
index 40e174c..6554215 100644
--- a/OneBus.API/Controllers/LineTimeController.cs
+++ b/OneBus.API/Controllers/LineTimeController.cs
@@ -10,7 +10,6 @@
namespace OneBus.API.Controllers
{
- [NonController]
[Route("api/v1/linesTimes")]
[ApiController]
[Produces("application/json")]
@@ -102,9 +101,11 @@ public async Task DeleteAsync([FromRoute] long id, CancellationTo
/// Horários de Linha paginados e filtrados com sucesso
[HttpGet]
[ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
- public async Task GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
+ public async Task GetPaginedAsync([FromQuery] LineTimeFilter filter, CancellationToken cancellationToken = default)
{
- return (await _lineTimeService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _lineTimeService.GetPaginedAsync(filter,
+ DbQueryOptions.Create(["Line"]),
+ cancellationToken)).ToActionResult();
}
///
@@ -123,7 +124,9 @@ public async Task GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
public async Task GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
- return (await _lineTimeService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _lineTimeService.GetByIdAsync(id,
+ DbQueryOptions.Create(["Line"]),
+ cancellationToken)).ToActionResult();
}
}
}
diff --git a/OneBus.API/Controllers/MaintenanceController.cs b/OneBus.API/Controllers/MaintenanceController.cs
index f7dcb88..122c3db 100644
--- a/OneBus.API/Controllers/MaintenanceController.cs
+++ b/OneBus.API/Controllers/MaintenanceController.cs
@@ -10,7 +10,6 @@
namespace OneBus.API.Controllers
{
- [NonController]
[Route("api/v1/maintenances")]
[ApiController]
[Produces("application/json")]
@@ -102,9 +101,11 @@ public async Task DeleteAsync([FromRoute] long id, CancellationTo
/// Manutenções paginadas e filtradas com sucesso
[HttpGet]
[ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
- public async Task GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
+ public async Task GetPaginedAsync([FromQuery] MaintenanceFilter filter, CancellationToken cancellationToken = default)
{
- return (await _maintenanceService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _maintenanceService.GetPaginedAsync(filter,
+ DbQueryOptions.Create(["Vehicle"]),
+ cancellationToken)).ToActionResult();
}
///
@@ -123,7 +124,24 @@ public async Task GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
public async Task GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
- return (await _maintenanceService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _maintenanceService.GetByIdAsync(id,
+ DbQueryOptions.Create(["Vehicle"]),
+ cancellationToken)).ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de setores
+ ///
+ ///
+ /// GET de tipos de setores
+ ///
+ /// Tipos de Setores disponíveis
+ /// Setores retornados com sucesso
+ [HttpGet("sectors")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetSectors()
+ {
+ return _maintenanceService.GetSectors().ToActionResult();
}
}
}
diff --git a/OneBus.API/Controllers/UserController.cs b/OneBus.API/Controllers/UserController.cs
index 7ca6bae..1ecfd24 100644
--- a/OneBus.API/Controllers/UserController.cs
+++ b/OneBus.API/Controllers/UserController.cs
@@ -31,8 +31,8 @@ public UserController(IUserService userService)
///
/// POST /logins
/// {
- /// "email": "helloworld@gmail.com",
- /// "password": "dasdfsf35346353tsd"
+ /// "email": "onebus@admin",
+ /// "password": "onebus@2025"
/// }
///
///
diff --git a/OneBus.API/Controllers/VehicleController.cs b/OneBus.API/Controllers/VehicleController.cs
index 7185c78..61c7c3a 100644
--- a/OneBus.API/Controllers/VehicleController.cs
+++ b/OneBus.API/Controllers/VehicleController.cs
@@ -10,7 +10,6 @@
namespace OneBus.API.Controllers
{
- [NonController]
[Route("api/v1/vehicles")]
[ApiController]
[Produces("application/json")]
@@ -102,7 +101,7 @@ public async Task DeleteAsync([FromRoute] long id, CancellationTo
/// Veículos paginados e filtrados com sucesso
[HttpGet]
[ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
- public async Task GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
+ public async Task GetPaginedAsync([FromQuery] VehicleFilter filter, CancellationToken cancellationToken = default)
{
return (await _vehicleService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
}
@@ -125,5 +124,125 @@ public async Task GetByIdAsync([FromRoute] long id, CancellationT
{
return (await _vehicleService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
}
+
+ ///
+ /// Listar status
+ ///
+ ///
+ /// GET de status
+ ///
+ /// Status disponíveis
+ /// Status retornados com sucesso
+ [HttpGet("status")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetStatus()
+ {
+ return _vehicleService.GetStatus().ToActionResult();
+ }
+
+ ///
+ /// Listar marcas
+ ///
+ ///
+ /// GET de marcas
+ ///
+ /// Marcas disponíveis
+ /// Marcas retornadas com sucesso
+ [HttpGet("brands")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetBrands()
+ {
+ return _vehicleService.GetBrands().ToActionResult();
+ }
+
+ ///
+ /// Listar marcas de chassis
+ ///
+ ///
+ /// GET de marcas de chassis
+ ///
+ /// Marcas de chassis disponíveis
+ /// Marcas de chassis retornadas com sucesso
+ [HttpGet("chassisBrands")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetBusChassisBrands()
+ {
+ return _vehicleService.GetBusChassisBrands().ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de serviço
+ ///
+ ///
+ /// GET de tipos de serviço
+ ///
+ /// Tipos de serviço disponíveis
+ /// Tipos de serviço retornados com sucesso
+ [HttpGet("serviceTypes")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetBusServiceTypes()
+ {
+ return _vehicleService.GetBusServiceTypes().ToActionResult();
+ }
+
+ ///
+ /// Listar cores
+ ///
+ ///
+ /// GET de cores
+ ///
+ /// Cores disponíveis
+ /// Cores retornadas com sucesso
+ [HttpGet("colors")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetColors()
+ {
+ return _vehicleService.GetColors().ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de combustíveis
+ ///
+ ///
+ /// GET de tipos de combustíveis
+ ///
+ /// Tipos de combustíveis disponíveis
+ /// Tipos de combustíveis retornados com sucesso
+ [HttpGet("fuelTypes")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetFuelTypes()
+ {
+ return _vehicleService.GetFuelTypes().ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de transmissão
+ ///
+ ///
+ /// GET de tipos de transmissão
+ ///
+ /// Tipos de transmissão disponíveis
+ /// Tipos de transmissão retornados com sucesso
+ [HttpGet("transmissionTypes")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetTransmissionTypes()
+ {
+ return _vehicleService.GetTransmissionTypes().ToActionResult();
+ }
+
+ ///
+ /// Listar tipos de veículo
+ ///
+ ///
+ /// GET de tipos de veículo
+ ///
+ /// Tipos de veículo disponíveis
+ /// Tipos de veículo retornados com sucesso
+ [HttpGet("types")]
+ [ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
+ public IActionResult GetVehicleTypes()
+ {
+ return _vehicleService.GetVehicleTypes().ToActionResult();
+ }
}
}
diff --git a/OneBus.API/Controllers/VehicleOperationController.cs b/OneBus.API/Controllers/VehicleOperationController.cs
index aa611cb..b3d36be 100644
--- a/OneBus.API/Controllers/VehicleOperationController.cs
+++ b/OneBus.API/Controllers/VehicleOperationController.cs
@@ -10,7 +10,6 @@
namespace OneBus.API.Controllers
{
- [NonController]
[Route("api/v1/vehiclesOperations")]
[ApiController]
[Produces("application/json")]
@@ -102,9 +101,11 @@ public async Task DeleteAsync([FromRoute] long id, CancellationTo
/// Operações de Veículos paginadas e filtradas com sucesso
[HttpGet]
[ProducesResponseType(typeof(SuccessResult>), StatusCodes.Status200OK)]
- public async Task GetPaginedAsync([FromQuery] BaseFilter filter, CancellationToken cancellationToken = default)
+ public async Task GetPaginedAsync([FromQuery] VehicleOperationFilter filter, CancellationToken cancellationToken = default)
{
- return (await _vehicleOperationService.GetPaginedAsync(filter, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _vehicleOperationService.GetPaginedAsync(filter,
+ DbQueryOptions.Create(["LineTime.Line", "EmployeeWorkday.Employee", "Vehicle"]),
+ cancellationToken)).ToActionResult();
}
///
@@ -123,7 +124,9 @@ public async Task GetPaginedAsync([FromQuery] BaseFilter filter,
[ProducesResponseType(typeof(NotFoundResult), StatusCodes.Status404NotFound)]
public async Task GetByIdAsync([FromRoute] long id, CancellationToken cancellationToken = default)
{
- return (await _vehicleOperationService.GetByIdAsync(id, cancellationToken: cancellationToken)).ToActionResult();
+ return (await _vehicleOperationService.GetByIdAsync(id,
+ DbQueryOptions.Create(["LineTime.Line", "EmployeeWorkday.Employee", "Vehicle"]),
+ cancellationToken)).ToActionResult();
}
}
}
diff --git a/OneBus.API/OneBus.API.csproj b/OneBus.API/OneBus.API.csproj
index 56da312..f7ffcd0 100644
--- a/OneBus.API/OneBus.API.csproj
+++ b/OneBus.API/OneBus.API.csproj
@@ -11,17 +11,17 @@
-
-
-
+
+
+
all
runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
+
+
+
+
diff --git a/OneBus.Application/DTOs/Bus/CreateBusDTO.cs b/OneBus.Application/DTOs/Bus/CreateBusDTO.cs
deleted file mode 100644
index 9f4ffb3..0000000
--- a/OneBus.Application/DTOs/Bus/CreateBusDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.Bus
-{
- public class CreateBusDTO : BaseCreateDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/Bus/ReadBusDTO.cs b/OneBus.Application/DTOs/Bus/ReadBusDTO.cs
deleted file mode 100644
index af8018a..0000000
--- a/OneBus.Application/DTOs/Bus/ReadBusDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.Bus
-{
- public class ReadBusDTO : BaseReadDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/Bus/UpdateBusDTO.cs b/OneBus.Application/DTOs/Bus/UpdateBusDTO.cs
deleted file mode 100644
index 23595d0..0000000
--- a/OneBus.Application/DTOs/Bus/UpdateBusDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.Bus
-{
- public class UpdateBusDTO : BaseUpdateDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/BusOperation/CreateBusOperationDTO.cs b/OneBus.Application/DTOs/BusOperation/CreateBusOperationDTO.cs
deleted file mode 100644
index c6fedf5..0000000
--- a/OneBus.Application/DTOs/BusOperation/CreateBusOperationDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.BusOperation
-{
- public class CreateBusOperationDTO : BaseCreateDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/BusOperation/ReadBusOperationDTO.cs b/OneBus.Application/DTOs/BusOperation/ReadBusOperationDTO.cs
deleted file mode 100644
index f0c04fa..0000000
--- a/OneBus.Application/DTOs/BusOperation/ReadBusOperationDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.BusOperation
-{
- public class ReadBusOperationDTO : BaseReadDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/BusOperation/UpdateBusOperationDTO.cs b/OneBus.Application/DTOs/BusOperation/UpdateBusOperationDTO.cs
deleted file mode 100644
index 143c07d..0000000
--- a/OneBus.Application/DTOs/BusOperation/UpdateBusOperationDTO.cs
+++ /dev/null
@@ -1,6 +0,0 @@
-namespace OneBus.Application.DTOs.BusOperation
-{
- public class UpdateBusOperationDTO : BaseUpdateDTO
- {
- }
-}
diff --git a/OneBus.Application/DTOs/Dashboard/ReadEmployeeCountDTO.cs b/OneBus.Application/DTOs/Dashboard/ReadEmployeeCountDTO.cs
new file mode 100644
index 0000000..388ff44
--- /dev/null
+++ b/OneBus.Application/DTOs/Dashboard/ReadEmployeeCountDTO.cs
@@ -0,0 +1,21 @@
+using OneBus.Application.DTOs.Employee;
+
+namespace OneBus.Application.DTOs.Dashboard
+{
+ public class ReadEmployeeCountDTO
+ {
+ public ReadEmployeeCountDTO()
+ {
+ StatusName = string.Empty;
+ Employees = [];
+ }
+
+ public long Count { get { return Employees.LongCount(); } }
+
+ public byte Status { get; set; }
+
+ public string StatusName { get; set; }
+
+ public IEnumerable Employees { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Dashboard/ReadEmployeeTotalCountDTO.cs b/OneBus.Application/DTOs/Dashboard/ReadEmployeeTotalCountDTO.cs
new file mode 100644
index 0000000..a1a67dd
--- /dev/null
+++ b/OneBus.Application/DTOs/Dashboard/ReadEmployeeTotalCountDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Dashboard
+{
+ public class ReadEmployeeTotalCountDTO
+ {
+ public ReadEmployeeTotalCountDTO(IEnumerable employeeCounts)
+ {
+ EmployeeCounts = employeeCounts;
+ }
+
+ public long TotalCount { get { return EmployeeCounts.SelectMany(c => c.Employees).LongCount(); } }
+
+ public IEnumerable EmployeeCounts { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Dashboard/ReadVehicleCountDTO.cs b/OneBus.Application/DTOs/Dashboard/ReadVehicleCountDTO.cs
new file mode 100644
index 0000000..18372fb
--- /dev/null
+++ b/OneBus.Application/DTOs/Dashboard/ReadVehicleCountDTO.cs
@@ -0,0 +1,21 @@
+using OneBus.Application.DTOs.Vehicle;
+
+namespace OneBus.Application.DTOs.Dashboard
+{
+ public class ReadVehicleCountDTO
+ {
+ public ReadVehicleCountDTO()
+ {
+ StatusName = string.Empty;
+ Vehicles = [];
+ }
+
+ public long Count { get { return Vehicles.LongCount(); } }
+
+ public byte Status { get; set; }
+
+ public string StatusName { get; set; }
+
+ public IEnumerable Vehicles { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Dashboard/ReadVehicleTotalCountDTO.cs b/OneBus.Application/DTOs/Dashboard/ReadVehicleTotalCountDTO.cs
new file mode 100644
index 0000000..fba2f41
--- /dev/null
+++ b/OneBus.Application/DTOs/Dashboard/ReadVehicleTotalCountDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Dashboard
+{
+ public class ReadVehicleTotalCountDTO
+ {
+ public ReadVehicleTotalCountDTO(IEnumerable vehicleCounts)
+ {
+ VehicleCounts = vehicleCounts;
+ }
+
+ public long TotalCount { get { return VehicleCounts.SelectMany(c => c.Vehicles).LongCount(); } }
+
+ public IEnumerable VehicleCounts { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Employee/ReadStatusDTO.cs b/OneBus.Application/DTOs/Employee/ReadEmployeeStatusDTO.cs
similarity index 71%
rename from OneBus.Application/DTOs/Employee/ReadStatusDTO.cs
rename to OneBus.Application/DTOs/Employee/ReadEmployeeStatusDTO.cs
index 6712450..0609d62 100644
--- a/OneBus.Application/DTOs/Employee/ReadStatusDTO.cs
+++ b/OneBus.Application/DTOs/Employee/ReadEmployeeStatusDTO.cs
@@ -1,8 +1,8 @@
namespace OneBus.Application.DTOs.Employee
{
- public class ReadStatusDTO
+ public class ReadEmployeeStatusDTO
{
- public ReadStatusDTO()
+ public ReadEmployeeStatusDTO()
{
Name = string.Empty;
}
diff --git a/OneBus.Application/DTOs/EmployeeWorkday/ReadEmployeeWorkdayDTO.cs b/OneBus.Application/DTOs/EmployeeWorkday/ReadEmployeeWorkdayDTO.cs
index 701d2bb..0a5653e 100644
--- a/OneBus.Application/DTOs/EmployeeWorkday/ReadEmployeeWorkdayDTO.cs
+++ b/OneBus.Application/DTOs/EmployeeWorkday/ReadEmployeeWorkdayDTO.cs
@@ -5,6 +5,8 @@ public class ReadEmployeeWorkdayDTO : BaseReadDTO
public long EmployeeId { get; set; }
public string? EmployeeName { get; set; }
+
+ public byte[]? EmployeeImage { get; set; }
public string? EmployeeCpf { get; set; }
diff --git a/OneBus.Application/DTOs/Line/CreateLineDTO.cs b/OneBus.Application/DTOs/Line/CreateLineDTO.cs
index 19b04c0..436353e 100644
--- a/OneBus.Application/DTOs/Line/CreateLineDTO.cs
+++ b/OneBus.Application/DTOs/Line/CreateLineDTO.cs
@@ -2,5 +2,22 @@
{
public class CreateLineDTO : BaseCreateDTO
{
+ public CreateLineDTO()
+ {
+ Name = string.Empty;
+ Number = string.Empty;
+ }
+
+ public string Number { get; set; }
+
+ public string Name { get; set; }
+
+ public byte Type { get; set; }
+
+ public TimeOnly TravelTime { get; set; }
+
+ public decimal Mileage { get; set; }
+
+ public byte DirectionType { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Line/ReadDirectionTypeDTO.cs b/OneBus.Application/DTOs/Line/ReadDirectionTypeDTO.cs
new file mode 100644
index 0000000..48c9475
--- /dev/null
+++ b/OneBus.Application/DTOs/Line/ReadDirectionTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Line
+{
+ public class ReadDirectionTypeDTO
+ {
+ public ReadDirectionTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Line/ReadLineDTO.cs b/OneBus.Application/DTOs/Line/ReadLineDTO.cs
index 4ee74db..6bfaa01 100644
--- a/OneBus.Application/DTOs/Line/ReadLineDTO.cs
+++ b/OneBus.Application/DTOs/Line/ReadLineDTO.cs
@@ -2,5 +2,26 @@
{
public class ReadLineDTO : BaseReadDTO
{
+ public ReadLineDTO()
+ {
+ Name = string.Empty;
+ Number = string.Empty;
+ }
+
+ public string Number { get; set; }
+
+ public string Name { get; set; }
+
+ public byte Type { get; set; }
+
+ public string? TypeName { get; set; }
+
+ public TimeOnly TravelTime { get; set; }
+
+ public decimal Mileage { get; set; }
+
+ public byte DirectionType { get; set; }
+
+ public string? DirectionTypeName { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Line/ReadLineTypeDTO.cs b/OneBus.Application/DTOs/Line/ReadLineTypeDTO.cs
new file mode 100644
index 0000000..cf1422d
--- /dev/null
+++ b/OneBus.Application/DTOs/Line/ReadLineTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Line
+{
+ public class ReadLineTypeDTO
+ {
+ public ReadLineTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Line/UpdateLineDTO.cs b/OneBus.Application/DTOs/Line/UpdateLineDTO.cs
index 7b7fc44..ddfa457 100644
--- a/OneBus.Application/DTOs/Line/UpdateLineDTO.cs
+++ b/OneBus.Application/DTOs/Line/UpdateLineDTO.cs
@@ -2,5 +2,20 @@
{
public class UpdateLineDTO : BaseUpdateDTO
{
+ public UpdateLineDTO()
+ {
+ Name = string.Empty;
+ Number = string.Empty;
+ }
+
+ public string Number { get; set; }
+
+ public string Name { get; set; }
+
+ public TimeOnly TravelTime { get; set; }
+
+ public decimal Mileage { get; set; }
+
+ public byte DirectionType { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/LineTime/CreateLineTimeDTO.cs b/OneBus.Application/DTOs/LineTime/CreateLineTimeDTO.cs
index 5460d6f..b2ec3f8 100644
--- a/OneBus.Application/DTOs/LineTime/CreateLineTimeDTO.cs
+++ b/OneBus.Application/DTOs/LineTime/CreateLineTimeDTO.cs
@@ -2,5 +2,10 @@
{
public class CreateLineTimeDTO : BaseCreateDTO
{
+ public long LineId { get; set; }
+
+ public TimeOnly Time { get; set; }
+
+ public byte DayType { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/LineTime/ReadLineTimeDTO.cs b/OneBus.Application/DTOs/LineTime/ReadLineTimeDTO.cs
index c8ff899..c2ccc88 100644
--- a/OneBus.Application/DTOs/LineTime/ReadLineTimeDTO.cs
+++ b/OneBus.Application/DTOs/LineTime/ReadLineTimeDTO.cs
@@ -2,5 +2,20 @@
{
public class ReadLineTimeDTO : BaseReadDTO
{
+ public long LineId { get; set; }
+
+ public string? LineNumber { get; set; }
+
+ public string? LineName { get; set; }
+
+ public byte LineDirectionType { get; set; }
+
+ public string? LineDirectionTypeName { get; set; }
+
+ public TimeOnly Time { get; set; }
+
+ public byte DayType { get; set; }
+
+ public string? DayTypeName { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/LineTime/UpdateLineTimeDTO.cs b/OneBus.Application/DTOs/LineTime/UpdateLineTimeDTO.cs
index 0166816..b4e7a45 100644
--- a/OneBus.Application/DTOs/LineTime/UpdateLineTimeDTO.cs
+++ b/OneBus.Application/DTOs/LineTime/UpdateLineTimeDTO.cs
@@ -1,6 +1,9 @@
namespace OneBus.Application.DTOs.LineTime
{
public class UpdateLineTimeDTO : BaseUpdateDTO
- {
+ {
+ public TimeOnly Time { get; set; }
+
+ public byte DayType { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Maintenance/CreateMaintenanceDTO.cs b/OneBus.Application/DTOs/Maintenance/CreateMaintenanceDTO.cs
index 7995cfb..125d91d 100644
--- a/OneBus.Application/DTOs/Maintenance/CreateMaintenanceDTO.cs
+++ b/OneBus.Application/DTOs/Maintenance/CreateMaintenanceDTO.cs
@@ -2,5 +2,23 @@
{
public class CreateMaintenanceDTO : BaseCreateDTO
{
+ public CreateMaintenanceDTO()
+ {
+ Description = string.Empty;
+ }
+
+ public long VehicleId { get; set; }
+
+ public byte Sector { get; set; }
+
+ public string Description { get; set; }
+
+ public DateOnly StartDate { get; set; }
+
+ public DateOnly EndDate { get; set; }
+
+ public DateOnly SurveyExpiration { get; set; }
+
+ public decimal Cost { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Maintenance/ReadMaintenanceDTO.cs b/OneBus.Application/DTOs/Maintenance/ReadMaintenanceDTO.cs
index 9cb1631..e185a66 100644
--- a/OneBus.Application/DTOs/Maintenance/ReadMaintenanceDTO.cs
+++ b/OneBus.Application/DTOs/Maintenance/ReadMaintenanceDTO.cs
@@ -2,5 +2,27 @@
{
public class ReadMaintenanceDTO : BaseReadDTO
{
+ public ReadMaintenanceDTO()
+ {
+ Description = string.Empty;
+ }
+
+ public long VehicleId { get; set; }
+
+ public string? VehiclePrefix { get; set; }
+
+ public byte Sector { get; set; }
+
+ public string? SectorName { get; set; }
+
+ public string Description { get; set; }
+
+ public DateOnly StartDate { get; set; }
+
+ public DateOnly EndDate { get; set; }
+
+ public DateOnly SurveyExpiration { get; set; }
+
+ public decimal Cost { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Maintenance/ReadSectorDTO.cs b/OneBus.Application/DTOs/Maintenance/ReadSectorDTO.cs
new file mode 100644
index 0000000..27741a7
--- /dev/null
+++ b/OneBus.Application/DTOs/Maintenance/ReadSectorDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Maintenance
+{
+ public class ReadSectorDTO
+ {
+ public ReadSectorDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Maintenance/UpdateMaintenanceDTO.cs b/OneBus.Application/DTOs/Maintenance/UpdateMaintenanceDTO.cs
index 765265a..791f239 100644
--- a/OneBus.Application/DTOs/Maintenance/UpdateMaintenanceDTO.cs
+++ b/OneBus.Application/DTOs/Maintenance/UpdateMaintenanceDTO.cs
@@ -2,5 +2,21 @@
{
public class UpdateMaintenanceDTO : BaseUpdateDTO
{
+ public UpdateMaintenanceDTO()
+ {
+ Description = string.Empty;
+ }
+
+ public byte Sector { get; set; }
+
+ public string Description { get; set; }
+
+ public DateOnly StartDate { get; set; }
+
+ public DateOnly EndDate { get; set; }
+
+ public DateOnly SurveyExpiration { get; set; }
+
+ public decimal Cost { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Vehicle/CreateVehicleDTO.cs b/OneBus.Application/DTOs/Vehicle/CreateVehicleDTO.cs
index 731fa48..5e26783 100644
--- a/OneBus.Application/DTOs/Vehicle/CreateVehicleDTO.cs
+++ b/OneBus.Application/DTOs/Vehicle/CreateVehicleDTO.cs
@@ -2,5 +2,73 @@
{
public class CreateVehicleDTO : BaseCreateDTO
{
+ public CreateVehicleDTO()
+ {
+ Prefix = string.Empty;
+ Model = string.Empty;
+ Plate = string.Empty;
+ Renavam = string.Empty;
+ Licensing = string.Empty;
+ }
+
+ public byte Type { get; set; }
+
+ public string Prefix { get; set; }
+
+ public byte NumberDoors { get; set; }
+
+ public byte NumberSeats { get; set; }
+
+ public bool HasAccessibility { get; set; }
+
+ public byte FuelType { get; set; }
+
+ public byte Brand { get; set; }
+
+ public string Model { get; set; }
+
+ public ushort Year { get; set; }
+
+ public string Plate { get; set; }
+
+ public byte? Color { get; set; }
+
+ public string? BodyworkNumber { get; set; }
+
+ public string? NumberChassis { get; set; }
+
+ public string? EngineNumber { get; set; }
+
+ public byte AxesNumber { get; set; }
+
+ public DateOnly IpvaExpiration { get; set; }
+
+ public string Licensing { get; set; }
+
+ public string Renavam { get; set; }
+
+ public byte TransmissionType { get; set; }
+
+ public DateOnly AcquisitionDate { get; set; }
+
+ public byte Status { get; set; }
+
+ public byte[]? Image { get; set; }
+
+ public byte? BusServiceType { get; set; }
+
+ public byte? BusChassisBrand { get; set; }
+
+ public string? BusChassisModel { get; set; }
+
+ public short? BusChassisYear { get; set; }
+
+ public bool? BusHasLowFloor { get; set; }
+
+ public bool? BusHasLeftDoors { get; set; }
+
+ public DateOnly? BusInsuranceExpiration { get; set; }
+
+ public DateOnly? BusFumigateExpiration { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadBrandDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadBrandDTO.cs
new file mode 100644
index 0000000..a4dd81b
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadBrandDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadBrandDTO
+ {
+ public ReadBrandDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadBusChassisBrandDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadBusChassisBrandDTO.cs
new file mode 100644
index 0000000..d309975
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadBusChassisBrandDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadBusChassisBrandDTO
+ {
+ public ReadBusChassisBrandDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadBusServiceTypeDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadBusServiceTypeDTO.cs
new file mode 100644
index 0000000..30401a1
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadBusServiceTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadBusServiceTypeDTO
+ {
+ public ReadBusServiceTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadColorDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadColorDTO.cs
new file mode 100644
index 0000000..9ac01eb
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadColorDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadColorDTO
+ {
+ public ReadColorDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadFuelTypeDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadFuelTypeDTO.cs
new file mode 100644
index 0000000..337b0d8
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadFuelTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadFuelTypeDTO
+ {
+ public ReadFuelTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadTransmissionTypeDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadTransmissionTypeDTO.cs
new file mode 100644
index 0000000..81d7e25
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadTransmissionTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadTransmissionTypeDTO
+ {
+ public ReadTransmissionTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadVehicleDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadVehicleDTO.cs
index e1d240b..7f97eba 100644
--- a/OneBus.Application/DTOs/Vehicle/ReadVehicleDTO.cs
+++ b/OneBus.Application/DTOs/Vehicle/ReadVehicleDTO.cs
@@ -2,5 +2,89 @@
{
public class ReadVehicleDTO : BaseReadDTO
{
+ public ReadVehicleDTO()
+ {
+ Prefix = string.Empty;
+ Model = string.Empty;
+ Plate = string.Empty;
+ Renavam = string.Empty;
+ Licensing = string.Empty;
+ }
+
+ public byte Type { get; set; }
+
+ public string? TypeName { get; set; }
+
+ public string Prefix { get; set; }
+
+ public byte NumberDoors { get; set; }
+
+ public byte NumberSeats { get; set; }
+
+ public bool HasAccessibility { get; set; }
+
+ public byte FuelType { get; set; }
+
+ public string? FuelTypeName { get; set; }
+
+ public byte Brand { get; set; }
+
+ public string? BrandName { get; set; }
+
+ public string Model { get; set; }
+
+ public ushort Year { get; set; }
+
+ public string Plate { get; set; }
+
+ public byte? Color { get; set; }
+
+ public string? ColorName { get; set; }
+
+ public string? BodyworkNumber { get; set; }
+
+ public string? NumberChassis { get; set; }
+
+ public string? EngineNumber { get; set; }
+
+ public byte AxesNumber { get; set; }
+
+ public DateOnly IpvaExpiration { get; set; }
+
+ public string Licensing { get; set; }
+
+ public string Renavam { get; set; }
+
+ public byte TransmissionType { get; set; }
+
+ public string? TransmissionTypeName { get; set; }
+
+ public DateOnly AcquisitionDate { get; set; }
+
+ public byte Status { get; set; }
+
+ public string? StatusName { get; set; }
+
+ public byte[]? Image { get; set; }
+
+ public byte? BusServiceType { get; set; }
+
+ public string? BusServiceTypeName { get; set; }
+
+ public byte? BusChassisBrand { get; set; }
+
+ public string? BusChassisBrandName { get; set; }
+
+ public string? BusChassisModel { get; set; }
+
+ public short? BusChassisYear { get; set; }
+
+ public bool? BusHasLowFloor { get; set; }
+
+ public bool? BusHasLeftDoors { get; set; }
+
+ public DateOnly? BusInsuranceExpiration { get; set; }
+
+ public DateOnly? BusFumigateExpiration { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadVehicleStatusDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadVehicleStatusDTO.cs
new file mode 100644
index 0000000..02b6262
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadVehicleStatusDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadVehicleStatusDTO
+ {
+ public ReadVehicleStatusDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/ReadVehicleTypeDTO.cs b/OneBus.Application/DTOs/Vehicle/ReadVehicleTypeDTO.cs
new file mode 100644
index 0000000..8590dbe
--- /dev/null
+++ b/OneBus.Application/DTOs/Vehicle/ReadVehicleTypeDTO.cs
@@ -0,0 +1,14 @@
+namespace OneBus.Application.DTOs.Vehicle
+{
+ public class ReadVehicleTypeDTO
+ {
+ public ReadVehicleTypeDTO()
+ {
+ Name = string.Empty;
+ }
+
+ public byte Value { get; set; }
+
+ public string Name { get; set; }
+ }
+}
diff --git a/OneBus.Application/DTOs/Vehicle/UpdateVehicleDTO.cs b/OneBus.Application/DTOs/Vehicle/UpdateVehicleDTO.cs
index e0fa962..182d8d5 100644
--- a/OneBus.Application/DTOs/Vehicle/UpdateVehicleDTO.cs
+++ b/OneBus.Application/DTOs/Vehicle/UpdateVehicleDTO.cs
@@ -2,5 +2,71 @@
{
public class UpdateVehicleDTO : BaseUpdateDTO
{
+ public UpdateVehicleDTO()
+ {
+ Prefix = string.Empty;
+ Model = string.Empty;
+ Plate = string.Empty;
+ Renavam = string.Empty;
+ Licensing = string.Empty;
+ }
+
+ public string Prefix { get; set; }
+
+ public byte NumberDoors { get; set; }
+
+ public byte NumberSeats { get; set; }
+
+ public bool HasAccessibility { get; set; }
+
+ public byte FuelType { get; set; }
+
+ public byte Brand { get; set; }
+
+ public string Model { get; set; }
+
+ public ushort Year { get; set; }
+
+ public string Plate { get; set; }
+
+ public byte? Color { get; set; }
+
+ public string? BodyworkNumber { get; set; }
+
+ public string? NumberChassis { get; set; }
+
+ public string? EngineNumber { get; set; }
+
+ public byte AxesNumber { get; set; }
+
+ public DateOnly IpvaExpiration { get; set; }
+
+ public string Licensing { get; set; }
+
+ public string Renavam { get; set; }
+
+ public byte TransmissionType { get; set; }
+
+ public DateOnly AcquisitionDate { get; set; }
+
+ public byte Status { get; set; }
+
+ public byte[]? Image { get; set; }
+
+ public byte? BusServiceType { get; set; }
+
+ public byte? BusChassisBrand { get; set; }
+
+ public string? BusChassisModel { get; set; }
+
+ public short? BusChassisYear { get; set; }
+
+ public bool? BusHasLowFloor { get; set; }
+
+ public bool? BusHasLeftDoors { get; set; }
+
+ public DateOnly? BusInsuranceExpiration { get; set; }
+
+ public DateOnly? BusFumigateExpiration { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/VehicleOperation/CreateVehicleOperationDTO.cs b/OneBus.Application/DTOs/VehicleOperation/CreateVehicleOperationDTO.cs
index 0fa953c..bab4a08 100644
--- a/OneBus.Application/DTOs/VehicleOperation/CreateVehicleOperationDTO.cs
+++ b/OneBus.Application/DTOs/VehicleOperation/CreateVehicleOperationDTO.cs
@@ -2,5 +2,10 @@
{
public class CreateVehicleOperationDTO : BaseCreateDTO
{
+ public long LineTimeId { get; set; }
+
+ public long EmployeeWorkdayId { get; set; }
+
+ public long VehicleId { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/VehicleOperation/ReadVehicleOperationDTO.cs b/OneBus.Application/DTOs/VehicleOperation/ReadVehicleOperationDTO.cs
index 2d9b991..0496378 100644
--- a/OneBus.Application/DTOs/VehicleOperation/ReadVehicleOperationDTO.cs
+++ b/OneBus.Application/DTOs/VehicleOperation/ReadVehicleOperationDTO.cs
@@ -1,6 +1,81 @@
-namespace OneBus.Application.DTOs.VehicleOperation
+using System.Text.Json.Serialization;
+
+namespace OneBus.Application.DTOs.VehicleOperation
{
public class ReadVehicleOperationDTO : BaseReadDTO
{
+ public long LineTimeId { get; set; }
+
+ public TimeOnly? LineTimeTime { get; set; }
+
+ public byte? LineTimeDayType { get; set; }
+
+ public string? LineTimeDayTypeName { get; set; }
+
+ [JsonPropertyName("lineId")]
+ public long? LineTimeLineId { get; set; }
+
+ [JsonPropertyName("lineDirectionType")]
+ public byte? LineTimeLineDirectionType { get; set; }
+
+ [JsonPropertyName("lineDirectionTypeName")]
+ public string? LineTimeLineDirectionTypeName { get; set; }
+
+ [JsonPropertyName("lineType")]
+ public byte? LineTimeLineType { get; set; }
+
+ [JsonPropertyName("lineTypeName")]
+ public string? LineTimeLineTypeName { get; set; }
+
+ [JsonPropertyName("lineNumber")]
+ public string? LineTimeLineNumber { get; set; }
+
+ [JsonPropertyName("lineName")]
+ public string? LineTimeLineName { get; set; }
+
+ public long EmployeeWorkdayId { get; set; }
+
+ public TimeOnly? EmployeeWorkdayStartTime { get; set; }
+
+ public TimeOnly? EmployeeWorkdayEndTime { get; set; }
+
+ public byte? EmployeeWorkdayDayType { get; set; }
+
+ public string? EmployeeWorkdayDayTypeName { get; set; }
+
+ [JsonPropertyName("employeeId")]
+ public long? EmployeeWorkdayEmployeeId { get; set; }
+
+ [JsonPropertyName("employeeName")]
+ public string? EmployeeWorkdayEmployeeName { get; set; }
+
+ [JsonPropertyName("employeeImage")]
+ public byte[]? EmployeeWorkdayEmployeeImage { get; set; }
+
+ [JsonPropertyName("employeeCpf")]
+ public string? EmployeeWorkdayEmployeeCpf { get; set; }
+
+ [JsonPropertyName("employeeCode")]
+ public string? EmployeeWorkdayEmployeeCode { get; set; }
+
+ [JsonPropertyName("employeeStatus")]
+ public byte? EmployeeWorkdayEmployeeStatus { get; set; }
+
+ [JsonPropertyName("employeeStatusName")]
+ public string? EmployeeWorkdayEmployeeStatusName { get; set; }
+
+ public long VehicleId { get; set; }
+
+ public string? VehiclePrefix { get; set; }
+
+ public byte? VehicleType { get; set; }
+
+ public string? VehicleTypeName { get; set; }
+
+ public byte? VehicleStatus { get; set; }
+
+ public string? VehicleStatusName { get; set; }
+
+ public byte[]? VehicleImage { get; set; }
}
}
diff --git a/OneBus.Application/DTOs/VehicleOperation/UpdateVehicleOperationDTO.cs b/OneBus.Application/DTOs/VehicleOperation/UpdateVehicleOperationDTO.cs
index 6bf63a5..503ccf9 100644
--- a/OneBus.Application/DTOs/VehicleOperation/UpdateVehicleOperationDTO.cs
+++ b/OneBus.Application/DTOs/VehicleOperation/UpdateVehicleOperationDTO.cs
@@ -2,5 +2,10 @@
{
public class UpdateVehicleOperationDTO : BaseUpdateDTO
{
+ public long LineTimeId { get; set; }
+
+ public long EmployeeWorkdayId { get; set; }
+
+ public long VehicleId { get; set; }
}
}
diff --git a/OneBus.Application/Interfaces/Services/IBusOperationService.cs b/OneBus.Application/Interfaces/Services/IBusOperationService.cs
deleted file mode 100644
index f301efd..0000000
--- a/OneBus.Application/Interfaces/Services/IBusOperationService.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using OneBus.Application.DTOs.BusOperation;
-using OneBus.Domain.Entities;
-using OneBus.Domain.Filters;
-
-namespace OneBus.Application.Interfaces.Services
-{
- public interface IBusOperationService :
- IBaseService
- {
- }
-}
diff --git a/OneBus.Application/Interfaces/Services/IBusService.cs b/OneBus.Application/Interfaces/Services/IBusService.cs
deleted file mode 100644
index 60c1962..0000000
--- a/OneBus.Application/Interfaces/Services/IBusService.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using OneBus.Application.DTOs.Bus;
-using OneBus.Domain.Entities;
-using OneBus.Domain.Filters;
-
-namespace OneBus.Application.Interfaces.Services
-{
- public interface IBusService : IBaseService
- {
- }
-}
diff --git a/OneBus.Application/Interfaces/Services/IDashboardService.cs b/OneBus.Application/Interfaces/Services/IDashboardService.cs
new file mode 100644
index 0000000..ea4e080
--- /dev/null
+++ b/OneBus.Application/Interfaces/Services/IDashboardService.cs
@@ -0,0 +1,12 @@
+using OneBus.Application.DTOs.Dashboard;
+using OneBus.Domain.Commons.Result;
+
+namespace OneBus.Application.Interfaces.Services
+{
+ public interface IDashboardService
+ {
+ Task> GetEmployeeStatusAsync(CancellationToken cancellationToken = default);
+
+ Task> GetVehicleStatusAsync(CancellationToken cancellationToken = default);
+ }
+}
diff --git a/OneBus.Application/Interfaces/Services/IEmployeeService.cs b/OneBus.Application/Interfaces/Services/IEmployeeService.cs
index d924a80..b529797 100644
--- a/OneBus.Application/Interfaces/Services/IEmployeeService.cs
+++ b/OneBus.Application/Interfaces/Services/IEmployeeService.cs
@@ -12,6 +12,6 @@ public interface IEmployeeService :
Result> GetRoles();
- Result> GetStatus();
+ Result> GetStatus();
}
}
diff --git a/OneBus.Application/Interfaces/Services/ILineService.cs b/OneBus.Application/Interfaces/Services/ILineService.cs
index c51fd07..4ada52f 100644
--- a/OneBus.Application/Interfaces/Services/ILineService.cs
+++ b/OneBus.Application/Interfaces/Services/ILineService.cs
@@ -1,11 +1,14 @@
using OneBus.Application.DTOs.Line;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
using OneBus.Domain.Filters;
namespace OneBus.Application.Interfaces.Services
{
- public interface ILineService :
- IBaseService
+ public interface ILineService :
+ IBaseService
{
+ Result> GetDirectionTypes();
+ Result> GetLineTypes();
}
}
diff --git a/OneBus.Application/Interfaces/Services/ILineTimeService.cs b/OneBus.Application/Interfaces/Services/ILineTimeService.cs
index 6f6ea5d..ca32205 100644
--- a/OneBus.Application/Interfaces/Services/ILineTimeService.cs
+++ b/OneBus.Application/Interfaces/Services/ILineTimeService.cs
@@ -5,7 +5,7 @@
namespace OneBus.Application.Interfaces.Services
{
public interface ILineTimeService :
- IBaseService
+ IBaseService
{
}
}
diff --git a/OneBus.Application/Interfaces/Services/IMaintenanceService.cs b/OneBus.Application/Interfaces/Services/IMaintenanceService.cs
index 36d7701..5abc42a 100644
--- a/OneBus.Application/Interfaces/Services/IMaintenanceService.cs
+++ b/OneBus.Application/Interfaces/Services/IMaintenanceService.cs
@@ -1,11 +1,13 @@
using OneBus.Application.DTOs.Maintenance;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
using OneBus.Domain.Filters;
namespace OneBus.Application.Interfaces.Services
{
- public interface IMaintenanceService :
- IBaseService
+ public interface IMaintenanceService :
+ IBaseService
{
+ Result> GetSectors();
}
}
diff --git a/OneBus.Application/Interfaces/Services/IVehicleOperationService.cs b/OneBus.Application/Interfaces/Services/IVehicleOperationService.cs
index 4b81d0e..f776053 100644
--- a/OneBus.Application/Interfaces/Services/IVehicleOperationService.cs
+++ b/OneBus.Application/Interfaces/Services/IVehicleOperationService.cs
@@ -5,7 +5,7 @@
namespace OneBus.Application.Interfaces.Services
{
public interface IVehicleOperationService :
- IBaseService
+ IBaseService
{
}
}
diff --git a/OneBus.Application/Interfaces/Services/IVehicleService.cs b/OneBus.Application/Interfaces/Services/IVehicleService.cs
index ac0f422..8d4d4f9 100644
--- a/OneBus.Application/Interfaces/Services/IVehicleService.cs
+++ b/OneBus.Application/Interfaces/Services/IVehicleService.cs
@@ -1,11 +1,27 @@
using OneBus.Application.DTOs.Vehicle;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
using OneBus.Domain.Filters;
namespace OneBus.Application.Interfaces.Services
{
public interface IVehicleService :
- IBaseService
+ IBaseService
{
+ Result> GetBrands();
+
+ Result> GetBusChassisBrands();
+
+ Result> GetBusServiceTypes();
+
+ Result> GetColors();
+
+ Result> GetFuelTypes();
+
+ Result> GetStatus();
+
+ Result> GetTransmissionTypes();
+
+ Result> GetVehicleTypes();
}
}
diff --git a/OneBus.Application/OneBus.Application.csproj b/OneBus.Application/OneBus.Application.csproj
index eee47b5..eae80e9 100644
--- a/OneBus.Application/OneBus.Application.csproj
+++ b/OneBus.Application/OneBus.Application.csproj
@@ -7,10 +7,11 @@
-
+
-
+
+
diff --git a/OneBus.Application/Services/BusOperationService.cs b/OneBus.Application/Services/BusOperationService.cs
deleted file mode 100644
index ba7ab6b..0000000
--- a/OneBus.Application/Services/BusOperationService.cs
+++ /dev/null
@@ -1,26 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.BusOperation;
-using OneBus.Application.Interfaces.Services;
-using OneBus.Domain.Entities;
-using OneBus.Domain.Filters;
-using OneBus.Domain.Interfaces.Repositories;
-
-namespace OneBus.Application.Services
-{
- public class BusOperationService : BaseService,
- IBusOperationService
- {
- public BusOperationService(
- IBaseRepository baseRepository,
- IValidator createValidator,
- IValidator updateValidator)
- : base(baseRepository, createValidator, updateValidator)
- {
- }
-
- protected override void UpdateFields(BusOperation entity, UpdateBusOperationDTO updateDTO)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/OneBus.Application/Services/BusService.cs b/OneBus.Application/Services/BusService.cs
deleted file mode 100644
index 5b17c8d..0000000
--- a/OneBus.Application/Services/BusService.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.Bus;
-using OneBus.Application.Interfaces.Services;
-using OneBus.Domain.Entities;
-using OneBus.Domain.Filters;
-using OneBus.Domain.Interfaces.Repositories;
-
-namespace OneBus.Application.Services
-{
- public class BusService : BaseService, IBusService
- {
- public BusService(
- IBaseRepository baseRepository,
- IValidator createValidator,
- IValidator updateValidator)
- : base(baseRepository, createValidator, updateValidator)
- {
- }
-
- protected override void UpdateFields(Bus entity, UpdateBusDTO updateDTO)
- {
- throw new NotImplementedException();
- }
- }
-}
diff --git a/OneBus.Application/Services/DashboardService.cs b/OneBus.Application/Services/DashboardService.cs
new file mode 100644
index 0000000..977f9e9
--- /dev/null
+++ b/OneBus.Application/Services/DashboardService.cs
@@ -0,0 +1,80 @@
+using OneBus.Application.DTOs.Dashboard;
+using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons.Result;
+using OneBus.Domain.Enums.Employee;
+using OneBus.Domain.Enums.Vehicle;
+using OneBus.Domain.Extensions;
+
+namespace OneBus.Application.Services
+{
+ public class DashboardService : IDashboardService
+ {
+ private readonly IVehicleService _vehicleService;
+ private readonly IEmployeeService _employeeService;
+
+ public DashboardService(
+ IVehicleService vehicleService,
+ IEmployeeService employeeService)
+ {
+ _vehicleService = vehicleService;
+ _employeeService = employeeService;
+ }
+
+ public async Task> GetEmployeeStatusAsync(
+ CancellationToken cancellationToken = default)
+ {
+ var employeesPagination = await _employeeService.GetPaginedAsync(
+ new Domain.Filters.EmployeeFilter { PageSize = int.MaxValue },
+ cancellationToken: cancellationToken);
+
+ if (!employeesPagination.Sucess || !employeesPagination.Value!.Items.Any())
+ return SuccessResult.Create(new ReadEmployeeTotalCountDTO([]));
+
+ var employees = employeesPagination.Value.Items;
+
+ var groupByStatus = employees.GroupBy(c => c.Status).ToList();
+
+ List employeeCounts = [];
+ foreach (var group in groupByStatus)
+ {
+ employeeCounts.Add(new ReadEmployeeCountDTO
+ {
+ Status = group.Key,
+ StatusName = ((EmployeeStatus)group.Key).ToString().Localize(),
+ Employees = group.Select(c => c)
+ });
+ }
+
+ var result = new ReadEmployeeTotalCountDTO(employeeCounts);
+ return SuccessResult.Create(result);
+ }
+
+ public async Task> GetVehicleStatusAsync(CancellationToken cancellationToken = default)
+ {
+ var vehiclesPagination = await _vehicleService.GetPaginedAsync(
+ new Domain.Filters.VehicleFilter { PageSize = int.MaxValue },
+ cancellationToken: cancellationToken);
+
+ if (!vehiclesPagination.Sucess || !vehiclesPagination.Value!.Items.Any())
+ return SuccessResult.Create(new ReadVehicleTotalCountDTO([]));
+
+ var vehicles = vehiclesPagination.Value.Items;
+
+ var groupByStatus = vehicles.GroupBy(c => c.Status).ToList();
+
+ List vehicleCounts = [];
+ foreach (var group in groupByStatus)
+ {
+ vehicleCounts.Add(new ReadVehicleCountDTO
+ {
+ Status = group.Key,
+ StatusName = ((VehicleStatus)group.Key).ToString().Localize(),
+ Vehicles = group.Select(c => c)
+ });
+ }
+
+ var result = new ReadVehicleTotalCountDTO(vehicleCounts);
+ return SuccessResult.Create(result);
+ }
+ }
+}
diff --git a/OneBus.Application/Services/EmployeeService.cs b/OneBus.Application/Services/EmployeeService.cs
index 8114cd2..c6819f5 100644
--- a/OneBus.Application/Services/EmployeeService.cs
+++ b/OneBus.Application/Services/EmployeeService.cs
@@ -27,7 +27,7 @@ public override async Task>> GetPaginedAsync(
DbQueryOptions? dbQueryOptions = null,
CancellationToken cancellationToken = default)
{
- var result = await base.GetPaginedAsync(filter, cancellationToken: cancellationToken);
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
if (!result.Sucess)
return result;
@@ -47,7 +47,7 @@ public override async Task> GetByIdAsync(
DbQueryOptions? dbQueryOptions = null,
CancellationToken cancellationToken = default)
{
- var result = await base.GetByIdAsync(id, cancellationToken: cancellationToken);
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
if (!result.Sucess)
return result;
@@ -61,18 +61,18 @@ public override async Task> GetByIdAsync(
return result;
}
- public Result> GetStatus()
+ public Result> GetStatus()
{
var values = Enum.GetValues();
- List status = [];
+ List status = [];
foreach (var value in values)
{
- status.Add(new ReadStatusDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ status.Add(new ReadEmployeeStatusDTO { Value = (byte)value, Name = value.ToString().Localize() });
}
- return SuccessResult>.Create(status);
+ return SuccessResult>.Create(status);
}
public Result> GetRoles()
{
diff --git a/OneBus.Application/Services/LineService.cs b/OneBus.Application/Services/LineService.cs
index c46d45d..12ca50c 100644
--- a/OneBus.Application/Services/LineService.cs
+++ b/OneBus.Application/Services/LineService.cs
@@ -1,26 +1,98 @@
using FluentValidation;
using OneBus.Application.DTOs.Line;
using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Extensions;
using OneBus.Domain.Filters;
using OneBus.Domain.Interfaces.Repositories;
namespace OneBus.Application.Services
{
- public class LineService : BaseService,
+ public class LineService : BaseService,
ILineService
{
public LineService(
- IBaseRepository baseRepository,
+ IBaseRepository baseRepository,
IValidator createValidator,
IValidator updateValidator)
: base(baseRepository, createValidator, updateValidator)
{
}
+ public override async Task>> GetPaginedAsync(
+ LineFilter filter,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ foreach (var line in result.Value!.Items)
+ {
+ line.TypeName = ((LineType)line.Type).ToString().Localize();
+ line.DirectionTypeName = ((DirectionType)line.DirectionType).ToString().Localize();
+ }
+
+ return result;
+ }
+
+ public override async Task> GetByIdAsync(
+ long id,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ var line = result.Value!;
+ line.TypeName = ((LineType)line.Type).ToString().Localize();
+ line.DirectionTypeName = ((DirectionType)line.DirectionType).ToString().Localize();
+
+ return result;
+ }
+
+ public Result> GetLineTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadLineTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetDirectionTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadDirectionTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
protected override void UpdateFields(Line entity, UpdateLineDTO updateDTO)
{
- throw new NotImplementedException();
+ entity.Name = updateDTO.Name;
+ entity.Number = updateDTO.Number;
+ entity.Mileage = updateDTO.Mileage;
+ entity.TravelTime = updateDTO.TravelTime;
+ entity.DirectionType = updateDTO.DirectionType;
}
}
}
diff --git a/OneBus.Application/Services/LineTimeService.cs b/OneBus.Application/Services/LineTimeService.cs
index d895b3c..e45eb5c 100644
--- a/OneBus.Application/Services/LineTimeService.cs
+++ b/OneBus.Application/Services/LineTimeService.cs
@@ -1,26 +1,68 @@
using FluentValidation;
using OneBus.Application.DTOs.LineTime;
using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
+using OneBus.Domain.Enums;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Extensions;
using OneBus.Domain.Filters;
using OneBus.Domain.Interfaces.Repositories;
namespace OneBus.Application.Services
{
- public class LineTimeService : BaseService,
+ public class LineTimeService : BaseService,
ILineTimeService
{
public LineTimeService(
- IBaseRepository baseRepository,
+ IBaseRepository baseRepository,
IValidator createValidator,
IValidator updateValidator)
: base(baseRepository, createValidator, updateValidator)
{
}
+ public async override Task>> GetPaginedAsync(
+ LineTimeFilter filter,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ foreach (var lineTime in result.Value!.Items)
+ {
+ lineTime.DayTypeName = ((DayType)lineTime.DayType).ToString().Localize();
+ lineTime.LineDirectionTypeName = ((DirectionType)lineTime.LineDirectionType).ToString().Localize();
+ }
+
+ return result;
+ }
+
+ public async override Task> GetByIdAsync(
+ long id,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ var lineTime = result.Value!;
+ lineTime.DayTypeName = ((DayType)lineTime.DayType).ToString().Localize();
+ lineTime.LineDirectionTypeName = ((DirectionType)lineTime.LineDirectionType).ToString().Localize();
+
+ return result;
+ }
+
protected override void UpdateFields(LineTime entity, UpdateLineTimeDTO updateDTO)
{
- throw new NotImplementedException();
+ entity.Time = updateDTO.Time;
+ entity.DayType = updateDTO.DayType;
}
}
}
diff --git a/OneBus.Application/Services/MaintenanceService.cs b/OneBus.Application/Services/MaintenanceService.cs
index 394e293..4e74d85 100644
--- a/OneBus.Application/Services/MaintenanceService.cs
+++ b/OneBus.Application/Services/MaintenanceService.cs
@@ -1,26 +1,100 @@
using FluentValidation;
using OneBus.Application.DTOs.Maintenance;
using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
+using OneBus.Domain.Enums.Maintenance;
+using OneBus.Domain.Extensions;
using OneBus.Domain.Filters;
using OneBus.Domain.Interfaces.Repositories;
namespace OneBus.Application.Services
{
- public class MaintenanceService : BaseService,
+ public class MaintenanceService : BaseService,
IMaintenanceService
{
+ private readonly IVehicleRepository _vehicleRepository;
+
public MaintenanceService(
- IBaseRepository baseRepository,
- IValidator createValidator,
- IValidator updateValidator)
+ IBaseRepository baseRepository,
+ IValidator createValidator,
+ IValidator updateValidator,
+ IVehicleRepository vehicleRepository)
: base(baseRepository, createValidator, updateValidator)
{
+ _vehicleRepository = vehicleRepository;
+ }
+
+ public async override Task>> GetPaginedAsync(
+ MaintenanceFilter filter,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ foreach (var maintenance in result.Value!.Items)
+ {
+ maintenance.SectorName = ((Sector)maintenance.Sector).ToString().Localize();
+ }
+
+ return result;
+ }
+
+ public async override Task> GetByIdAsync(
+ long id,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ var maintenance = result.Value!;
+ maintenance.SectorName = ((Sector)maintenance.Sector).ToString().Localize();
+
+ return result;
+ }
+
+ public Result> GetSectors()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadSectorDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public async override Task> CreateAsync(
+ CreateMaintenanceDTO createDTO,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.CreateAsync(createDTO, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ await _vehicleRepository.SetStatusAsync([createDTO.VehicleId], Domain.Enums.Vehicle.VehicleStatus.Em_Manutenção, cancellationToken);
+ return result;
}
protected override void UpdateFields(Maintenance entity, UpdateMaintenanceDTO updateDTO)
{
- throw new NotImplementedException();
+ entity.Cost = updateDTO.Cost;
+ entity.Sector = updateDTO.Sector;
+ entity.EndDate = updateDTO.EndDate;
+ entity.StartDate = updateDTO.StartDate;
+ entity.Description = updateDTO.Description;
+ entity.SurveyExpiration = updateDTO.SurveyExpiration;
}
}
}
diff --git a/OneBus.Application/Services/UserService.cs b/OneBus.Application/Services/UserService.cs
index 412dd53..c6fca91 100644
--- a/OneBus.Application/Services/UserService.cs
+++ b/OneBus.Application/Services/UserService.cs
@@ -49,9 +49,6 @@ public async Task> LoginAsync(
return SuccessResult.Create(tokenModel);
}
- protected override void UpdateFields(User entity, UpdateUserDTO updateDTO)
- {
- throw new NotImplementedException();
- }
+ protected override void UpdateFields(User entity, UpdateUserDTO updateDTO) { }
}
}
diff --git a/OneBus.Application/Services/VehicleOperationService.cs b/OneBus.Application/Services/VehicleOperationService.cs
index 93f3b93..d9b1114 100644
--- a/OneBus.Application/Services/VehicleOperationService.cs
+++ b/OneBus.Application/Services/VehicleOperationService.cs
@@ -1,26 +1,81 @@
using FluentValidation;
using OneBus.Application.DTOs.VehicleOperation;
using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
+using OneBus.Domain.Enums;
+using OneBus.Domain.Enums.Employee;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Enums.Vehicle;
+using OneBus.Domain.Extensions;
using OneBus.Domain.Filters;
using OneBus.Domain.Interfaces.Repositories;
namespace OneBus.Application.Services
{
- public class VehicleOperationService : BaseService,
+ public class VehicleOperationService : BaseService,
IVehicleOperationService
{
public VehicleOperationService(
- IBaseRepository baseRepository,
+ IBaseRepository baseRepository,
IValidator createValidator,
IValidator updateValidator)
: base(baseRepository, createValidator, updateValidator)
{
}
+ public override async Task>> GetPaginedAsync(
+ VehicleOperationFilter filter,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ foreach (var vehicleOperation in result.Value!.Items)
+ {
+ vehicleOperation.VehicleTypeName = ((VehicleType?)vehicleOperation.VehicleType)?.ToString()?.Localize();
+ vehicleOperation.LineTimeDayTypeName = ((DayType?)vehicleOperation.LineTimeDayType)?.ToString()?.Localize();
+ vehicleOperation.VehicleStatusName = ((VehicleStatus?)vehicleOperation.VehicleStatus)?.ToString()?.Localize();
+ vehicleOperation.LineTimeLineTypeName = ((LineType?)vehicleOperation.LineTimeLineType)?.ToString()?.Localize();
+ vehicleOperation.EmployeeWorkdayDayTypeName = ((DayType?)vehicleOperation.EmployeeWorkdayDayType)?.ToString()?.Localize();
+ vehicleOperation.LineTimeLineDirectionTypeName = ((DirectionType?)vehicleOperation.LineTimeLineDirectionType)?.ToString()?.Localize();
+ vehicleOperation.EmployeeWorkdayEmployeeStatusName = ((EmployeeStatus?)vehicleOperation.EmployeeWorkdayEmployeeStatus)?.ToString()?.Localize();
+ }
+
+ return result;
+ }
+
+ public override async Task> GetByIdAsync(
+ long id,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ var vehicleOperation = result.Value!;
+ vehicleOperation.VehicleTypeName = ((VehicleType?)vehicleOperation.VehicleType)?.ToString()?.Localize();
+ vehicleOperation.LineTimeDayTypeName = ((DayType?)vehicleOperation.LineTimeDayType)?.ToString()?.Localize();
+ vehicleOperation.VehicleStatusName = ((VehicleStatus?)vehicleOperation.VehicleStatus)?.ToString()?.Localize();
+ vehicleOperation.LineTimeLineTypeName = ((LineType?)vehicleOperation.LineTimeLineType)?.ToString()?.Localize();
+ vehicleOperation.EmployeeWorkdayDayTypeName = ((DayType?)vehicleOperation.EmployeeWorkdayDayType)?.ToString()?.Localize();
+ vehicleOperation.LineTimeLineDirectionTypeName = ((DirectionType?)vehicleOperation.LineTimeLineDirectionType)?.ToString()?.Localize();
+ vehicleOperation.EmployeeWorkdayEmployeeStatusName = ((EmployeeStatus?)vehicleOperation.EmployeeWorkdayEmployeeStatus)?.ToString()?.Localize();
+
+ return result;
+ }
+
protected override void UpdateFields(VehicleOperation entity, UpdateVehicleOperationDTO updateDTO)
{
- throw new NotImplementedException();
+ entity.VehicleId = updateDTO.VehicleId;
+ entity.LineTimeId = updateDTO.LineTimeId;
+ entity.EmployeeWorkdayId = updateDTO.EmployeeWorkdayId;
}
}
}
diff --git a/OneBus.Application/Services/VehicleService.cs b/OneBus.Application/Services/VehicleService.cs
index bf793c1..fed8b1b 100644
--- a/OneBus.Application/Services/VehicleService.cs
+++ b/OneBus.Application/Services/VehicleService.cs
@@ -1,26 +1,219 @@
using FluentValidation;
using OneBus.Application.DTOs.Vehicle;
using OneBus.Application.Interfaces.Services;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Commons.Result;
using OneBus.Domain.Entities;
+using OneBus.Domain.Enums.Vehicle;
+using OneBus.Domain.Extensions;
using OneBus.Domain.Filters;
using OneBus.Domain.Interfaces.Repositories;
namespace OneBus.Application.Services
{
- public class VehicleService : BaseService,
+ public class VehicleService : BaseService,
IVehicleService
{
public VehicleService(
- IBaseRepository baseRepository,
- IValidator createValidator,
- IValidator updateValidator)
+ IBaseRepository baseRepository,
+ IValidator createValidator,
+ IValidator updateValidator)
: base(baseRepository, createValidator, updateValidator)
{
}
+ public override async Task>> GetPaginedAsync(
+ VehicleFilter filter,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetPaginedAsync(filter, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ foreach (var vehicle in result.Value!.Items)
+ {
+ vehicle.ColorName = ((Color?)vehicle.Color)?.ToString()?.Localize();
+ vehicle.TypeName = ((VehicleType)vehicle.Type).ToString().Localize();
+ vehicle.BrandName = ((VehicleBrands)vehicle.Brand).ToString().Localize();
+ vehicle.FuelTypeName = ((FuelType)vehicle.FuelType).ToString().Localize();
+ vehicle.StatusName = ((VehicleStatus)vehicle.Status).ToString().Localize();
+ vehicle.BusServiceTypeName = ((BusServiceType?)vehicle.BusServiceType)?.ToString()?.Localize();
+ vehicle.TransmissionTypeName = ((TransmissionType)vehicle.TransmissionType).ToString().Localize();
+ vehicle.BusChassisBrandName = ((BusChassisBrands?)vehicle.BusChassisBrand)?.ToString()?.Localize();
+ }
+
+ return result;
+ }
+
+ public override async Task> GetByIdAsync(
+ long id,
+ DbQueryOptions? dbQueryOptions = null,
+ CancellationToken cancellationToken = default)
+ {
+ var result = await base.GetByIdAsync(id, dbQueryOptions, cancellationToken);
+
+ if (!result.Sucess)
+ return result;
+
+ var vehicle = result.Value!;
+
+ vehicle.ColorName = ((Color?)vehicle.Color)?.ToString()?.Localize();
+ vehicle.TypeName = ((VehicleType)vehicle.Type).ToString().Localize();
+ vehicle.BrandName = ((VehicleBrands)vehicle.Brand).ToString().Localize();
+ vehicle.FuelTypeName = ((FuelType)vehicle.FuelType).ToString().Localize();
+ vehicle.StatusName = ((VehicleStatus)vehicle.Status).ToString().Localize();
+ vehicle.BusServiceTypeName = ((BusServiceType?)vehicle.BusServiceType)?.ToString()?.Localize();
+ vehicle.TransmissionTypeName = ((TransmissionType)vehicle.TransmissionType).ToString().Localize();
+ vehicle.BusChassisBrandName = ((BusChassisBrands?)vehicle.BusChassisBrand)?.ToString()?.Localize();
+
+ return result;
+ }
+
+ public Result> GetStatus()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadVehicleStatusDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetBrands()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadBrandDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetBusChassisBrands()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadBusChassisBrandDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetBusServiceTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadBusServiceTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetColors()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadColorDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetFuelTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadFuelTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetTransmissionTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadTransmissionTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
+ public Result> GetVehicleTypes()
+ {
+ var values = Enum.GetValues();
+
+ List status = [];
+
+ foreach (var value in values)
+ {
+ status.Add(new ReadVehicleTypeDTO { Value = (byte)value, Name = value.ToString().Localize() });
+ }
+
+ return SuccessResult>.Create(status);
+ }
+
protected override void UpdateFields(Vehicle entity, UpdateVehicleDTO updateDTO)
{
- throw new NotImplementedException();
+ entity.Year = updateDTO.Year;
+ entity.Brand = updateDTO.Brand;
+ entity.Model = updateDTO.Model;
+ entity.Plate = updateDTO.Plate;
+ entity.Color = updateDTO.Color;
+ entity.Image = updateDTO.Image;
+ entity.Prefix = updateDTO.Prefix;
+ entity.Status = updateDTO.Status;
+ entity.Renavam = updateDTO.Renavam;
+ entity.FuelType = updateDTO.FuelType;
+ entity.Licensing = updateDTO.Licensing;
+ entity.AxesNumber = updateDTO.AxesNumber;
+ entity.NumberDoors = updateDTO.NumberDoors;
+ entity.NumberSeats = updateDTO.NumberSeats;
+ entity.EngineNumber = updateDTO.EngineNumber;
+ entity.NumberChassis = updateDTO.NumberChassis;
+ entity.BusChassisYear = updateDTO.BusChassisYear;
+ entity.BusServiceType = updateDTO.BusServiceType;
+ entity.BusHasLowFloor = updateDTO.BusHasLowFloor;
+ entity.IpvaExpiration = updateDTO.IpvaExpiration;
+ entity.BodyworkNumber = updateDTO.BodyworkNumber;
+ entity.BusChassisBrand = updateDTO.BusChassisBrand;
+ entity.BusChassisModel = updateDTO.BusChassisModel;
+ entity.AcquisitionDate = updateDTO.AcquisitionDate;
+ entity.BusHasLeftDoors = updateDTO.BusHasLeftDoors;
+ entity.HasAccessibility = updateDTO.HasAccessibility;
+ entity.TransmissionType = updateDTO.TransmissionType;
+ entity.BusFumigateExpiration = updateDTO.BusFumigateExpiration;
+ entity.BusInsuranceExpiration = updateDTO.BusInsuranceExpiration;
}
}
}
diff --git a/OneBus.Application/Validators/Bus/CreateBusDTOValidator.cs b/OneBus.Application/Validators/Bus/CreateBusDTOValidator.cs
deleted file mode 100644
index 2aa60f9..0000000
--- a/OneBus.Application/Validators/Bus/CreateBusDTOValidator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.Bus;
-
-namespace OneBus.Application.Validators.Bus
-{
- public class CreateBusDTOValidator : AbstractValidator
- {
- }
-}
diff --git a/OneBus.Application/Validators/Bus/UpdateBusDTOValidator.cs b/OneBus.Application/Validators/Bus/UpdateBusDTOValidator.cs
deleted file mode 100644
index 2ff8eea..0000000
--- a/OneBus.Application/Validators/Bus/UpdateBusDTOValidator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.Bus;
-
-namespace OneBus.Application.Validators.Bus
-{
- public class UpdateBusDTOValidator : AbstractValidator
- {
- }
-}
diff --git a/OneBus.Application/Validators/BusOperation/CreateBusOperationDTOValidator.cs b/OneBus.Application/Validators/BusOperation/CreateBusOperationDTOValidator.cs
deleted file mode 100644
index 71a1d13..0000000
--- a/OneBus.Application/Validators/BusOperation/CreateBusOperationDTOValidator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.BusOperation;
-
-namespace OneBus.Application.Validators.BusOperation
-{
- public class CreateBusOperationDTOValidator : AbstractValidator
- {
- }
-}
diff --git a/OneBus.Application/Validators/BusOperation/UpdateBusOperationDTOValidator.cs b/OneBus.Application/Validators/BusOperation/UpdateBusOperationDTOValidator.cs
deleted file mode 100644
index 44448c4..0000000
--- a/OneBus.Application/Validators/BusOperation/UpdateBusOperationDTOValidator.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-using FluentValidation;
-using OneBus.Application.DTOs.BusOperation;
-
-namespace OneBus.Application.Validators.BusOperation
-{
- public class UpdateBusOperationDTOValidator : AbstractValidator
- {
- }
-}
diff --git a/OneBus.Application/Validators/Employee/CreateEmployeeDTOValidator.cs b/OneBus.Application/Validators/Employee/CreateEmployeeDTOValidator.cs
index 4edee42..0c5a842 100644
--- a/OneBus.Application/Validators/Employee/CreateEmployeeDTOValidator.cs
+++ b/OneBus.Application/Validators/Employee/CreateEmployeeDTOValidator.cs
@@ -1,9 +1,9 @@
using FluentValidation;
using OneBus.Application.DTOs.Employee;
-using OneBus.Application.Utils;
using OneBus.Domain.Commons;
using OneBus.Domain.Enums.Employee;
using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Employee
{
@@ -52,25 +52,25 @@ public CreateEmployeeDTOValidator(IEmployeeRepository employeeRepository)
private async Task CpfAlreadyExistsAsync(string cpf, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Cpf.ToLower().Equals(cpf),
+ return await _employeeRepository.AnyAsync(c => c.Cpf.ToLower().Equals(cpf.ToLower()),
cancellationToken: cancellationToken);
}
private async Task CodeAlreadyExistsAsync(string code, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Code.ToLower().Equals(code),
+ return await _employeeRepository.AnyAsync(c => c.Code.ToLower().Equals(code.ToLower()),
cancellationToken: cancellationToken);
}
private async Task EmailAlreadyExistsAsync(string email, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Email.ToLower().Equals(email),
+ return await _employeeRepository.AnyAsync(c => c.Email.ToLower().Equals(email.ToLower()),
cancellationToken: cancellationToken);
}
private async Task PhoneAlreadyExistsAsync(string phone, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Phone.ToLower().Equals(phone),
+ return await _employeeRepository.AnyAsync(c => c.Phone.ToLower().Equals(phone.ToLower()),
cancellationToken: cancellationToken);
}
@@ -79,7 +79,7 @@ private async Task CnhNumberAlreadyExistsAsync(string? cnhNumber, Cancella
if (string.IsNullOrWhiteSpace(cnhNumber))
return false;
- return await _employeeRepository.AnyAsync(c => c.CnhNumber!.ToLower().Equals(cnhNumber),
+ return await _employeeRepository.AnyAsync(c => c.CnhNumber!.ToLower().Equals(cnhNumber.ToLower()),
cancellationToken: cancellationToken);
}
}
diff --git a/OneBus.Application/Validators/Employee/UpdateEmployeeDTOValidator.cs b/OneBus.Application/Validators/Employee/UpdateEmployeeDTOValidator.cs
index 9762db7..26378c4 100644
--- a/OneBus.Application/Validators/Employee/UpdateEmployeeDTOValidator.cs
+++ b/OneBus.Application/Validators/Employee/UpdateEmployeeDTOValidator.cs
@@ -1,9 +1,9 @@
using FluentValidation;
using OneBus.Application.DTOs.Employee;
-using OneBus.Application.Utils;
using OneBus.Domain.Commons;
using OneBus.Domain.Enums.Employee;
using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Employee
{
@@ -53,25 +53,25 @@ public UpdateEmployeeDTOValidator(IEmployeeRepository employeeRepository)
private async Task CpfAlreadyExistsAsync(long id, string cpf, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Cpf.ToLower().Equals(cpf) && c.Id != id,
+ return await _employeeRepository.AnyAsync(c => c.Cpf.ToLower().Equals(cpf.ToLower()) && c.Id != id,
cancellationToken: cancellationToken);
}
private async Task CodeAlreadyExistsAsync(long id, string code, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Code.ToLower().Equals(code) && c.Id != id,
+ return await _employeeRepository.AnyAsync(c => c.Code.ToLower().Equals(code.ToLower()) && c.Id != id,
cancellationToken: cancellationToken);
}
private async Task EmailAlreadyExistsAsync(long id, string email, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Email.ToLower().Equals(email) && c.Id != id,
+ return await _employeeRepository.AnyAsync(c => c.Email.ToLower().Equals(email.ToLower()) && c.Id != id,
cancellationToken: cancellationToken);
}
private async Task PhoneAlreadyExistsAsync(long id, string phone, CancellationToken cancellationToken = default)
{
- return await _employeeRepository.AnyAsync(c => c.Phone.ToLower().Equals(phone) && c.Id != id,
+ return await _employeeRepository.AnyAsync(c => c.Phone.ToLower().Equals(phone.ToLower()) && c.Id != id,
cancellationToken: cancellationToken);
}
@@ -80,7 +80,7 @@ private async Task CnhNumberAlreadyExistsAsync(long id, string? cnhNumber,
if (string.IsNullOrWhiteSpace(cnhNumber))
return false;
- return await _employeeRepository.AnyAsync(c => c.CnhNumber!.ToLower().Equals(cnhNumber) && c.Id != id,
+ return await _employeeRepository.AnyAsync(c => c.CnhNumber!.ToLower().Equals(cnhNumber.ToLower()) && c.Id != id,
cancellationToken: cancellationToken);
}
}
diff --git a/OneBus.Application/Validators/EmployeeWorkday/CreateEmployeeWorkdayDTOValidator.cs b/OneBus.Application/Validators/EmployeeWorkday/CreateEmployeeWorkdayDTOValidator.cs
index 2c90fab..4cf3f42 100644
--- a/OneBus.Application/Validators/EmployeeWorkday/CreateEmployeeWorkdayDTOValidator.cs
+++ b/OneBus.Application/Validators/EmployeeWorkday/CreateEmployeeWorkdayDTOValidator.cs
@@ -1,9 +1,9 @@
using FluentValidation;
using OneBus.Application.DTOs.EmployeeWorkday;
-using OneBus.Application.Utils;
using OneBus.Domain.Commons;
using OneBus.Domain.Enums;
using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.EmployeeWorkday
{
@@ -26,12 +26,7 @@ public CreateEmployeeWorkdayDTOValidator(IEmployeeRepository employeeRepository)
.OverridePropertyName(EmployeeIdPropertyName);
RuleFor(c => c.DayType).Must(ValidationUtils.IsValidEnumValue)
- .OverridePropertyName("Dia da Semana");
-
- RuleFor(c => c.EndTime)
- .Must((dto, endTime) => endTime > dto.StartTime)
- .WithMessage("Horário inválido")
- .OverridePropertyName("Horário de Saída");
+ .OverridePropertyName("Dia da Semana");
}
private async Task ExistsAsync(long employeeId, CancellationToken ct = default)
diff --git a/OneBus.Application/Validators/EmployeeWorkday/UpdateEmployeeWorkdayDTOValidator.cs b/OneBus.Application/Validators/EmployeeWorkday/UpdateEmployeeWorkdayDTOValidator.cs
index 95effef..16057d1 100644
--- a/OneBus.Application/Validators/EmployeeWorkday/UpdateEmployeeWorkdayDTOValidator.cs
+++ b/OneBus.Application/Validators/EmployeeWorkday/UpdateEmployeeWorkdayDTOValidator.cs
@@ -6,11 +6,7 @@ namespace OneBus.Application.Validators.EmployeeWorkday
public class UpdateEmployeeWorkdayDTOValidator : AbstractValidator
{
public UpdateEmployeeWorkdayDTOValidator()
- {
- RuleFor(c => c.EndTime)
- .Must((dto, endTime) => endTime > dto.StartTime)
- .WithMessage("Horário inválido")
- .OverridePropertyName("Horário de Saída");
+ {
}
}
}
diff --git a/OneBus.Application/Validators/Line/CreateLineDTOValidator.cs b/OneBus.Application/Validators/Line/CreateLineDTOValidator.cs
index f1d032b..f7c4dca 100644
--- a/OneBus.Application/Validators/Line/CreateLineDTOValidator.cs
+++ b/OneBus.Application/Validators/Line/CreateLineDTOValidator.cs
@@ -1,9 +1,69 @@
using FluentValidation;
using OneBus.Application.DTOs.Line;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Line
{
public class CreateLineDTOValidator : AbstractValidator
{
+ private readonly ILineRepository _lineRepository;
+
+ public const string InvalidDirectionType = "Tipo de Direção inválida, verifique se a linha é circular ou a direção é repetida.";
+
+ public CreateLineDTOValidator(ILineRepository lineRepository)
+ {
+ _lineRepository = lineRepository;
+
+ RuleFor(c => c.Type)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Tipo");
+
+ RuleFor(c => c.DirectionType)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .MustAsync(IsValidDirectionTypeAsync)
+ .WithMessage(InvalidDirectionType)
+ .OverridePropertyName("Tipo de Direção");
+
+ RuleFor(c => c.Number)
+ .MustAsync(async (line, number, ct) => !await IsNumberInUse(number, line.Type, line.DirectionType, ct))
+ .WithMessage(ErrorUtils.AlreadyExists("Número").Message)
+ .NotEmpty()
+ .OverridePropertyName("Número");
+
+ RuleFor(c => c.Name)
+ .NotEmpty()
+ .OverridePropertyName("Nome");
+ }
+
+ private async Task IsValidDirectionTypeAsync(CreateLineDTO lineDTO, byte directionType, CancellationToken cancellationToken = default)
+ {
+ var lines = await _lineRepository.GetManyAsync(c => c.Number.ToLower().Equals(lineDTO.Number.ToLower()) && c.Type == lineDTO.Type,
+ cancellationToken: cancellationToken);
+
+ if (lines is null || !lines.Any())
+ return true;
+
+ if (lines.Any(c => c.DirectionType == directionType))
+ return false;
+
+ if (directionType is (byte)DirectionType.Circular &&
+ lines.Any(c => c.DirectionType is (byte)DirectionType.Ida or (byte)DirectionType.Volta))
+ return false;
+
+ if (directionType is (byte)DirectionType.Ida or (byte)DirectionType.Volta &&
+ lines.Any(c => c.DirectionType is (byte)DirectionType.Circular))
+ return false;
+
+ return true;
+ }
+
+ private async Task IsNumberInUse(string number, byte type, byte directionType, CancellationToken cancellationToken = default)
+ {
+ return await _lineRepository.AnyAsync(c => c.Number.ToLower().Equals(number.ToLower()) && c.Type == type && c.DirectionType == directionType,
+ cancellationToken: cancellationToken);
+ }
}
}
diff --git a/OneBus.Application/Validators/Line/UpdateLineDTOValidator.cs b/OneBus.Application/Validators/Line/UpdateLineDTOValidator.cs
index e74b13b..e6eebd5 100644
--- a/OneBus.Application/Validators/Line/UpdateLineDTOValidator.cs
+++ b/OneBus.Application/Validators/Line/UpdateLineDTOValidator.cs
@@ -1,9 +1,76 @@
using FluentValidation;
using OneBus.Application.DTOs.Line;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Line
{
public class UpdateLineDTOValidator : AbstractValidator
{
+ private readonly ILineRepository _lineRepository;
+
+ public UpdateLineDTOValidator(ILineRepository lineRepository)
+ {
+ _lineRepository = lineRepository;
+
+ RuleFor(c => c.Id).GreaterThan(0);
+
+ RuleFor(c => c.DirectionType)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .MustAsync(IsValidDirectionTypeAsync)
+ .WithMessage(CreateLineDTOValidator.InvalidDirectionType)
+ .OverridePropertyName("Tipo de Direção");
+
+ RuleFor(c => c.Number)
+ .MustAsync(async (line, number, ct) => !await IsNumberInUse(line.Id, number, ct))
+ .WithMessage(ErrorUtils.AlreadyExists("Número").Message)
+ .NotEmpty()
+ .OverridePropertyName("Número");
+
+ RuleFor(c => c.Name)
+ .NotEmpty()
+ .OverridePropertyName("Nome");
+ }
+
+ private async Task IsValidDirectionTypeAsync(UpdateLineDTO lineDTO, byte directionType, CancellationToken cancellationToken = default)
+ {
+ var line = await _lineRepository.GetOneAsync(c => c.Id == lineDTO.Id, cancellationToken: cancellationToken);
+
+ if (line is null)
+ return false;
+
+ var lines = await _lineRepository.GetManyAsync(c => c.Number.ToLower().Equals(line.Number.ToLower()) && c.Type == line.Type,
+ cancellationToken: cancellationToken);
+
+ if (lines is null || !lines.Any())
+ return false;
+
+ if (lines.Any(c => c.DirectionType == directionType))
+ return false;
+
+ if (directionType is (byte)DirectionType.Circular &&
+ lines.Any(c => c.DirectionType is (byte)DirectionType.Ida or (byte)DirectionType.Volta))
+ return false;
+
+ if (directionType is (byte)DirectionType.Ida or (byte)DirectionType.Volta &&
+ lines.Any(c => c.DirectionType is (byte)DirectionType.Circular))
+ return false;
+
+ return true;
+ }
+
+ private async Task IsNumberInUse(long id, string number, CancellationToken cancellationToken = default)
+ {
+ var line = await _lineRepository.GetOneAsync(c => c.Id == id, cancellationToken: cancellationToken);
+
+ if (line is null)
+ return false;
+
+ return await _lineRepository.AnyAsync(c => c.Number.ToLower().Equals(number.ToLower()) &&
+ c.Type == line.Type && c.DirectionType == line.DirectionType && c.Id != id,
+ cancellationToken: cancellationToken);
+ }
}
}
diff --git a/OneBus.Application/Validators/LineTime/CreateLineTimeDTOValidator.cs b/OneBus.Application/Validators/LineTime/CreateLineTimeDTOValidator.cs
index 5837c3e..f6b05a8 100644
--- a/OneBus.Application/Validators/LineTime/CreateLineTimeDTOValidator.cs
+++ b/OneBus.Application/Validators/LineTime/CreateLineTimeDTOValidator.cs
@@ -1,9 +1,37 @@
using FluentValidation;
using OneBus.Application.DTOs.LineTime;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Enums;
+using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.LineTime
{
public class CreateLineTimeDTOValidator : AbstractValidator
{
+ private readonly ILineRepository _lineRepository;
+
+ const string LineIdPropertyName = "Id da Linha";
+
+ public CreateLineTimeDTOValidator(ILineRepository lineRepository)
+ {
+ _lineRepository = lineRepository;
+
+ RuleFor(c => c.LineId).GreaterThan(0)
+ .OverridePropertyName(LineIdPropertyName);
+
+ RuleFor(c => c.LineId)
+ .MustAsync(ExistsAsync)
+ .WithMessage(ErrorUtils.EntityNotFound(LineIdPropertyName).Message)
+ .OverridePropertyName(LineIdPropertyName);
+
+ RuleFor(c => c.DayType).Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Dia da Semana");
+ }
+
+ private async Task ExistsAsync(long lineId, CancellationToken ct = default)
+ {
+ return await _lineRepository.AnyAsync(c => c.Id == lineId, cancellationToken: ct);
+ }
}
}
diff --git a/OneBus.Application/Validators/LineTime/UpdateLineTimeDTOValidator.cs b/OneBus.Application/Validators/LineTime/UpdateLineTimeDTOValidator.cs
index 72a0302..f82ed91 100644
--- a/OneBus.Application/Validators/LineTime/UpdateLineTimeDTOValidator.cs
+++ b/OneBus.Application/Validators/LineTime/UpdateLineTimeDTOValidator.cs
@@ -1,9 +1,19 @@
using FluentValidation;
using OneBus.Application.DTOs.LineTime;
+using OneBus.Domain.Enums;
+using OneBus.Domain.Enums.Line;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.LineTime
{
public class UpdateLineTimeDTOValidator : AbstractValidator
- {
+ {
+ public UpdateLineTimeDTOValidator()
+ {
+ RuleFor(c => c.Id).GreaterThan(0);
+
+ RuleFor(c => c.DayType).Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Dia da Semana");
+ }
}
}
diff --git a/OneBus.Application/Validators/Maintenance/CreateMaintenanceDTOValidator.cs b/OneBus.Application/Validators/Maintenance/CreateMaintenanceDTOValidator.cs
index 3bc45f7..0df8bfa 100644
--- a/OneBus.Application/Validators/Maintenance/CreateMaintenanceDTOValidator.cs
+++ b/OneBus.Application/Validators/Maintenance/CreateMaintenanceDTOValidator.cs
@@ -1,9 +1,45 @@
using FluentValidation;
using OneBus.Application.DTOs.Maintenance;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Enums.Maintenance;
+using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Maintenance
{
public class CreateMaintenanceDTOValidator : AbstractValidator
{
+ private readonly IVehicleRepository _vehicleRepository;
+
+ const string VehicleIdPropertyName = "Id do Veículo";
+
+ public CreateMaintenanceDTOValidator(IVehicleRepository vehicleRepository)
+ {
+ _vehicleRepository = vehicleRepository;
+
+ RuleFor(c => c.VehicleId).GreaterThan(0)
+ .OverridePropertyName(VehicleIdPropertyName);
+
+ RuleFor(c => c.VehicleId)
+ .MustAsync(ExistsAsync)
+ .WithMessage(ErrorUtils.EntityNotFound(VehicleIdPropertyName).Message)
+ .OverridePropertyName(VehicleIdPropertyName);
+
+ RuleFor(c => c.Description)
+ .NotEmpty()
+ .OverridePropertyName("Descrição");
+
+ RuleFor(c => c.Cost).GreaterThanOrEqualTo(0)
+ .OverridePropertyName("Custo");
+
+ RuleFor(c => c.Sector)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Setor");
+ }
+
+ private async Task ExistsAsync(long vehicleId, CancellationToken ct = default)
+ {
+ return await _vehicleRepository.AnyAsync(c => c.Id == vehicleId, cancellationToken: ct);
+ }
}
}
diff --git a/OneBus.Application/Validators/Maintenance/UpdateMaintenanceDTOValidator.cs b/OneBus.Application/Validators/Maintenance/UpdateMaintenanceDTOValidator.cs
index c53765f..445fd4a 100644
--- a/OneBus.Application/Validators/Maintenance/UpdateMaintenanceDTOValidator.cs
+++ b/OneBus.Application/Validators/Maintenance/UpdateMaintenanceDTOValidator.cs
@@ -1,9 +1,26 @@
using FluentValidation;
using OneBus.Application.DTOs.Maintenance;
+using OneBus.Domain.Enums.Maintenance;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Maintenance
{
public class UpdateMaintenanceDTOValidator : AbstractValidator
{
+ public UpdateMaintenanceDTOValidator()
+ {
+ RuleFor(c => c.Id).GreaterThan(0);
+
+ RuleFor(c => c.Description)
+ .NotEmpty()
+ .OverridePropertyName("Descrição");
+
+ RuleFor(c => c.Cost).GreaterThanOrEqualTo(0)
+ .OverridePropertyName("Custo");
+
+ RuleFor(c => c.Sector)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Setor");
+ }
}
}
diff --git a/OneBus.Application/Validators/Vehicle/CreateVehicleDTOValidator.cs b/OneBus.Application/Validators/Vehicle/CreateVehicleDTOValidator.cs
index 2ff123d..cce2b6e 100644
--- a/OneBus.Application/Validators/Vehicle/CreateVehicleDTOValidator.cs
+++ b/OneBus.Application/Validators/Vehicle/CreateVehicleDTOValidator.cs
@@ -1,9 +1,168 @@
using FluentValidation;
using OneBus.Application.DTOs.Vehicle;
+using OneBus.Domain.Commons;
+using OneBus.Domain.Enums.Vehicle;
+using OneBus.Domain.Interfaces.Repositories;
+using OneBus.Domain.Utils;
namespace OneBus.Application.Validators.Vehicle
{
public class CreateVehicleDTOValidator : AbstractValidator
{
+ private readonly IVehicleRepository _vehicleRepository;
+
+ public CreateVehicleDTOValidator(IVehicleRepository vehicleRepository)
+ {
+ _vehicleRepository = vehicleRepository;
+
+ RuleFor(c => c.Type)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Tipo");
+
+ RuleFor(c => c.Prefix)
+ .MustAsync(async (prefix, ct) => !await IsPrefixInUseAsync(prefix, ct))
+ .WithMessage(ErrorUtils.AlreadyExists("Prefixo").Message)
+ .NotEmpty()
+ .OverridePropertyName("Prefixo");
+
+ RuleFor(c => c.FuelType)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Tipo de Combustível");
+
+ RuleFor(c => c.Brand)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Marca");
+
+ RuleFor(c => c.Model)
+ .NotEmpty()
+ .OverridePropertyName("Modelo");
+
+ RuleFor(c => c.Licensing)
+ .NotEmpty()
+ .OverridePropertyName("Licenciamento");
+
+ RuleFor(c => c.Plate)
+ .MustAsync(async (plate, ct) => !await IsPlateInUseAsync(plate, ct))
+ .WithMessage(ErrorUtils.AlreadyExists("Placa").Message)
+ .NotEmpty()
+ .OverridePropertyName("Placa");
+
+ RuleFor(c => c.Renavam)
+ .MustAsync(async (renavam, ct) => !await IsRenavamInUseAsync(renavam, ct))
+ .When(c => !string.IsNullOrWhiteSpace(c.Renavam))
+ .WithMessage(ErrorUtils.AlreadyExists("Renavam").Message)
+ .OverridePropertyName("Renavam");
+
+ RuleFor(c => c.NumberChassis)
+ .MustAsync(async (numberChassis, ct) => !await IsNumberChassisInUseAsync(numberChassis, ct))
+ .When(c => !string.IsNullOrWhiteSpace(c.NumberChassis))
+ .WithMessage(ErrorUtils.AlreadyExists("Número do Chassi").Message)
+ .OverridePropertyName("Número do Chassi");
+
+ RuleFor(c => c.BodyworkNumber)
+ .MustAsync(async (bodyworkNumber, ct) => !await IsBodyworkNumberInUseAsync(bodyworkNumber, ct))
+ .When(c => !string.IsNullOrWhiteSpace(c.BodyworkNumber))
+ .WithMessage(ErrorUtils.AlreadyExists("Número da Carroceria").Message)
+ .OverridePropertyName("Número da Carroceria");
+
+ RuleFor(c => c.EngineNumber)
+ .MustAsync(async (engineNumber, ct) => !await IsEngineNumberInUseAsync(engineNumber, ct))
+ .When(c => !string.IsNullOrWhiteSpace(c.EngineNumber))
+ .WithMessage(ErrorUtils.AlreadyExists("Número do Motor").Message)
+ .OverridePropertyName("Número do Motor");
+
+ RuleFor(c => c.Status)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Status");
+
+ RuleFor(c => c.Color)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .When(c => c.Color != null)
+ .OverridePropertyName("Cor");
+
+ RuleFor(c => c.TransmissionType)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .OverridePropertyName("Tipo de Transmissão");
+
+ RuleFor(c => c.BusServiceType)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .When(c => c.BusServiceType != null)
+ .OverridePropertyName("Tipo de Serviço");
+
+ RuleFor(c => c.BusChassisBrand)
+ .Must(ValidationUtils.IsValidEnumValue)
+ .When(c => c.BusChassisBrand != null)
+ .OverridePropertyName("Marca do Chassi");
+
+ RuleFor(c => c.BusChassisModel)
+ .NotEmpty()
+ .When(c => c.BusChassisModel != null)
+ .OverridePropertyName("Modelo do Chassi");
+
+ RuleFor(c => c.BusChassisYear)
+ .NotNull()
+ .When(c => c.BusChassisYear != null)
+ .OverridePropertyName("Ano do Chassi");
+
+ RuleFor(c => c.BusHasLowFloor)
+ .NotNull()
+ .When(c => c.BusHasLowFloor != null)
+ .OverridePropertyName("Possui Piso Baixo");
+
+ RuleFor(c => c.BusHasLeftDoors)
+ .NotNull()
+ .When(c => c.BusHasLeftDoors != null)
+ .OverridePropertyName("Possui Portas a Esquerda");
+
+ RuleFor(c => c.BusInsuranceExpiration)
+ .NotNull()
+ .When(c => c.BusInsuranceExpiration != null)
+ .OverridePropertyName("Vencimento do Seguro");
+ }
+
+ private async Task IsPrefixInUseAsync(string prefix, CancellationToken cancellationToken = default)
+ {
+ return await _vehicleRepository.AnyAsync(c => c.Prefix.ToLower().Equals(prefix.ToLower()) && c.Status != (byte)VehicleStatus.Desativado,
+ cancellationToken: cancellationToken);
+ }
+
+ private async Task IsPlateInUseAsync(string plate, CancellationToken cancellationToken = default)
+ {
+ return await _vehicleRepository.AnyAsync(c => c.Plate.ToLower().Equals(plate.ToLower()),
+ cancellationToken: cancellationToken);
+ }
+
+ private async Task IsRenavamInUseAsync(string renavam, CancellationToken cancellationToken = default)
+ {
+ return await _vehicleRepository.AnyAsync(c => c.Renavam.ToLower().Equals(renavam.ToLower()),
+ cancellationToken: cancellationToken);
+ }
+
+ private async Task IsNumberChassisInUseAsync(string? numberChassis, CancellationToken cancellationToken = default)
+ {
+ if (string.IsNullOrWhiteSpace(numberChassis))
+ return false;
+
+ return await _vehicleRepository.AnyAsync(c => c.NumberChassis!.ToLower().Equals(numberChassis.ToLower()),
+ cancellationToken: cancellationToken);
+ }
+
+ private async Task