Merge remote-tracking branch 'origin/main'

This commit is contained in:
2025-04-27 17:47:48 +03:30
@@ -74,11 +74,22 @@ public interface ITransportationRepository : IRepository<Transportation, long>
📂 Suggested Folder: Infrastructure/Services/Services/TransportationRepositories 📂 Suggested Folder: Infrastructure/Services/Services/TransportationRepositories
```cs ```cs
public async Task<IEnumerable<Transportation>> SearchTransportationsAsync( public class TransportationRepository :
BaseRepository<ApplicationDBContext, Transportation, long>,
ITransportationRepository
{
public TransportationRepository(ApplicationDBContext dbContext) : base(dbContext)
{
}
public async Task<IEnumerable<Transportation>> SearchTransportationsAsync(
short? vehicleTypeId, short? vehicleTypeId,
int? fromCityId, int? toCityId, int? fromCityId,
DateTime? startDate, DateTime? endDate) int? toCityId,
{ DateTime? startDate,
DateTime? endDate)
{
var query = DbContext.Transportations var query = DbContext.Transportations
.Include(x => x.Vehicle) .Include(x => x.Vehicle)
.Include(x => x.FromLocation).ThenInclude(x => x.City) .Include(x => x.FromLocation).ThenInclude(x => x.City)
@@ -86,22 +97,14 @@ public async Task<IEnumerable<Transportation>> SearchTransportationsAsync(
.Include(x => x.Company) .Include(x => x.Company)
.AsQueryable(); .AsQueryable();
query = query.Where(x => vehicleTypeId == null || x.Vehicle.VehicleTypeId == vehicleTypeId.Value); query = query.Where(x => vehicleTypeId == null || x.Vehicle.VehicleTypeId == vehicleTypeId.Value);
query = query.Where(x => fromCityId == null || x.FromLocation.CityId == fromCityId.Value);
query = query.Where query = query.Where(x => toCityId == null || x.ToLocation.CityId == toCityId.Value);
(x => fromCityId == null || x.FromLocation.CityId == fromCityId.Value); query = query.Where(x => startDate == null || x.StartDateTime.Date == startDate.Value.Date);
query = query.Where(x => endDate == null || (x.EndDateTime.HasValue && x.EndDateTime.Value == endDate.Value.Date));
query = query.Where
(x => toCityId == null || x.ToLocation.CityId == toCityId.Value);
query = query.Where
(x => startDate == null || x.StartDateTime.Date == startDate.Value.Date);
query = query.Where
(x => endDate == null ||
(x.EndDateTime.HasValue && x.EndDateTime.Value == endDate.Value.Date));
return await query.ToListAsync(); return await query.ToListAsync();
} }
}
``` ```