public PartialViewResult Index_DonationLogTable_Post(DonationShowFilterViewModel model) { var query = bddb.DonationLog .Include(dl => dl.Donor) .Include(dl => dl.DonationCenter) .Include(dl => dl.DonationCenter.DonationCenterType) .Include(dl => dl.DonationCenter.Address) .Where(dl => dl.Donor.Email == SessionState.Current.UserEmail); if (model.MinDate != DateTime.MinValue) { query = query.Where(dl => dl.DonationDate >= model.MinDate); } if (model.MaxDate != DateTime.MinValue) { query = query.Where(dl => dl.DonationDate <= model.MaxDate); } if (model.DonationCenter != null) { query = query.Where(dl => (dl.DonationCenter.Name + (" ") + dl.DonationCenter.DonationCenterType.Name + (" ") + dl.DonationCenter.Address.City).ToLower().Contains(model.DonationCenter.ToLower())); } if (model.IsSuccessful != null) { query = query.Where(dl => dl.IsSuccessful == model.IsSuccessful); } if (model.IsNextDatePassed != null) { if ((bool)model.IsNextDatePassed) { query = query.Where(dl => dl.NextDate <= DateTime.Now); } else { query = query.Where(dl => dl.NextDate >= DateTime.Now); }; } var DonationLogTable = new DonationShowTableViewModel { Header = new DonationShowTableRowViewModel(), Rows = query.Select(q => new DonationShowTableRowViewModel { Id = q.Id, DonationDate = q.DonationDate, DonationCenter = q.DonationCenter.Name + " " + q.DonationCenter.DonationCenterType.Name, IsSuccessful = q.IsSuccessful ? "✔" : "𘚨", NextDate = q.NextDate }).ToList() }; return(PartialView("_DonationLogTable", DonationLogTable)); }
// GET: Donation public ActionResult Index() { var model = new DonationShowFilterViewModel(); return(View(model)); }