public ActionResult Slots(string date) { var day = DateTime.Parse(date); var cart = GetCart(); List<LocationDay> locations = new List<LocationDay>(); foreach (var facility in _facilities.GetAllFacilities()) { var dbSlots = _reservations.GetExistingReservationsForFacility(facility.FacilityName).ToList(); var cartReserved = cart.Slots != null && cart.Slots.Count() > 0 ? cart.Slots.Where(s => s.DayOfReservation == day.Date) .Where(s => s.Facility.ToLower().CompareTo(facility.FacilityName.ToLower()) == 0) .ToList() : new List<ReservedSlot>(); var dbReserved = dbSlots != null && dbSlots.Count() > 0 ? dbSlots.Where(s => s.DayOfReservation == day.Date).ToList() : new List<ReservedSlot>(); var reserved = cartReserved.Concat(dbReserved).ToList(); var locationDay = new LocationDay() { Location = facility, Day = day, ReservedSlots = reserved }; locations.Add(locationDay); } ViewBag.SellingUnitMinutes = _reservations.SellingUnitMiutes; return View("~/Views/Reservation/SlotsPartial.cshtml", locations); }
public ActionResult Days() { List<Day> days = new List<Day>(); var StartDay = DateTime.Today; var EndDay = StartDay.AddDays(30); int DifferenceFromLastSunday = DayOfWeek.Sunday - StartDay.DayOfWeek; var LastSunday = StartDay.AddDays(DifferenceFromLastSunday).Date; for (var date = LastSunday; date.Date < StartDay.Date; date = date.AddDays(1)) { var allReserved = new List<ReservedSlot>(); allReserved.Add(new ReservedSlot { StartTime = date.Date, EndTime = date.Date.AddHours(24) }); var locationDay = new LocationDay() { Day = date.Date, ReservedSlots = allReserved, }; days.Add(new Day { Locations = new List<LocationDay> { locationDay } }); } var cart = GetCart(); for (DateTime date = StartDay; date.Date <= EndDay.Date; date = date.AddDays(1)) { var locations = new List<LocationDay>(); foreach (var facility in _facilities.GetAllFacilities()) { var dbSlots = _reservations.GetExistingReservationsForFacility(facility.FacilityName).ToList(); var cartReserved = cart.Slots != null && cart.Slots.Count() > 0 ? cart.Slots.Where(s => s.DayOfReservation == date.Date) .Where(s => s.Facility.ToLower().CompareTo(facility.FacilityName.ToLower()) == 0) .ToList() : new List<ReservedSlot>(); var dbReserved = dbSlots != null && dbSlots.Count() > 0 ? dbSlots.Where(s => s.DayOfReservation == date.Date).ToList() : new List<ReservedSlot>(); var reserved = cartReserved.Concat(dbReserved).ToList(); var locationDay = new LocationDay() { Location = facility, Day = date.Date, ReservedSlots = reserved }; locations.Add(locationDay); } days.Add(new Day { Locations = locations }); } return View("~/Views/Reservation/DaysPartial.cshtml", days); }
public void Setup() { _model = new LocationDay { HourlyForecasts = new[] { new HourlyForecast { Time = new TimeSpan(12, 0, 0), Weather = string.Empty } } }; }