public static IEnumerable<SelectListItem> BuildClientsDropdownList() { ManagerContext db = new ManagerContext(); List<SelectListItem> clientsList = new List<SelectListItem>(); List<Client> clients = db.Clients.ToList(); foreach (Client c in clients) { clientsList.Add(new SelectListItem { Value = c.ID.ToString(), Text = c.Name + " - " + c.Email, }); } return clientsList; }
public static IEnumerable<SelectListItem> BuildReportTypesDropdownList() { ManagerContext db = new ManagerContext(); List<SelectListItem> typesList = new List<SelectListItem>(); typesList.Add(new SelectListItem { Value = "0", Text = "Select One", }); typesList.Add(new SelectListItem { Value = "1", Text = "Client Emails", }); typesList.Add(new SelectListItem { Value = "2", Text = "Monthly Tax Report", }); typesList.Add(new SelectListItem { Value = "3", Text = "Available Houses", }); typesList.Add(new SelectListItem { Value = "4", Text = "Arrival/Departure Dates", }); return typesList; }
public static Boolean IsAvailableInRange(DateTime start, DateTime end, int houseID) { if (start > end) return false; ManagerContext db = new ManagerContext(); List<Booking> bookings = db.Bookings.Where(m => m.House.ID == houseID).ToList(); foreach (Booking b in bookings) { if ((start >= b.StartDate && start < b.EndDate) || (end > b.StartDate && end <= b.EndDate) || (start < b.StartDate && end > b.EndDate)) return false; } return true; }
public static IEnumerable<SelectListItem> BuildHousesDropdownList() { ManagerContext db = new ManagerContext(); List<SelectListItem> housesList = new List<SelectListItem>(); List<House> houses = db.Houses.ToList(); housesList.Add(new SelectListItem { Value = "0", Text = "Select One", }); foreach (House h in houses) { housesList.Add(new SelectListItem { Value = h.ID.ToString(), Text = h.Name, }); } return housesList; }