public Task <List <MaintenanceCost> > List(MaintenanceCostSearchParams searchParams) { var taskResult = Task.Run(() => { using (var context = new DbContext()) { var ctx = context .MaintCostList .Where(c => c.SocietyId == searchParams.SocietyId) .Include(m => m.Society) .Include(m => m.Definition) .Include(m => m.Flats) .Include(m => m.Approvals) .Include(m => m.Comments); if (searchParams.IsApproved.HasValue) { ctx = ctx.Where(c => c.IsApproved == searchParams.IsApproved.Value); } if (searchParams.IsDeleted.HasValue) { ctx = ctx.Where(c => c.Deleted == searchParams.IsDeleted.Value); } if (searchParams.IsActive.HasValue) { ctx = ctx.Where(c => !c.ToDate.HasValue || c.ToDate.Value > DateTime.Now); } if (searchParams.IsRejected.HasValue) { ctx = ctx.Where(c => c.IsRejected == searchParams.IsRejected.Value); } return(ctx.ToList()); } }); return(taskResult); }
public Task <List <MaintenanceCost> > List(MaintenanceCostSearchParams searchParams) { return(_maintenanceCostRepository.List(searchParams)); }