public Task <IEnumerable <Supply> > GetAllAsync(bool isRemoved, Domain.Models.DatePeriod datePeriod) { return(unitOfWork.Supplies.GetAllExtendedAsync(isRemoved, datePeriod)); }
public async Task <IEnumerable <Supply> > GetAllExtendedAsync(bool isRemoved, Domain.Models.DatePeriod datePeriod) { //Сделано так, но можно улучшить фильтрацию по дате var q = context.Supplies .Where(x => x.IsDelete == isRemoved); if (!datePeriod.IsEmpty) { q = q.Where(x => x.ProvideDate >= datePeriod.DateTimeFrom && x.ProvideDate <= datePeriod.DateTimeTo); } q = q.Select(x => new Supply { Count = x.Count, EquipmentTypeId = x.EquipmentTypeId, EquipmentTypeName = x.EquipmentType.Name, Id = x.Id, IsDelete = x.IsDelete, ProvideDate = x.ProvideDate, ProviderId = x.ProviderId, ProviderName = x.Provider.Name }); return(await q.ToListAsync()); }