public IList<ChildBirth> GetChildBirth(Filters filter) { using (var context = new RabbitsDBEntities()) { IQueryable<ChildBirth> query = context.ChildBirth; if (!string.IsNullOrEmpty(filter.MaleName)) query = query.Where(x => x.MaleId1 == new MalesRepository().GetMale(filter.MaleName).Id); if (!string.IsNullOrEmpty(filter.FemaleName)) query = query.Where(x => x.FemaleId == new FemalesRepository().GetFemale(filter.FemaleName).Id); if (filter.DateFrom.HasValue) query = query.Where(x => x.Birthday >= filter.DateFrom); if (filter.DateTo.HasValue) query = query.Where(x => x.Birthday <= filter.DateTo); return query.ToList(); } }
public IList<ChildBirth> GetChildBirth(Filters filter) { return new ChildBirthRepository().GetChildBirth(filter); }
Filters GetFiltersData(FormCollection formCollection) { var filter = new Filters(); filter.FemaleName = formCollection["textboxFemaleName"]; filter.MaleName = formCollection["textboxMaleName"]; filter.DateFrom = Convert.ToDateTime(formCollection["textboxDateFrom"]); filter.DateTo = Convert.ToDateTime(formCollection["textboxDateTo"]); var names = formCollection.AllKeys.Where(c => c.StartsWith("checkbox")); return filter; }
public ActionResult Filter(string maleName, string femaleName, string[] resultsIds, string dateFrom, string dateTo) { var filters = new Filters { MaleName = maleName, FemaleName = femaleName, DateFrom = DateTime.Parse(dateFrom), DateTo = DateTime.Parse(dateTo), Results = resultsIds != null ? new ResultsManager().GetResults(resultsIds) : null }; return RedirectToAction(ShowChildBirthAction, new { childBirthParrentsList = new ChildBirthManager().GetChildBirth(filters)}); }