public JsonResult GetJSONAllReservationList(GetReservationsParamVM model) { var floorPlan = model.FloorPlanId.HasValue ? model.FloorPlanId.Value.ToString() : string.Empty; var shift = model.ShiftId.HasValue ? model.ShiftId.Value.ToString() : string.Empty; string key = string.Format(CacheKeys.FILTERED_RESERVATION, User.Identity.GetDatabaseName(), model.Date.Ticks, model.Time, model.Filter, floorPlan, shift); var ResListVM = cache.Get<CachedReservationItemListVM>(key, () => { var allRes = db.GetReservationByDate(model.Date) .Where(r => (r.FloorTableId > 0) ? (!r.FloorTable.IsDeleted) : (!r.MergedFloorTable.OrigionalTables.Any(t => t.FloorTable.IsDeleted))).ToList(); allRes = allRes.Where(r => r.StatusId.Value != ReservationStatus.Cancelled).ToList(); var covers = allRes.Sum(r => r.Covers); IList<ReservationListItemVM> ResList = GetFilteredReservations20150617(model); var currentList = new CachedReservationItemListVM { ReservationListItems = ResList, Covers = allRes.Sum(r => r.Covers) }; return currentList; }); //ViewBag.Covers = ResListVM.Covers; var liTemplate = @"<li id='resL{0}' class='{1}cover popUp' data-cover='{1}' data-time='{2}'>{3}</li>"; var HTMLArray = new List<string>(); HTMLArray.Add("<ul class='reslist'>"); HTMLArray.AddRange(ResListVM.ReservationListItems .Select(rvm => string.Format(liTemplate, rvm.Reservation.ReservationId, rvm.Reservation.Covers, rvm.Reservation.TimeForm.TimeOfDay.TotalMinutes, rvm.HTMLString))); HTMLArray.Add("</ul>"); return Json(new { HTMLArray = HTMLArray, Covers = ResListVM.Covers }, JsonRequestBehavior.AllowGet); }
public PartialViewResult GetAllReservationList20150617(GetReservationsParamVM model) { var floorPlan = model.FloorPlanId.HasValue ? model.FloorPlanId.Value.ToString() : string.Empty; var shift = model.ShiftId.HasValue ? model.ShiftId.Value.ToString() : string.Empty; string key = string.Format(CacheKeys.FILTERED_RESERVATION, User.Identity.GetDatabaseName(), model.Date.Ticks, model.Time, model.Filter, floorPlan, shift); var ResListVM = cache.Get<CachedReservationItemListVM>(key, () => { var allRes = db.GetReservationByDate(model.Date) .Where(r => (r.FloorTableId > 0) ? (!r.FloorTable.IsDeleted) : (!r.MergedFloorTable.OrigionalTables.Any(t => t.FloorTable.IsDeleted))).ToList(); allRes = allRes.Where(r => r.StatusId.Value != ReservationStatus.Cancelled).ToList(); var covers = allRes.Sum(r => r.Covers); IList<ReservationListItemVM> ResList = GetFilteredReservations20150617(model); var currentList = new CachedReservationItemListVM { ReservationListItems = ResList, Covers = allRes.Sum(r => r.Covers) }; //var day = model.Date.DayOfWeek.ToString().Trim(); //var dId = db.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId; //var openTime = new DateTime(); //var closeTime = new DateTime(); //var ttime = db.GetMenuShiftHours().Where(p => p.DayId == dId).AsEnumerable(); //var minOpenAt = ttime.Where(p => p.OpenAt != null).Min(p => Convert.ToDateTime(p.OpenAt)); //var maxCloseAt = ttime.Where(p => p.CloseAt != null).Max(p => Convert.ToDateTime(p.CloseAt).AddDays(Convert.ToInt32(p.IsNext))); //openTime = Convert.ToDateTime(minOpenAt); //closeTime = Convert.ToDateTime(maxCloseAt); //while (openTime < closeTime) //{ // var startTime = openTime; // openTime = openTime.AddMinutes(15); // string otherKey = string.Format(CacheKeys.FILTERED_RESERVATION, // model.Date.Ticks, // startTime.ToString("HH:mm"), // model.Filter, // floorPlan, // shift); // var other = cache.Get<CachedReservationItemListVM>(otherKey, () => // { // IList<ReservationListItemVM> otherResList = GetFilteredReservations20150617(model); // var otherList = new CachedReservationItemListVM // { // ReservationListItems = ResList, // Covers = covers // }; // return otherList; // }); //} return currentList; }); ViewBag.Covers = ResListVM.Covers; return PartialView("~/Views/FloorPlan/ReservationListPartial.cshtml", ResListVM.ReservationListItems); }