diff --git a/Server/Configurations/MapperInitializer.cs b/Server/Configurations/MapperInitializer.cs index e4950be..28461bf 100644 --- a/Server/Configurations/MapperInitializer.cs +++ b/Server/Configurations/MapperInitializer.cs @@ -46,10 +46,6 @@ public class MapperInitializer : Profile CreateMap().ReverseMap(); CreateMap().ReverseMap(); - - - - CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); @@ -69,10 +65,17 @@ public class MapperInitializer : Profile CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); - - + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); CreateMap().ReverseMap(); CreateMap().ReverseMap(); + + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); + CreateMap().ReverseMap(); } } \ No newline at end of file diff --git a/Server/Controllers/VehicleEnrollmentController.cs b/Server/Controllers/VehicleEnrollmentController.cs index 97929fd..0b3765e 100644 --- a/Server/Controllers/VehicleEnrollmentController.cs +++ b/Server/Controllers/VehicleEnrollmentController.cs @@ -30,6 +30,19 @@ public class VehicleEnrollmentController : ControllerBase return CreatedAtAction(nameof(GetEnrollment), new {id = result.enrollment.Id}, result.enrollment); } + + [HttpPost("withDetails")] + public async Task AddEnrollmentWithDetails(CreateVehicleEnrollmentWithDetailsDto enrollment) + { + var result = await _vehicleEnrollmentManagementService.AddEnrollmentWithDetails(enrollment); + + if (!result.isSucceed) + { + return result.actionResult; + } + + return CreatedAtAction(nameof(GetEnrollment), new {id = result.enrollment.Id}, result.enrollment); + } [HttpGet] public async Task GetEnrollments([FromQuery] VehicleEnrollmentParameters parameters) @@ -46,6 +59,21 @@ public class VehicleEnrollmentController : ControllerBase return Ok(result.enrollments); } + [HttpGet("withDetails")] + public async Task GetEnrollments([FromQuery] VehicleEnrollmentWithDetailsParameters parameters) + { + var result = await _vehicleEnrollmentManagementService.GetEnrollmentsWithDetails(parameters); + + if (!result.isSucceed) + { + return result.actionResult; + } + + Response.Headers.Add("X-Pagination", JsonConvert.SerializeObject(result.pagingMetadata)); + + return Ok(result.enrollments); + } + [HttpGet("{id}")] public async Task GetEnrollment(int id, [FromQuery] string? fields) { @@ -58,6 +86,19 @@ public class VehicleEnrollmentController : ControllerBase return Ok(result.enrollment); } + + [HttpGet("withDetails/{id}")] + public async Task GetEnrollmentWithDetails(int id, [FromQuery] string? fields) + { + var result = await _vehicleEnrollmentManagementService.GetEnrollmentWithDetails(id, fields); + + if (!result.isSucceed) + { + return result.actionResult; + } + + return Ok(result.enrollment); + } [HttpPut("{id}")] public async Task UpdateVehicle(int id, UpdateVehicleEnrollmentDto enrollment) diff --git a/Server/Models/VehicleEnrollment.cs b/Server/Models/VehicleEnrollment.cs index a4fe704..76b5e12 100644 --- a/Server/Models/VehicleEnrollment.cs +++ b/Server/Models/VehicleEnrollment.cs @@ -16,8 +16,6 @@ public class VehicleEnrollment public int RouteId { get; set; } public Route Route { get; set; } = null!; - [ForeignKey("RouteAddressDetailsId")] - public int RouteAddressDetailsId { get; set; } public virtual IList RouteAddressDetails { get; set; } = null!; public DateTime DepartureDateTimeUtc { get; set; } diff --git a/Server/Program.cs b/Server/Program.cs index 07f9a26..a370d88 100644 --- a/Server/Program.cs +++ b/Server/Program.cs @@ -23,6 +23,7 @@ builder.Services.AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.Formatting = Formatting.Indented; options.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); options.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Error; + options.SerializerSettings.DateFormatHandling = DateFormatHandling.IsoDateFormat; }); // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle @@ -116,6 +117,7 @@ builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); +builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); builder.Services.AddScoped, DataShaper>(); diff --git a/Server/Services/AddressManagementService.cs b/Server/Services/AddressManagementService.cs index 915ba24..2102f52 100644 --- a/Server/Services/AddressManagementService.cs +++ b/Server/Services/AddressManagementService.cs @@ -36,6 +36,10 @@ public class AddressManagementService : IAddressManagementService await _dbContext.Addresses.AddAsync(address); await _dbContext.SaveChangesAsync(); + + address = await _dbContext.Addresses.Include(a => a.City) + .ThenInclude(c => c.State).ThenInclude(s => s.Country) + .FirstAsync(a => a.Id == address.Id); return (true, null, _mapper.Map(address)); } diff --git a/Server/Services/CityManagementService.cs b/Server/Services/CityManagementService.cs index ae73db2..66196c0 100644 --- a/Server/Services/CityManagementService.cs +++ b/Server/Services/CityManagementService.cs @@ -36,6 +36,9 @@ public class CityManagementService : ICityManagementService await _dbContext.Cities.AddAsync(city); await _dbContext.SaveChangesAsync(); + + city = await _dbContext.Cities.Include(c => c.State) + .ThenInclude(s => s.Country).FirstAsync(c => c.Id == city.Id); return (true, null, _mapper.Map(city)); } diff --git a/Server/Services/IVehicleEnrollmentManagementService.cs b/Server/Services/IVehicleEnrollmentManagementService.cs index 4e2e4bf..cac6588 100644 --- a/Server/Services/IVehicleEnrollmentManagementService.cs +++ b/Server/Services/IVehicleEnrollmentManagementService.cs @@ -9,9 +9,13 @@ namespace Server.Services; public interface IVehicleEnrollmentManagementService { Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentDto enrollment)> AddEnrollment(CreateVehicleEnrollmentDto createEnrollmentDto); + Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentWithDetailsDto enrollment)> AddEnrollmentWithDetails(CreateVehicleEnrollmentWithDetailsDto createEnrollmentDto); Task<(bool isSucceed, IActionResult? actionResult, IEnumerable enrollments, - PagingMetadata pagingMetadata)> GetEnrollments(VehicleEnrollmentParameters parameters); + PagingMetadata pagingMetadata)> GetEnrollments(VehicleEnrollmentParameters parameters); + Task<(bool isSucceed, IActionResult? actionResult, IEnumerable enrollments, + PagingMetadata pagingMetadata)> GetEnrollmentsWithDetails(VehicleEnrollmentWithDetailsParameters parameters); Task<(bool isSucceed, IActionResult? actionResult, ExpandoObject enrollment)> GetEnrollment(int id, string? fields); + Task<(bool isSucceed, IActionResult? actionResult, ExpandoObject enrollment)> GetEnrollmentWithDetails(int id, string? fields); Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentDto enrollment)> UpdateEnrollment(UpdateVehicleEnrollmentDto updateEnrollmentDto); Task<(bool isSucceed, IActionResult? actionResult)> DeleteEnrollment(int id); Task IsEnrollmentExists(int id); diff --git a/Server/Services/RouteManagementService.cs b/Server/Services/RouteManagementService.cs index 95692b4..ccbed95 100644 --- a/Server/Services/RouteManagementService.cs +++ b/Server/Services/RouteManagementService.cs @@ -49,21 +49,15 @@ public class RouteManagementService : IRouteManagementService { var route = _mapper.Map(createRouteWithAddressesDto); - foreach (var routeAddress in route.RouteAddresses) - { - var dbAddress = await _dbContext.Addresses - .FirstOrDefaultAsync(a => a.Id == routeAddress.AddressId); - - if (dbAddress == null) - { - return (false, new BadRequestObjectResult($"Address with Id {routeAddress.AddressId} doesn't exist"), null!); - } - - routeAddress.Address = dbAddress; - } + await _dbContext.Routes.AddAsync(route); await _dbContext.SaveChangesAsync(); + + route = await _dbContext.Routes + .Include(r => r.RouteAddresses).ThenInclude(ra => ra.Address) + .ThenInclude(a => a.City).ThenInclude(c => c.State) + .ThenInclude(s => s.Country).FirstAsync(r => r.Id == route.Id); return (true, null, _mapper.Map(route)); } @@ -248,7 +242,7 @@ public class RouteManagementService : IRouteManagementService } var routeDto = _mapper.Map(dbRoute); - var shapedData = _routeDataShaper.ShapeData(routeDto, fields); + var shapedData = _routeWithAddressesDataShaper.ShapeData(routeDto, fields); return (true, null, shapedData); } diff --git a/Server/Services/StateManagementService.cs b/Server/Services/StateManagementService.cs index 2389e1c..9aaa334 100644 --- a/Server/Services/StateManagementService.cs +++ b/Server/Services/StateManagementService.cs @@ -36,6 +36,9 @@ public class StateManagementService : IStateManagementService await _dbContext.States.AddAsync(state); await _dbContext.SaveChangesAsync(); + + state = await _dbContext.States.Include(s => s.Country) + .FirstAsync(s => s.Id == state.Id); return (true, null, _mapper.Map(state)); } diff --git a/Server/Services/VehicleEnrollmentManagementService.cs b/Server/Services/VehicleEnrollmentManagementService.cs index c2261df..d38a9c5 100644 --- a/Server/Services/VehicleEnrollmentManagementService.cs +++ b/Server/Services/VehicleEnrollmentManagementService.cs @@ -17,17 +17,20 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe private readonly IMapper _mapper; private readonly ISortHelper _enrollmentSortHelper; private readonly IDataShaper _enrollmentDataShaper; + private readonly IDataShaper _enrollmentWithDetailsDataShaper; private readonly IPager _pager; public VehicleEnrollmentManagementService(ApplicationDbContext dbContext, IMapper mapper, ISortHelper enrollmentSortHelper, - IDataShaper enrollmentDataShaper, IPager pager) + IDataShaper enrollmentDataShaper, IPager pager, + IDataShaper enrollmentWithDetailsDataShaper) { _dbContext = dbContext; _mapper = mapper; _enrollmentSortHelper = enrollmentSortHelper; _enrollmentDataShaper = enrollmentDataShaper; _pager = pager; + _enrollmentWithDetailsDataShaper = enrollmentWithDetailsDataShaper; } public async Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentDto enrollment)> AddEnrollment(CreateVehicleEnrollmentDto createEnrollmentDto) @@ -39,6 +42,20 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe return (true, null, _mapper.Map(enrollment)); } + + public async Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentWithDetailsDto enrollment)> AddEnrollmentWithDetails(CreateVehicleEnrollmentWithDetailsDto createEnrollmentDto) + { + var enrollment = _mapper.Map(createEnrollmentDto); + + await _dbContext.VehicleEnrollments.AddAsync(enrollment); + await _dbContext.SaveChangesAsync(); + + enrollment = await _dbContext.VehicleEnrollments + .Include(ve => ve.RouteAddressDetails) + .FirstAsync(ve => ve.Id == enrollment.Id); + + return (true, null, _mapper.Map(enrollment)); + } public async Task<(bool isSucceed, IActionResult? actionResult, IEnumerable enrollments, PagingMetadata pagingMetadata)> GetEnrollments(VehicleEnrollmentParameters parameters) @@ -80,7 +97,7 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe } enrollment = enrollment.Where(e => - e.CancelationComment.ToLower().Contains(search.ToLower())); + e.CancelationComment != null && e.CancelationComment.ToLower().Contains(search.ToLower())); } void FilterByEnrollmentVehicleId(ref IQueryable enrollments, @@ -142,7 +159,175 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe enrollments = enrollments.Where(e => e.IsCanceled == isCancelled); } } - + + public async Task<(bool isSucceed, IActionResult? actionResult, IEnumerable enrollments, + PagingMetadata pagingMetadata)> GetEnrollmentsWithDetails(VehicleEnrollmentWithDetailsParameters parameters) + { + var dbEnrollments = _dbContext.VehicleEnrollments + .Include(ve => ve.RouteAddressDetails) + .AsQueryable(); + + SearchByAllEnrollmentFields(ref dbEnrollments, parameters.Search); + FilterByEnrollmentVehicleId(ref dbEnrollments, parameters.VehicleId); + FilterByEnrollmentRouteId(ref dbEnrollments, parameters.RouteId); + FilterByEnrollmentDepartureDateTime(ref dbEnrollments, + parameters.FromDepartureDateTime, parameters.ToDepartureDateTime); + FilterByEnrollmentDelayedValue(ref dbEnrollments, parameters.IsDelayed); + FilterByEnrollmentCancelledValue(ref dbEnrollments, parameters.IsCanceled); + FilterByEnrollmentTotalDuration(ref dbEnrollments, + parameters.FromTotalTripDuration, parameters.ToTotalTripDuration); + FilterByEnrollmentTotalCost(ref dbEnrollments, parameters.FromCost, + parameters.ToCost); + + var enrollmentDtos = _mapper.ProjectTo(dbEnrollments); + var shapedData = _enrollmentWithDetailsDataShaper.ShapeData(enrollmentDtos, parameters.Fields).AsQueryable(); + + try + { + shapedData = _enrollmentSortHelper.ApplySort(shapedData, parameters.Sort); + } + catch (Exception) + { + return (false, new BadRequestObjectResult("Invalid sorting string"), null!, null!); + } + + var pagingMetadata = _pager.ApplyPaging(ref shapedData, parameters.PageNumber, + parameters.PageSize); + + return (true, null, shapedData, pagingMetadata); + + void SearchByAllEnrollmentFields(ref IQueryable enrollment, + string? search) + { + if (!enrollment.Any() || String.IsNullOrWhiteSpace(search)) + { + return; + } + + enrollment = enrollment.Where(e => + e.CancelationComment != null && e.CancelationComment.ToLower().Contains(search.ToLower())); + } + + void FilterByEnrollmentVehicleId(ref IQueryable enrollments, + int? vehicleId) + { + if (!enrollments.Any() || vehicleId == null) + { + return; + } + + enrollments = enrollments.Where(e => e.VehicleId == vehicleId); + } + + void FilterByEnrollmentRouteId(ref IQueryable enrollments, + int? routeId) + { + if (!enrollments.Any() || routeId == null) + { + return; + } + + enrollments = enrollments.Where(e => e.RouteId == routeId); + } + + void FilterByEnrollmentDepartureDateTime(ref IQueryable enrollments, + DateTime? fromDateTime, DateTime? toDateTime) + { + if (!enrollments.Any() || fromDateTime == null || toDateTime == null) + { + return; + } + + enrollments = enrollments.Where(e => + e.DepartureDateTimeUtc >= fromDateTime.Value.ToUniversalTime() && + e.DepartureDateTimeUtc <= toDateTime.Value.ToUniversalTime()); + } + + void FilterByEnrollmentDelayedValue(ref IQueryable enrollments, + bool? isDelayed) + { + if (!enrollments.Any() || !isDelayed.HasValue) + { + return; + } + + enrollments = isDelayed.Value + ? enrollments.Where(e => e.DelayTimeSpan != null) + : enrollments.Where(e => e.DelayTimeSpan == null); + } + + void FilterByEnrollmentCancelledValue(ref IQueryable enrollments, + bool? isCancelled) + { + if (!enrollments.Any() || !isCancelled.HasValue) + { + return; + } + + enrollments = enrollments.Where(e => e.IsCanceled == isCancelled); + } + + void FilterByEnrollmentTotalDuration(ref IQueryable enrollments, + TimeSpan? fromDuration, TimeSpan? toDuration) + { + if (!enrollments.Any() ) + { + return; + } + + fromDuration ??= TimeSpan.Zero; + toDuration ??= TimeSpan.MaxValue; + + List filteredEnrollmentsIds = new List(); + foreach (var enrollment in enrollments) + { + TimeSpan duration = TimeSpan.Zero; + foreach (var details in enrollment.RouteAddressDetails) + { + duration += details.WaitTimeSpan + details.TimeSpanToNextCity; + } + + if (duration >= fromDuration && duration <= toDuration) + { + filteredEnrollmentsIds.Add(enrollment.Id); + } + } + + enrollments = enrollments.Where(e => + filteredEnrollmentsIds.Any(id => id == e.Id)); + } + + void FilterByEnrollmentTotalCost(ref IQueryable enrollments, + double? fromCost, double? toCost) + { + if (!enrollments.Any() ) + { + return; + } + + fromCost ??= 0; + toCost ??= Double.MaxValue; + + List filteredEnrollmentsIds = new List(); + foreach (var enrollment in enrollments) + { + double cost = 0; + foreach (var details in enrollment.RouteAddressDetails) + { + cost += details.CostToNextCity; + } + + if (cost >= fromCost && cost <= toCost) + { + filteredEnrollmentsIds.Add(enrollment.Id); + } + } + + enrollments = enrollments.Where(e => + filteredEnrollmentsIds.Any(id => id == e.Id)); + } + } + public async Task<(bool isSucceed, IActionResult? actionResult, ExpandoObject enrollment)> GetEnrollment(int id, string? fields) { if (!await IsEnrollmentExists(id)) @@ -164,6 +349,28 @@ public class VehicleEnrollmentManagementService : IVehicleEnrollmentManagementSe return (true, null, shapedData); } + public async Task<(bool isSucceed, IActionResult? actionResult, ExpandoObject enrollment)> GetEnrollmentWithDetails(int id, string? fields) + { + if (!await IsEnrollmentExists(id)) + { + return (false, new NotFoundResult(), null!); + } + + var dbEnrollment = await _dbContext.VehicleEnrollments + .Include(ve => ve.RouteAddressDetails) + .FirstAsync(e => e.Id == id); + + if (String.IsNullOrWhiteSpace(fields)) + { + fields = VehicleEnrollmentWithDetailsParameters.DefaultFields; + } + + var enrollmentDto = _mapper.Map(dbEnrollment); + var shapedData = _enrollmentWithDetailsDataShaper.ShapeData(enrollmentDto, fields); + + return (true, null, shapedData); + } + public async Task<(bool isSucceed, IActionResult? actionResult, VehicleEnrollmentDto enrollment)> UpdateEnrollment(UpdateVehicleEnrollmentDto updateEnrollmentDto) { var enrollment = _mapper.Map(updateEnrollmentDto); diff --git a/SharedModels/DataTransferObjects/AddressDto.cs b/SharedModels/DataTransferObjects/AddressDto.cs index 29eb500..52206fc 100644 --- a/SharedModels/DataTransferObjects/AddressDto.cs +++ b/SharedModels/DataTransferObjects/AddressDto.cs @@ -40,18 +40,16 @@ public class InCityAddressDto public class CreateAddressInRouteAddress { - public int? Id { get; set; } - [StringLength(maximumLength: 250, ErrorMessage = "Address name is too long")] - public string? Name { get; set; } = null!; + public string Name { get; set; } = null!; [Range(-90, 90, ErrorMessage = "Latitude must be in range(-90, 90)")] - public double? Latitude { get; set; } + public double Latitude { get; set; } [Range(-180, 180, ErrorMessage = "Longitude must be in range(-180, 180)")] - public double? Longitude { get; set; } + public double Longitude { get; set; } - public int? CityId { get; set; } + public int CityId { get; set; } } public class AddressInRouteAddress : CreateAddressInRouteAddress diff --git a/SharedModels/DataTransferObjects/RouteAddressDetailsDto.cs b/SharedModels/DataTransferObjects/RouteAddressDetailsDto.cs new file mode 100644 index 0000000..54eb5e5 --- /dev/null +++ b/SharedModels/DataTransferObjects/RouteAddressDetailsDto.cs @@ -0,0 +1,52 @@ +using System.ComponentModel.DataAnnotations; + +namespace SharedModels.DataTransferObjects; + +public class RouteAddressDetailsDto : CreateRouteAddressDetailsDto +{ + public int Id { get; set; } +} + +public class CreateRouteAddressDetailsDto +{ + [Required] + public int VehicleEnrollmentId { get; set; } + + [Required] + public int RouteAddressId { get; set; } + + [Required] + public TimeSpan TimeSpanToNextCity { get; set; } + + [Required] + public TimeSpan WaitTimeSpan { get; set; } + + [Required] + public double CostToNextCity { get; set; } +} + +public class UpdateRouteAddressDetailsDto : CreateRouteAddressDetailsDto +{ + [Required] + public int Id { get; set; } +} + +public class CreateRouteAddressDetailsInVehicleEnrollmentDto +{ + [Required] + public int RouteAddressId { get; set; } + + [Required] + public TimeSpan TimeSpanToNextCity { get; set; } + + [Required] + public TimeSpan WaitTimeSpan { get; set; } + + [Required] + public double CostToNextCity { get; set; } +} + +public class RouteAddressDetailsInVehicleEnrollmentDto : CreateRouteAddressDetailsInVehicleEnrollmentDto +{ + public int Id { get; set; } +} \ No newline at end of file diff --git a/SharedModels/DataTransferObjects/RouteAddressDto.cs b/SharedModels/DataTransferObjects/RouteAddressDto.cs index 5e7b98d..23a6b06 100644 --- a/SharedModels/DataTransferObjects/RouteAddressDto.cs +++ b/SharedModels/DataTransferObjects/RouteAddressDto.cs @@ -30,14 +30,19 @@ public class CreateRouteAddressWithAddressDto { [Range(0, Int32.MaxValue)] public int Order { get; set; } - - [Required] - public CreateAddressInRouteAddress Address { get; set; } = null!; + + public CreateAddressInRouteAddress? Address { get; set; } + + public int? AddressId { get; set; } } public class RouteAddressWithAddressDto { + public int Id { get; set; } + public int Order { get; set; } public AddressInRouteAddress Address { get; set; } = null!; + + public int AddressId { get; set; } } \ No newline at end of file diff --git a/SharedModels/DataTransferObjects/TicketGroupDto.cs b/SharedModels/DataTransferObjects/TicketGroupDto.cs new file mode 100644 index 0000000..e166997 --- /dev/null +++ b/SharedModels/DataTransferObjects/TicketGroupDto.cs @@ -0,0 +1,6 @@ +namespace SharedModels.DataTransferObjects; + +public class TicketGroupDto +{ + +} \ No newline at end of file diff --git a/SharedModels/DataTransferObjects/VehicleEnrollmentDto.cs b/SharedModels/DataTransferObjects/VehicleEnrollmentDto.cs index a818a4f..9020513 100644 --- a/SharedModels/DataTransferObjects/VehicleEnrollmentDto.cs +++ b/SharedModels/DataTransferObjects/VehicleEnrollmentDto.cs @@ -29,4 +29,16 @@ public class UpdateVehicleEnrollmentDto : CreateVehicleEnrollmentDto public bool IsCanceled { get; set; } = false; public string CancelationComment { get; set; } = null!; +} + +public class CreateVehicleEnrollmentWithDetailsDto : CreateVehicleEnrollmentDto +{ + public IList RouteAddressDetails { get; set; } = null!; +} + +public class VehicleEnrollmentWithDetailsDto +{ + public int Id { get; set; } + + public IList RouteAddressDetails { get; set; } = null!; } \ No newline at end of file diff --git a/SharedModels/QueryParameters/Objects/VehicleEnrollmentWithDetailsParameters.cs b/SharedModels/QueryParameters/Objects/VehicleEnrollmentWithDetailsParameters.cs new file mode 100644 index 0000000..d02f9fb --- /dev/null +++ b/SharedModels/QueryParameters/Objects/VehicleEnrollmentWithDetailsParameters.cs @@ -0,0 +1,24 @@ +namespace SharedModels.QueryParameters.Objects; + +public class VehicleEnrollmentWithDetailsParameters : ParametersBase +{ + public const string DefaultFields = "id,vehicleId,routeId,departureDateTimeUtc," + + "delayTimeSpan,isCancelled,cancellationComment," + + "routeAddressDetails"; + + public VehicleEnrollmentWithDetailsParameters() + { + Fields = DefaultFields; + } + + public int? VehicleId { get; set; } + public int? RouteId { get; set; } + public DateTime? FromDepartureDateTime { get; set; } + public DateTime? ToDepartureDateTime { get; set; } + public bool? IsDelayed { get; set; } + public bool? IsCanceled {get; set; } + public TimeSpan? FromTotalTripDuration { get; set; } + public TimeSpan? ToTotalTripDuration { get; set; } + public double? FromCost { get; set; } + public double? ToCost { get; set; } +} \ No newline at end of file