public ActionResult RoomList(FilterRoomModel f) { int mode = 0; if (f.roomType != null) { mode += 1000; } if (f.bedType != null) { mode += 100; } if (f.acType != null) { mode += 10; } // Enabled Room mode += 1; if (f.StartDate < DateTime.Parse("01/01/1990")) { f.StartDate = DateTime.Now.Date; } if (f.EndDate < DateTime.Parse("01/01/1990")) { f.EndDate = DateTime.Now.Date.AddDays(1); } TempData["StartDate"] = f.StartDate; TempData["EndDate"] = f.EndDate; var model = db.GetGroupedFilteredRoomsByModeAndDate(mode, f.roomType, f.bedType, f.acType, true, f.StartDate, f.EndDate); return(View(model.ToList())); }
public ActionResult Index(FilterRoomModel f) { if (f.StartDate < DateTime.Now.Date) { ModelState.AddModelError(nameof(f.StartDate), "Start date must be no earlier than today."); } if (f.EndDate <= f.StartDate) { ModelState.AddModelError(nameof(f.EndDate), "End date must be later than start date."); } if (ModelState.IsValid) { return(RedirectToAction("RoomList", f)); } return(View(f)); }