public ActionResult CancelReservation(int id) { Reservation res = GetReservation(id); bool success = DeleteReservation(id, res.CustomerFirstname, res.CustomerLastname); var startDate = (DateTime)Session["start_date"]; var endDate = (DateTime)Session["end_date"]; ReservationVM result = new ReservationVM { ReservationId = id, Rooms = res.Room, StartDate = startDate, EndDate = endDate, Firstname = res.CustomerFirstname, Lastname = res.CustomerLastname }; if (success == true) { return(View(result)); } result.Message = "Cancellation refused"; return(RedirectToAction("ResConfirmation", "Home", result)); }
public ActionResult Validate() { ReservationVM reservation = (ReservationVM)TempData["Reservation"]; TempData["Reservation"] = reservation; List <Room> rooms = new List <Room>(); foreach (int id in reservation.RoomIds) { Room room = RoomManager.GetRoom(id); rooms.Add(room); } ReservationValidateVM reservationValidate = new ReservationValidateVM(); reservationValidate.Arrival = reservation.Arrival; reservationValidate.Departure = reservation.Departure; reservationValidate.TotalNight = ReservationManager.GetNumberOfNight(reservation.Arrival, reservation.Departure); reservationValidate.FirstName = reservation.Firstname; reservationValidate.LastName = reservation.Lastname; reservationValidate.Rooms = rooms; reservationValidate.TotalPrice = ReservationManager.CalculatePrice(reservation.RoomIds, reservation.Arrival, reservation.Departure); reservationValidate.RoomNumber = rooms.Count(); ViewBag.ReservationValidate = reservationValidate; return(View(reservation)); }
public ActionResult Step1() { ReservationVM rvm = (ReservationVM)Session["rvm"]; List <Reservation> reservations = db.Reservations.ToList(); List <Vehicle> vehicles = db.Vehicles.ToList(); foreach (var reservation in reservations) { if (!((reservation.pickupDateTime > rvm.pickupDateTime && reservation.returnDateTime > rvm.pickupDateTime && reservation.pickupDateTime > rvm.returnDateTime && reservation.returnDateTime > rvm.returnDateTime) || (reservation.pickupDateTime < rvm.pickupDateTime && reservation.returnDateTime < rvm.pickupDateTime && reservation.pickupDateTime < rvm.returnDateTime && reservation.returnDateTime < rvm.returnDateTime))) { if (vehicles.Contains(reservation.vehicle)) { vehicles.Remove(reservation.vehicle); } } } Session["expiredateIsValid"] = true; Session["monthInRange"] = true; return(View(vehicles)); }
// GET: Reservations public async Task <IActionResult> Index(DateTime JourDebutSejour, int NombreDeNuit, byte NbPersonnes, byte HeureArrivee, bool?Travail) { ReservationVM tvm = new ReservationVM(); tvm.JourDebutSejour = DateTime.Today; JourDebutSejour = DateTime.Today; // ne recuprère pas direct les données mais juste les données dont on a besoin IQueryable <Reservation> tac = _context.Reservation; if (Travail.HasValue) { tac = tac.Where(s => s.Travail == Travail); } if (ModelState.IsValid) { tac = tac.Where(s => s.Jour == JourDebutSejour && s.NbPersonnes == NbPersonnes && s.HeureArrivee == HeureArrivee); } tvm.Reservations = await tac.ToListAsync(); //var grandHotelDbContext = _context.Reservation.Include(r => r.IdClientNavigation).Include(r => r.JourNavigation).Include(r => r.NumChambreNavigation); return(View("Index", tvm)); }
public ActionResult CustomerReservation(int id) { var user = User as MPrincipal; if (user == null) { TempData["alertMessage"] = "Zaloguj się, aby zarezerwować termin"; return(RedirectToAction("LoginCustomer", "Account")); } var login = user.UserDetails.Login; ViewBag.UserName = user.UserDetails.Login; ReservationVM res = new ReservationVM(); res.TermId = id; using (ApplicationDbContext db = new ApplicationDbContext()) { var cust = db.Customers.FirstOrDefault(u => u.Login.Equals(login)); if (cust == null) { TempData["alertMessage"] = "Termin możesz zarezerwować tylko jako kient"; return(RedirectToAction("Index", "Home")); } ViewBag.UserRole = cust.RoleId; res.CustomerId = cust.ID; var term = db.Terms.FirstOrDefault(u => u.Id == id); res.CompanyName = term.Company.CompanyName; } return(View(res)); }
public ActionResult Removal() { // Je récupère les informations saisies par l'utilisateur (en minuscules, afin d'éviter les problèmes de casse) string firstname = Request["firstname"].ToLower(); string lastname = Request["lastname"].ToLower(); int identity = Convert.ToInt32(Request["number"]); // Je teste ensuite si les informations saisies correspondent à une réservation (comme une sorte de login) // Si c'est en ordre, je lance les deux requêtes de suppression Boolean login = ReservationManager.LoginReservation(identity, firstname, lastname); if (login.Equals(true)) { ReservationManager.RemoveReservation(identity); ReservationDetailsManager.RemoveReservationDetails(identity); } // Je passe ensuite la valeur du booléen login à la vue, afin d'afficher le bon encadré // Je passe également les informations de la réservation, afin de les afficher ViewData["login"] = login; ReservationVM reservation = new ReservationVM { IdReservation = identity, ClientFirstname = Request["firstname"], ClientLastname = Request["lastname"] }; return(View(reservation)); }
public ActionResult Reservation() { ReservationVM model = new ReservationVM(); model.Settings = db.settings.FirstOrDefault() ?? new Models.Settings(); return(View(model)); }
// GET: Reservation public ActionResult Index() { //Resource.GetWeather(2172797); Resource.GetCity(); ReservationVM reservationVM = new ReservationVM(); return(View(reservationVM)); }
public ActionResult Index(ReservationVM NewReservation) { using (var db = new Y2kContext()) { db.Reservacion.Add(NewReservation.Reservation); db.SaveChanges(); return(RedirectToAction("Resultado", new { Id = NewReservation.Reservation.Id })); } }
// GET: Reservation/Create public ActionResult Create() { var Res = new ReservationVM(); Res.Locataires = serviceLoc.GetMany().ToSelectListItems(); Res.Bungalows = serviceBung.GetMany().ToSelectListItems(); return(View(Res)); }
// GET: Reservations/Create public ActionResult Create() { ViewBag.Room_Id = new SelectList(db.Rooms, "Id", "Name"); ViewBag.RoomType_Id = new SelectList(db.RoomTypes, "Id", "Name"); ReservationVM reservationVM = new ReservationVM { Reservations = db.Reservations.ToList(), }; return(View(reservationVM)); }
public ActionResult Index(ReservationVM1 reservationvm1) { ReservationVM reservationvm = new ReservationVM(); reservationvm.pickupPlace = reservationvm1.pickupPlace; reservationvm.returnPlace = reservationvm1.returnPlace; reservationvm.pickupDateTime = reservationvm1.pickupDate.Date + reservationvm1.pickupTime.TimeOfDay; reservationvm.returnDateTime = reservationvm1.returnDate.Date + reservationvm1.returnTime.TimeOfDay; Session["rvm"] = reservationvm; return(RedirectToAction("Step1")); }
public ActionResult Reservation(int?id) { #region Cart list HttpCookie cookieCart = Request.Cookies["Cart"]; List <string> CartList = new List <string>(); if (cookieCart != null) { CartList = cookieCart.Value.Split(',').ToList(); CartList.RemoveAt(CartList.Count - 1); ViewBag.CartList = CartList; ViewBag.CartListCount = CartList.Count; } else { ViewBag.CartListCount = 0; } List <Product> products = new List <Product>(); foreach (var item in CartList) { foreach (var prd in db.Products.Include("ProductImages").Include("Admin").Include("ProductToCategory").Include("ProductToCategory.ProductCategory").ToList()) { if (Convert.ToInt32(item.Split('-')[0]) == prd.Id) { prd.Count = Convert.ToDecimal(item.Split('-')[1]); products.Add(prd); } } } ViewBag.Products = products; #endregion ViewBag.ModelPage = true; ViewBag.Blogs = db.Blog.Where(c => c.isActive).OrderByDescending(c => c.PostDate).Take(3).ToList(); ViewBag.Address = db.Layout.FirstOrDefault().Address; ViewBag.Phone = db.Layout.FirstOrDefault().Phone; ViewBag.Email = db.Layout.FirstOrDefault().Email; ViewBag.FooterLogo = db.Layout.FirstOrDefault().LogoFooter; ViewBag.HeaderLogo = db.Layout.FirstOrDefault().Logo; ReservationVM v = new ReservationVM(); v.Model = db.Model.Include("Admin").Include("Brand").Include("ModelImages").Include("Reservations").FirstOrDefault(m => m.Id == id && m.isActive); v.FeatureSets = db.FeatureSet.ToList(); return(View(v)); }
public ActionResult Resultado(int Id) { ReservationVM reservation = new ReservationVM(); using (var db = new Y2kContext()) { reservation.Reservation = db.Reservacion.Include("City").FirstOrDefault(s => s.Id == Id); } reservation.GetWeather(reservation.Reservation.City.Id); return(View(reservation)); }
public ActionResult Create(IFormCollection collection) { try { ReservationVM vm = new ReservationVM(_reservationRepo, _screeningRepo); return(View(vm)); } catch { return(View()); } }
public ReservationPage(string e, string lname, string r, int c) { InitializeComponent(); email = e; lotname = lname; row = r; col = c; //VIEW MODEL Value Transfer reservationVM = new ReservationVM(lotname, row, col, email); //BINDINGCONTEXT HERE BindingContext = reservationVM; }
public ActionResult Create() { RESTClientClient RESTClientClient = new RESTClientClient(); RESTRoomClient RESTRoomClient = new RESTRoomClient(); ReservationVM rVM = new ReservationVM(); rVM.Clients = RESTClientClient.getClients(); rVM.Rooms = RESTRoomClient.GetRooms(); return(View(rVM)); }
public ActionResult Hotel(int id, ReservationVM reservation) { if (ModelState.IsValid) { TempData["Reservation"] = reservation; return(RedirectToAction("Validate")); } TempData["ViewData"] = ViewData; return(RedirectToAction("Hotel")); }
public static ReservationVM convertToVM(Reservation reservation) { var vm = new ReservationVM() { fromDate = reservation.startDate, toDate = reservation.endDate, typeOfRoom = reservation.roomType, guestCount = reservation.guestCount, found = true }; return(vm); }
public ActionResult CancelReservation(ReservationVM reservation) { using (ApplicationDbContext db = new ApplicationDbContext()) { var reservationDB = db.Reservations.FirstOrDefault(u => u.TermId == reservation.TermId); reservationDB.IsDelete = true; int termId = reservationDB.TermId; var termDB = db.Terms.FirstOrDefault(t => t.Id == termId); termDB.CustomerId = null; db.SaveChanges(); } return(RedirectToAction("CompanyTermList", "Company")); }
public ReservationActions(ReservationVM vm, RoomsBLL roomBLL, FeaturesBLL featureBLL, ExtraServicesBLL extraServicesBLL, DiscountBLL discountBLL) { viewModel = vm; this.roomBLL = roomBLL; this.featureBLL = featureBLL; this.extraServicesBLL = extraServicesBLL; this.discountBLL = discountBLL; }
public ActionResult Edit(int id) { RESTClientClient RESTClientClient = new RESTClientClient(); RESTRoomClient RESTRoomClient = new RESTRoomClient(); ReservationVM rvm = new ReservationVM(); rvm.Clients = RESTClientClient.getClients(); rvm.Rooms = RESTRoomClient.GetRooms(); rvm.reservation = RESTReservationClient.getReservationById(id); return(View(rvm)); }
public static Reservation convertFromVM(ReservationVM vm, System.Security.Claims.ClaimsIdentity user) { var reservation = new Reservation() { guestCount = vm.guestCount, roomType = vm.typeOfRoom, roomID = db.Rooms.First(f => f.roomType == vm.typeOfRoom).ID, startDate = vm.fromDate, endDate = vm.toDate, userID = user.Name }; return(reservation); }
public ActionResult Edit([Bind(Include = "ReservationID,CarID,CustomerID,StartDate,EndDate")] ReservationVM reservationVM) { if (ModelState.IsValid) { var reservation = ReservationVM.MapTo(reservationVM); db.Entry(reservation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CarID = new SelectList(db.Cars, "CarID", "Make", reservationVM.CarID); ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "Name", reservationVM.CustomerID); return(View(reservationVM)); }
public ActionResult Reserve(ReservationVM rvm) { // Get the rooms selected for the reservation rvm.Reservation.Rooms = new List <Room>(); foreach (Room r in rvm.Rooms) { using (HttpClient httpClient = new HttpClient()) { Task <String> response = httpClient.GetStringAsync(roomUri + r.IdRoom); rvm.Reservation.Rooms.Add(JsonConvert.DeserializeObject <Room>(response.Result)); } } // Send the reservation to the system using (HttpClient httpClient = new HttpClient()) { string pro = JsonConvert.SerializeObject(rvm.Reservation); StringContent frame = new StringContent(pro, Encoding.UTF8, "Application/json"); Task <HttpResponseMessage> response = httpClient.PostAsync(reservationUri, frame); if (response.Result.IsSuccessStatusCode) { // } } /* * Get all reservations and get last one */ List <Reservation> reservations; using (HttpClient httpClient = new HttpClient()) { Task <String> response = httpClient.GetStringAsync(reservationUri); reservations = JsonConvert.DeserializeObject <List <Reservation> >(response.Result); } Reservation reserv = reservations.ElementAt(0); foreach (Reservation res in reservations) { if (res.IdReservation > reserv.IdReservation) { reserv = res; } } // Redirect to reservation details return(RedirectToAction("Details", new { id = reserv.IdReservation })); }
public IActionResult Create(ChooseSeatVM chooseSeatVM) { List <Seat> seats = new List <Seat>(); foreach (var row in chooseSeatVM.SeatCheckBoxList) { foreach (var seat in row) { if (seat.IsChecked) { seats.Add(_db.Seat.Find(seat.Id)); } } } ScheduleEntry scheduleEntry = _db.ScheduleEntry.Where(se => se.Id == chooseSeatVM.ScheduleEntryId).Include(m => m.Movie). Include(s => s.Schedule).ThenInclude(c => c.Cinema).FirstOrDefault(); Order order; if (scheduleEntry.NewPrice != null) { order = new Order { Price = (float)(Math.Round((double)(seats.Count * scheduleEntry.NewPrice * 0.95), 2)) } } ; else { order = new Order { Price = (float)(Math.Round(seats.Count * scheduleEntry.Price * 0.95, 2)) } }; ReservationVM reservationVM = new ReservationVM() { ScheduleEntry = scheduleEntry, Customer = _db.Customer.Find(_userManager.GetUserId(User)), Payment = new Payment(), Order = order, PaymentSelectList = ((IEnumerable <WebConstants.PaymentMethod>)Enum.GetValues(typeof(WebConstants.PaymentMethod))).Select(pm => new SelectListItem { Text = pm.ToString().Replace('_', ' '), Value = pm.ToString() }), Seats = seats }; return(View(reservationVM)); }
public IHttpActionResult Put([FromBody] ReservationVM vm) { var db = new ApplicationDBContext(); var user = User.Identity as System.Security.Claims.ClaimsIdentity; if (UserServices.verifyUser(user) == false) { UserServices.createUser(user); } var reservation = ReservationServices.convertFromVM(vm, user); db.Reservations.AddOrUpdate(reservation); db.SaveChanges(); return(Ok(reservation)); }
public ActionResult Create([Bind(Include = "ReservationID,CustomerID,ParkingID,StartDate,EndDate")] Reservation reservation) { if (ModelState.IsValid) { db.Reservations.Add(reservation); db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.CustomerID = new SelectList(db.Customers, "CustomerID", "FirstName", reservation.CustomerID); ViewBag.ParkingID = new SelectList(db.ParkingLots.GroupBy(x => x.ParkingName).Select(x => x.FirstOrDefault()).ToList(), "ParkingID", "ParkingName"); var reservationsVM = ReservationVM.MapTo(reservation); return(View(reservationsVM)); }
public async Task <IActionResult> Select(string id) { if (id == null) { return(NotFound()); } MatchSection matchSection = await _matchSectionService.FindById(id); ReservationVM reservationVM = new ReservationVM { MatchId = matchSection.Match.Id, ReservationDate = DateTime.Now, NumberOfTickets = 1, Price = matchSection.Match.BasePriceTicket * matchSection.Section.PriceFactor, SectionName = matchSection.Section.Name, MatchSectionId = id, HomeTeam = matchSection.Match.HomeTeam.Name, AwayTeam = matchSection.Match.AwayTeam.Name, MatchDate = matchSection.Match.MatchDate.Date }; ShoppingCartVM shopping; if (HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart") != null) { shopping = HttpContext.Session.GetObject <ShoppingCartVM>("ShoppingCart"); var matchIds = shopping.Reservations.Select(m => m.MatchId).ToList(); if (matchIds != null) { if (matchIds.Contains(reservationVM.MatchId)) { ModelState.AddModelError("error", "U heeft al een ticket voor deze match in uw Winkelmandje."); return(View("Index", shopping)); } } } else { shopping = new ShoppingCartVM(); shopping.Reservations = new List <ReservationVM>(); shopping.Subscriptions = new List <SubscriptionCartVM>(); } shopping.Reservations.Add(reservationVM); HttpContext.Session.SetObject("ShoppingCart", shopping); return(RedirectToAction("Index", "ShoppingCart")); }
public ActionResult Create(ReservationVM resVM) { Reservation reservation = new Reservation() { CIN = resVM.CIN, DateDebut = resVM.DateDebut, NombreJour = resVM.NombreJour, PrixTotal = resVM.PrixTotal, Saison = resVM.Saison, CodeBungalow = resVM.CodeBungalow, }; serviceRes.Add(reservation); serviceRes.Commit(); return(RedirectToAction("Index")); }
private void UpdateReservationModel(ReservationVM model) { if (model.ReservationId > 0) { var res = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); model.Email = ((res.Customers.Emails.Count() > 0) ? res.Customers.Emails.First().Email : string.Empty); model.FirstName = res.Customers.FirstName; model.LastName = res.Customers.LastName; model.MobileNumber = res.Customers.PhoneNumbers.First().PhoneNumbers; model.ShiftId = res.FoodMenuShiftId; model.Status = res.StatusId.ToString(); model.TablePositionLeft = res.TablePositionLeft; model.TablePositionTop = res.TablePositionTop; } }
public ActionResult MergeTablePartial(ReservationVM model) { ViewBag.LevelList = db.tabFloorPlans.ToList().Select(fp => new { Text = "L" + fp.FLevel.Value + "-" + fp.FloorName, Value = fp.FloorPlanId }); var coverList = new List<object>(); for (int i = 7; i <= 16; i++) { coverList.Add(new { Value = i, Text = i + " Cover" }); } ViewBag.CoverList = coverList; ViewBag.TimeList = db.GetTimeListForReservation(model); var tempTables = db.tabMergedFloorTables .Include("OrigionalTables") .Where(mt => mt.CreatedBy == User.Identity.GetUserId<long>() && !db.tabReservations .Any(r => !r.IsDeleted && r.MergedFloorTableId == mt.FloorTableId)) .ToList(); if (tempTables.Count() > 0) { foreach (var tbl in tempTables) { foreach (var otbl in tbl.OrigionalTables.ToList()) { db.tabMergedTableOrigionalTables.Remove(otbl); } db.tabMergedFloorTables.Remove(tbl); } db.SaveChanges(); } return PartialView(model); }
public ActionResult Reserve(ReservationVM model) { Reservation reservation = null; try { var onlineUserName = context.Users.Where(c => c.Roles.Any(ur => ur.RoleId == context.Roles.Where(r => r.Name == "Online").FirstOrDefault().Id)).Single().UserName; var onlineUser = context.Users.Where(u => u.UserName.Contains(onlineUserName)).First(); FloorTableServer server = null; var fTblId = Convert.ToInt64(model.tableIdd); var flrTbl = context.tabFloorTables.Find(fTblId); model.FloorPlanId = flrTbl.FloorPlanId; model.MergeTableId = 0; server = flrTbl.FloorTableServer; double time = 0; if (!string.IsNullOrEmpty(model.Email)) { model.Email = model.Email.Trim(); } model.MobileNumber = model.MobileNumber.Trim(); // model.ShiftId = model.ShiftId; var startTime = model.resDate.Add(DateTime.ParseExact(model.time.Trim(), "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay); bool isFakeMobileNo = long.Parse(model.MobileNumber) == 0L; var customer = context.tabCustomers.Where(c => !isFakeMobileNo && c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Contains(model.MobileNumber))).FirstOrDefault(); int tShiftId = 0; var openTM = new DateTime(); var closeTM = new DateTime(); var day = model.resDate.DayOfWeek.ToString(); var dId = context.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId; var aa = context.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && startTime.Date.Add(openTM.TimeOfDay) <= startTime && startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { tShiftId = timeShift.FoodMenuShiftId; } model.ShiftId = tShiftId; model.Status = (!string.IsNullOrEmpty(model.Status)) ? model.Status : ReservationStatus.Online_Booking.ToString(); #region Old Customer //if (customer != null) //{ if (customer != null && StringComparer.OrdinalIgnoreCase.Equals(customer.FirstName.Trim(), model.FirstName.Trim()) && StringComparer.OrdinalIgnoreCase.Equals(customer.FirstName.Trim(), model.FirstName.Trim())) { reservation = new Reservation() { FloorPlanId = model.FloorPlanId, Covers = model.Covers, CustomerId = customer.CustomerId, FoodMenuShiftId = model.ShiftId, ReservationDate = model.resDate, TimeForm = startTime, TimeTo = startTime.AddMinutes(model.Duration.GetMinutesFromDuration()), FloorTableId = fTblId, MergedFloorTableId = model.MergeTableId.Value, StatusId = Convert.ToInt64(model.Status), UserId = onlineUser.Id, TablePositionLeft = model.TablePositionLeft, TablePositionTop = model.TablePositionTop, Duration = model.Duration, ReservationNote = model.ReservationNote, CreatedOn = DateTime.UtcNow, UpdatedBy = onlineUser.Id, UpdatedOn = DateTime.UtcNow }; if (server != null && server.ServerId != null) { reservation.ReservationServer = new ReservationServer() { ServerId = server.ServerId.Value }; } context.tabReservations.Add(reservation); if (!string.IsNullOrEmpty(model.GuestNote)) { customer.Notes = model.GuestNote; } if (!string.IsNullOrEmpty(model.Email)) { if (customer.Emails == null || (customer.Emails != null && !customer.Emails.Any(ce => ce.Email.Contains(model.Email)))) { var cemail = new CustomersEmails() { CustomerId = customer.CustomerId, Email = model.Email, EmailTypeId = 1 }; context.tabCustomersEmails.Add(cemail); } } time = reservation.TimeForm.TimeOfDay.TotalMinutes; context.LogAddReservation(reservation, onlineUser, null); } #endregion #region new customer else { var cust = new Customers() { FirstName = model.FirstName, LastName = model.LastName, DateCreated = DateTime.UtcNow, //.ToClientTime(), DateOfBirth = DateTime.UtcNow, //.ToClientTime(), Address1 = "1", Address2 = "2", Anniversary = DateTime.UtcNow //.ToClientTime(), }; context.tabCustomers.Add(cust); if (!string.IsNullOrEmpty(model.Email)) { var cemail = new CustomersEmails() { CustomerId = cust.CustomerId, Email = model.Email, EmailTypeId = 1 }; context.tabCustomersEmails.Add(cemail); } var cphone = new CustomersPhoneNumbers() { CustomerId = cust.CustomerId, PhoneNumbers = model.MobileNumber, PhoneTypeId = 1 }; context.tabCustomersPhoneNumbers.Add(cphone); reservation = new Reservation() { FloorPlanId = model.FloorPlanId, Covers = model.Covers, CustomerId = cust.CustomerId, FoodMenuShiftId = model.ShiftId, ReservationDate = model.resDate, TimeForm = startTime, TimeTo = startTime.AddMinutes(model.Duration.GetMinutesFromDuration()), FloorTableId = fTblId, MergedFloorTableId = model.MergeTableId.Value, StatusId = Convert.ToInt64(model.Status), UserId = onlineUser.Id, TablePositionLeft = model.TablePositionLeft, TablePositionTop = model.TablePositionTop, Duration = model.Duration, ReservationNote = model.ReservationNote, CreatedOn = DateTime.UtcNow, UpdatedBy = onlineUser.Id, UpdatedOn = DateTime.UtcNow }; if (server != null && server.ServerId != null) { reservation.ReservationServer = new ReservationServer() { ServerId = server.ServerId.Value }; } context.tabReservations.Add(reservation); if (!string.IsNullOrEmpty(model.GuestNote)) { cust.Notes = model.GuestNote; } time = reservation.TimeForm.TimeOfDay.TotalMinutes; context.LogAddReservation(reservation, onlineUser, null); } #endregion context.SaveChanges(); _wfmService.SendCustomerBookingSuccess(this.Url, reservation,context); return Redirect(this.Url.EncodedUrl("ReserveSuccess", "Online", new { id = reservation.ReservationId, company = context.Database.Connection.Database })); } catch (SmtpException) { return Redirect(this.Url.EncodedUrl("ReserveSuccess", "Online", new { id = reservation.ReservationId ,company=context.Database.Connection.Database})); } catch (Exception) { return RedirectToAction("ReserveFail", new { id = 2, company = context.Database.Connection.Database }); } finally { this.ClearReservationCache(context.Database.Connection.Database); } }
public ActionResult FloorPlan(ReservationVM obj) { var UTCDate = DateTime.UtcNow; var isEditMode = false; var clientDate = TimeZoneInfo.ConvertTime(DateTime.UtcNow, db.GetDefaultTimeZone()); if (obj.ReservationId != 0) { var res = db.tabReservations.Where(r => !r.IsDeleted).SingleOrDefault(r => r.ReservationId == obj.ReservationId); var resObj = new ReservationVM { ReservationId = obj.ReservationId, Covers = res.Covers, Duration = res.Duration, Email = ((res.Customers.Emails.Count() > 0) ? res.Customers.Emails.First().Email : string.Empty), FirstName = res.Customers.FirstName, LastName = res.Customers.LastName, MobileNumber = res.Customers.PhoneNumbers.First().PhoneNumbers, resDate = res.ReservationDate, ShiftId = res.FoodMenuShiftId, Status = res.StatusId.ToString(), tableIdd = res.FloorTableId.ToString(), TablePositionLeft = res.TablePositionLeft, TablePositionTop = res.TablePositionTop, FloorPlanId = ((res.FloorTableId > 0) ? db.tabFloorTables.Find(res.FloorTableId).FloorPlanId : db.tabMergedFloorTables.Find(res.MergedFloorTableId).FloorPlanId), MergeTableId = res.MergedFloorTableId }; var day = res.ReservationDate.DayOfWeek; var dId = db.GetWeekDays().Single(p => p.DayName.Trim() == day.ToString().Trim()).DayId; //var dId = db.tabWeekDays.AsEnumerable().Single(p => p.DayName.Trim() == day.ToString().Trim()).DayId; var aa = db.GetMenuShiftHours().Where(p => p.DayId == dId); //var aa = db.tabMenuShiftHours.AsEnumerable().Where(p => p.DayId == dId); var startTime = DateTime.Now.Date.Add(res.TimeForm.TimeOfDay); var open = new DateTime(); var close = new DateTime(); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out open) && DateTime.TryParse(s.CloseAt, out close)) && startTime.Date.Add(open.TimeOfDay) <= startTime && startTime.Date.Add(close.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); resObj.time = new DateTime().Add(res.TimeForm.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(res.TimeForm.AddMinutes(15).TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + timeShift.FoodMenuShiftId; ViewBag.ResModel = resObj; obj.FloorPlanId = resObj.FloorPlanId; isEditMode = true; } else if (obj.resDate.Year == DateTime.UtcNow.ToDefaultTimeZone(User.Identity.GetDatabaseName()).Year) //else if (obj.resDate.Year == DateTime.UtcNow.ToClientTime().Year) { obj.FloorPlanId = 1; ViewBag.ResModel = obj; isEditMode = true; } else { obj.FloorPlanId = 1; } ViewBag.shiftDdl = new SelectList(db.tabFoodMenuShift, "FoodMenuShiftId", "MenuShift"); var floorPlans = db.tabFloorPlans; var rec = floorPlans.Include("FloorTables").Where(p => p.FloorPlanId == obj.FloorPlanId).SingleOrDefault(); ViewBag.IsEditMode = isEditMode; ViewBag.maxCoverLimit = db.GetMaxFloorCovers(); if (rec != null) { ViewBag.Floors = floorPlans; return View(rec); } else { return RedirectToAction("Index", "Floor"); } }
public PartialViewResult GetCustomerDetailPartial(ReservationVM model) { Customers customer = null; if (!string.IsNullOrEmpty(model.MobileNumber) && long.Parse(model.MobileNumber) != 0) { var phno = model.MobileNumber.Trim(); customer = db.tabCustomers.Where(c => c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Equals(model.MobileNumber))).FirstOrDefault(); } else if (model.ReservationId > 0) { customer = db.tabCustomers.Where(c => c.Reservations.Any(r => r.ReservationId == model.ReservationId)).SingleOrDefault(); } return PartialView("~/Views/FloorPlan/AddReservationCustomerDetailPartial.cshtml", customer); }
//private IList<FloorTable> InitializeAddResOptionsNew(ReservationVM model, bool isDateChanged = false, bool considerFloor = false, bool isMerging = false) //{ // int maxCoversLimit = db.GetMaxFloorCovers(); // ViewBag.StatusList = db.GetStatusList(); // ViewBag.ShiftList = db.GetFoodMenuShifts(); // ViewBag.LevelList = db.tabFloorPlans.ToList().Select(fp => new // { // Text = "L" + fp.FLevel.Value + "-" + fp.FloorName, // Value = fp.FloorPlanId // }); // var coverList = new List<object>(); // for (int i = 1; i <= 30; i++) // { // coverList.Add(new { Value = i, Text = i + " Cover" }); // } // ViewBag.CoverList = coverList; // //ViewBag.DurationList = new List<string>() { "15MIN", "30MIN", "45MIN", "1HR", "1HR 30MIN", "2HR", "2HR 30MIN", "3HR", "3HR 30MIN", "4HR" }; // ViewBag.DurationList = this.GetDurationList("15MIN", "4HR"); // if (string.IsNullOrEmpty(model.Duration)) // { // model.Duration = "1HR 30MIN"; // } // // code for getting time list // var day = model.resDate.DayOfWeek.ToString().Trim(); // int sId = model.ShiftId; // var dId = db.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId; // var openTime = new DateTime(); // var closeTime = new DateTime(); // //if (sId != 0) // //{ // // var ttime = db.tabMenuShiftHours.Single(p => p.DayId == dId && p.FoodMenuShiftId == sId); // // openTime = Convert.ToDateTime(ttime.OpenAt); // // closeTime = Convert.ToDateTime(ttime.CloseAt).AddDays(Convert.ToInt32(ttime.IsNext)); // //} // //else // //{ // 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); // if (!string.IsNullOrEmpty(model.Duration)) // { // closeTime = closeTime.AddMinutes(-(model.Duration.GetMinutesFromDuration() - 15)); // } // //} // var op = openTime; // var cl = closeTime; // var TimeList = new List<object>(); // var aa = db.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); // while (op < cl) // { // var startTime = op; // op = op.AddMinutes(15); // int tShiftId = 0; // //var timeShift = aa.Where(s => Convert.ToDateTime(s.OpenAt) <= startTime && Convert.ToDateTime(s.CloseAt).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); // var openTM = new DateTime(); // var closeTM = new DateTime(); // var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && // startTime.Date.Add(openTM.TimeOfDay) <= startTime && // startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); // if (timeShift != null) // { // tShiftId = timeShift.FoodMenuShiftId; // } // TimeList.Add(new // { // Text = startTime.ToString("hh:mm tt"), // Value = new DateTime().Add(startTime.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(op.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + tShiftId // }); // } // ViewBag.TimeList = TimeList; // // end of code for getting time list // if (isDateChanged || string.IsNullOrEmpty(model.time)) // { // model.time = ((dynamic)TimeList[0]).Value; // } // // code to get tables list // var tt = model.time.Split('-'); // var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); // var endTime = new DateTime(); // if (string.IsNullOrEmpty(model.Duration)) // { // endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); // } // else // { // endTime = startTm.AddMinutes(model.Duration.GetMinutesFromDuration()); // } // var reservation = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); // if (reservation != null) // { // model.EdtTableId = reservation.FloorTableId; // } // IList<FloorTable> table = null; // var array = new string[] { "Sofa", "Chair", "SofaTable", "Wall", "SolidWall", "GlassWall", "BarTable", "Fence", "Pillar" }; // if (considerFloor) // { // if (model.FloorPlanId == 0) // { // model.FloorPlanId = 1; // } // maxCoversLimit = db.GetMaxFloorCovers(model.FloorPlanId); // var floorPlan = db.tabFloorPlans.Include("FloorTables").Where(f => f.FloorPlanId == model.FloorPlanId).Single(); // table = floorPlan.FloorTables.Where(t => t.IsDeleted == false).AsEnumerable().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); // } // else // { // table = db.tabFloorTables.Where(t => t.IsDeleted == false).ToList().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); // } // //var sid = Db.tabFoodMenuShift.Single(p => p.MenuShift == shift).FoodMenuShiftId; // var resList = db.GetReservationByDate(model.resDate); // var rejectedTables = new List<long>(); // // check if status is FINISHED, CANCELLED, CANCELLED2 // var rejectedStatus = new List<long>() // { // ReservationStatus.Finished, // ReservationStatus.Cancelled // //ReservationStatus.Cancelled_2 // }; // resList = resList.Where(r => !rejectedStatus.Contains(r.StatusId.Value)).ToList(); // if (reservation != null) // { // resList = resList.Where(r => r.ReservationId != reservation.ReservationId).ToList(); // if (reservation.ReservationDate.Date == model.resDate.Date && startTm == reservation.TimeForm && reservation.Duration.Trim() == model.Duration.Trim()) // { // if (reservation.MergedFloorTableId > 0) // { // var orgTables = reservation.MergedFloorTable.OrigionalTables.Select(ot => ot.FloorTable).ToList(); // ViewBag.SelectedTables = orgTables; // } // } // } // foreach (var item in resList) // { // var resStart = item.TimeForm; // var resEnd = item.TimeForm.AddMinutes(item.Duration.GetMinutesFromDuration()); // if ((resStart <= startTm && resEnd >= endTime) || (resStart >= startTm && resEnd <= endTime) || (resStart < startTm && resEnd > startTm) || (resStart < endTime && resEnd > endTime)) //(resStart >= startTm && resStart < endTime) || (resEnd <= endTime && resEnd > startTm) // { // if (item.FloorTableId == 0 && item.MergedFloorTableId > 0) // { // foreach (var origionalTbl in item.MergedFloorTable.OrigionalTables) // { // rejectedTables.Add(origionalTbl.FloorTableId); // } // } // else // { // rejectedTables.Add(item.FloorTableId); // } // } // } // foreach (var tbl in table) // { // if (tbl.MaxCover < model.Covers) // { // if (!rejectedTables.Contains(tbl.FloorTableId)) // { // rejectedTables.Add(tbl.FloorTableId); // } // } // } // table = table.Where(t => !rejectedTables.Contains(t.FloorTableId)).ToList(); // // Ends here // if (model.Covers == 0) // { // model.Covers = 1; // } // //if (model.ShiftId == 0) // //{ // model.ShiftId = Convert.ToInt32(tt[2]); // //} // if (string.IsNullOrEmpty(model.Status)) // { // model.Status = ReservationStatus.Not_confirmed.ToString(); // } // if (string.IsNullOrEmpty(model.tableIdd) || !table.Any(t => t.FloorTableId == Convert.ToInt64(model.tableIdd))) // { // if (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) // table != null && table.Count() > 0 // { // model.tableIdd = table.First().FloorTableId.ToString(); // } // else // { // model.tableIdd = "0"; // ViewBag.LevelList = new List<object>() // { // new // { // Text = "-No Level-", // Value = 0 // } // }; // } // } // var fTblId = Convert.ToInt64(model.tableIdd); // if (!isMerging) // { // model.FloorPlanId = (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) ? db.tabFloorTables.Find(fTblId).FloorPlanId : 0; // } // if (model.MergeTableId.HasValue && model.MergeTableId.Value > 0) // (table == null || table.Count() == 0) && // { // var mergedTable = db.tabMergedFloorTables.Find(model.MergeTableId.Value); // var flrTable = new FloorTable // { // FloorTableId = 0, // TableName = mergedTable.TableName // }; // table = new List<FloorTable>() // { // new FloorTable // { // FloorTableId = 0, // TableName = mergedTable.TableName, // FloorPlan = mergedTable.FloorPlan, // MinCover = mergedTable.MinCover, // MaxCover = mergedTable.MaxCover // } // }; // ViewBag.LevelList = new List<object>() // { // new // { // Text = "L" + mergedTable.FloorPlan.FLevel.Value + "-" + mergedTable.FloorPlan.FloorName, // Value = 0 // } // }; // } // ViewBag.MaxAvailCovers = maxCoversLimit; // return table.OrderBy(t => t.FloorPlan.FLevel).ThenBy(t => t.TableName, new AlphaNumericComparer()).ToList(); //} //private IList<FloorTable> InitializeAddResOptionsNew20150224(ReservationVM model, bool isDateChanged = false, bool considerFloor = false, bool isMerging = false) //{ // int maxCoversLimit = db.GetMaxFloorCovers(); // ViewBag.StatusList = db.GetStatusList(); // ViewBag.ShiftList = db.GetFoodMenuShifts(); // ViewBag.LevelList = db.tabFloorPlans.ToList().Select(fp => new // { // Text = "L" + fp.FLevel.Value + "-" + fp.FloorName, // Value = fp.FloorPlanId // }); // var coverList = new List<object>(); // for (int i = 1; i <= 30; i++) // { // coverList.Add(new { Value = i, Text = i + " Cover" }); // } // ViewBag.CoverList = coverList; // ViewBag.DurationList = this.GetDurationList("15MIN", "4HR"); // if (string.IsNullOrEmpty(model.Duration)) // { // //model.Duration = "1HR 30MIN"; // model.Duration = "2HR"; //2015-07-01 Leigh's request // } // // code for getting time list // var day = model.resDate.DayOfWeek.ToString().Trim(); // int sId = model.ShiftId; // 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); // if (!string.IsNullOrEmpty(model.Duration)) // { // closeTime = closeTime.AddMinutes(-(model.Duration.GetMinutesFromDuration() - 15)); // } // var op = openTime; // var cl = closeTime; // var TimeList = new List<object>(); // var aa = db.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); // while (op < cl) // { // var startTime = op; // op = op.AddMinutes(15); // int tShiftId = 0; // var openTM = new DateTime(); // var closeTM = new DateTime(); // var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && // startTime.Date.Add(openTM.TimeOfDay) <= startTime && // startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); // if (timeShift != null) // { // tShiftId = timeShift.FoodMenuShiftId; // } // TimeList.Add(new // { // Text = startTime.ToString("hh:mm tt"), // Value = new DateTime().Add(startTime.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(op.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + tShiftId // }); // } // ViewBag.TimeList = TimeList; // // end of code for getting time list // if (isDateChanged || string.IsNullOrEmpty(model.time)) // { // model.time = ((dynamic)TimeList[0]).Value; // } // // code to get tables list // var tt = model.time.Split('-'); // var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); // var endTime = new DateTime(); // if (string.IsNullOrEmpty(model.Duration)) // { // endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); // } // else // { // endTime = startTm.AddMinutes(model.Duration.GetMinutesFromDuration()); // } // var reservation = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); // if (reservation != null) // { // model.EdtTableId = reservation.FloorTableId; // } // IList<FloorTable> table = null; // var array = new string[] { "Sofa", "Chair", "SofaTable", "Wall", "SolidWall", "GlassWall", "BarTable", "Fence", "Pillar" }; // if (considerFloor) // { // if (model.FloorPlanId == 0) // { // model.FloorPlanId = 1; // } // maxCoversLimit = db.GetMaxFloorCovers(model.FloorPlanId); // var floorPlan = db.tabFloorPlans.Include("FloorTables").Where(f => f.FloorPlanId == model.FloorPlanId).Single(); // table = floorPlan.FloorTables.Where(t => t.IsDeleted == false).AsEnumerable().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); // } // else // { // table = db.tabFloorTables.Where(t => t.IsDeleted == false).ToList().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); // } // var resList = db.GetReservationByDate(model.resDate); // var rejectedTables = new List<long>(); // // check if status is FINISHED, CANCELLED, CANCELLED2 // var rejectedStatus = new List<long>() // { // ReservationStatus.Finished, // ReservationStatus.Cancelled // //ReservationStatus.Cancelled_2 // }; // resList = resList.Where(r => !rejectedStatus.Contains(r.StatusId.Value)).ToList(); // if (reservation != null) // { // resList = resList.Where(r => r.ReservationId != reservation.ReservationId).ToList(); // if (reservation.ReservationDate.Date == model.resDate.Date && startTm == reservation.TimeForm && reservation.Duration.Trim() == model.Duration.Trim()) // { // if (reservation.MergedFloorTableId > 0) // { // var orgTables = reservation.MergedFloorTable.OrigionalTables.Select(ot => ot.FloorTable).ToList(); // ViewBag.SelectedTables = orgTables; // } // } // } // foreach (var item in resList) // { // var resStart = item.TimeForm; // var resEnd = item.TimeForm.AddMinutes(item.Duration.GetMinutesFromDuration()); // if ((resStart <= startTm && resEnd >= endTime) // || (resStart >= startTm && resEnd <= endTime) // || (resStart < startTm && resEnd > startTm) // || (resStart < endTime && resEnd > endTime)) //(resStart >= startTm && resStart < endTime) || (resEnd <= endTime && resEnd > startTm) // { // if (item.FloorTableId == 0 && item.MergedFloorTableId > 0) // { // foreach (var origionalTbl in item.MergedFloorTable.OrigionalTables) // { // rejectedTables.Add(origionalTbl.FloorTableId); // } // } // else // { // rejectedTables.Add(item.FloorTableId); // } // } // } // if (table != null && table.Count() > 0) // maxCoversLimit = table.Where(t => !rejectedTables.Contains(t.FloorTableId)).Max(t => t.MaxCover); // foreach (var tbl in table) // { // if (tbl.MaxCover < model.Covers) // { // if (!rejectedTables.Contains(tbl.FloorTableId)) // { // rejectedTables.Add(tbl.FloorTableId); // } // } // } // table = table.Where(t => !rejectedTables.Contains(t.FloorTableId)).ToList(); // /**** Table availability feature enabled start here *****/ // var availList = db.tabTableAvailabilities // .Include("TableAvailabilityFloorTables") // .Include("TableAvailabilityWeekDays") // .Where(ta => ta.StartDate <= model.resDate && model.resDate <= ta.EndDate // && ta.TableAvailabilityWeekDays.Any(taw => taw.DayId == dId)).ToList(); // var blockList = db.GetFloorTableBlockTimeList(model.resDate); // table = table.Where(t => !availList.CheckAvailStatus(model.resDate, startTm, endTime, t, 2) // && !blockList.IsTableBlocked(t.FloorTableId, startTm, endTime)).ToList(); // /**** Table availability feature enabled end here *****/ // // Ends here // if (model.Covers == 0) // { // model.Covers = 1; // } // model.ShiftId = Convert.ToInt32(tt[2]); // if (string.IsNullOrEmpty(model.Status)) // { // model.Status = ReservationStatus.Not_confirmed.ToString(); // } // if (string.IsNullOrEmpty(model.tableIdd) || !table.Any(t => t.FloorTableId == Convert.ToInt64(model.tableIdd))) // { // if (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) // { // model.tableIdd = table.First().FloorTableId.ToString(); // } // else // { // model.tableIdd = "0"; // ViewBag.LevelList = new List<object>() // { // new // { // Text = "-No Level-", // Value = 0 // } // }; // } // } // var fTblId = Convert.ToInt64(model.tableIdd); // if (!isMerging) // { // if (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) // { // model.FloorPlanId = db.tabFloorTables.Find(fTblId).FloorPlanId; // } // else // model.FloorPlanId = 0; // // } // if (model.MergeTableId.HasValue && model.MergeTableId.Value > 0) // { // var mergedTable = db.tabMergedFloorTables.Find(model.MergeTableId.Value); // var flrTable = new FloorTable // { // FloorTableId = 0, // TableName = mergedTable.TableName // }; // table = new List<FloorTable>() // { // new FloorTable // { // FloorTableId = 0, // TableName = mergedTable.TableName, // FloorPlan = mergedTable.FloorPlan, // MinCover = mergedTable.MinCover, // MaxCover = mergedTable.MaxCover // } // }; // ViewBag.LevelList = new List<object>() // { // new // { // Text = "L" + mergedTable.FloorPlan.FLevel.Value + "-" + mergedTable.FloorPlan.FloorName, // Value = 0 // } // }; // } // ViewBag.MaxAvailCovers = maxCoversLimit; // return table.OrderBy(t => t.FloorPlan.FLevel).ThenBy(t => t.TableName, new AlphaNumericComparer()).ToList(); //} private IList<FloorTable> InitializeAddResOptionsNew20150512(ReservationVM model, bool isDateChanged = false, bool considerFloor = false, bool isMerging = false) { int maxCoversLimit = db.GetMaxFloorCovers(); ViewBag.StatusList = db.GetStatusList(); ViewBag.ShiftList = db.GetFoodMenuShifts(); ViewBag.LevelList = db.tabFloorPlans.ToList().Select(fp => new { Text = "L" + fp.FLevel.Value + "-" + fp.FloorName, Value = fp.FloorPlanId }); var coverList = new List<object>(); for (int i = 1; i <= 30; i++) { coverList.Add(new { Value = i, Text = i + " Cover" }); } ViewBag.CoverList = coverList; ViewBag.DurationList = this.GetDurationList("15MIN", "4HR"); if (string.IsNullOrEmpty(model.Duration)) { model.Duration = "1HR 30MIN"; //model.Duration = "2HR"; //2015-07-01 Leigh's request } // code for getting time list var day = model.resDate.DayOfWeek.ToString().Trim(); int sId = model.ShiftId; 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); if (!string.IsNullOrEmpty(model.Duration)) { closeTime = closeTime.AddMinutes(-(model.Duration.GetMinutesFromDuration() - 15)); } var op = openTime; var cl = closeTime; var TimeList = new List<object>(); var aa = db.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); while (op < cl) { var startTime = op; op = op.AddMinutes(15); int tShiftId = 0; var openTM = new DateTime(); var closeTM = new DateTime(); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && startTime.Date.Add(openTM.TimeOfDay) <= startTime && startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { tShiftId = timeShift.FoodMenuShiftId; } TimeList.Add(new { Text = startTime.ToString("hh:mm tt"), Value = new DateTime().Add(startTime.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(op.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + tShiftId }); } ViewBag.TimeList = TimeList; // end of code for getting time list if (isDateChanged || string.IsNullOrEmpty(model.time)) { model.time = ((dynamic)TimeList[0]).Value; } // code to get tables list var tt = model.time.Split('-'); var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = new DateTime(); if (string.IsNullOrEmpty(model.Duration)) { endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); } else { endTime = startTm.AddMinutes(model.Duration.GetMinutesFromDuration()); } var reservation = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); if (reservation != null) { model.EdtTableId = reservation.FloorTableId; } IList<FloorTable> table = null; var array = new string[] { "Sofa", "Chair", "SofaTable", "Wall", "SolidWall", "GlassWall", "BarTable", "Fence", "Pillar" }; if (considerFloor) { if (model.FloorPlanId == 0) { model.FloorPlanId = 1; } maxCoversLimit = db.GetMaxFloorCovers(model.FloorPlanId); var floorPlan = db.tabFloorPlans.Include("FloorTables").Where(f => f.FloorPlanId == model.FloorPlanId).Single(); table = floorPlan.FloorTables.Where(t => t.IsDeleted == false).AsEnumerable().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); } else { table = db.tabFloorTables.Where(t => t.IsDeleted == false).ToList().Where(t => !array.Contains(t.TableName.Split('-')[0])).ToList(); } var resList = db.GetReservationByDate(model.resDate); var rejectedTables = new List<long>(); // check if status is FINISHED, CANCELLED, CANCELLED2 var rejectedStatus = new List<long>() { ReservationStatus.Finished, ReservationStatus.Cancelled //ReservationStatus.Cancelled_2 }; resList = resList.Where(r => !rejectedStatus.Contains(r.StatusId.Value)).ToList(); if (reservation != null) { resList = resList.Where(r => r.ReservationId != reservation.ReservationId).ToList(); if (reservation.ReservationDate.Date == model.resDate.Date && startTm == reservation.TimeForm && reservation.Duration.Trim() == model.Duration.Trim()) { if (reservation.MergedFloorTableId > 0) { var orgTables = reservation.MergedFloorTable.OrigionalTables.Select(ot => ot.FloorTable).ToList(); ViewBag.SelectedTables = orgTables; } } } foreach (var item in resList) { var resStart = item.TimeForm; var resEnd = item.TimeForm.AddMinutes(item.Duration.GetMinutesFromDuration()); if ((resStart <= startTm && resEnd >= endTime) || (resStart >= startTm && resEnd <= endTime) || (resStart < startTm && resEnd > startTm) || (resStart < endTime && resEnd > endTime)) //(resStart >= startTm && resStart < endTime) || (resEnd <= endTime && resEnd > startTm) { if (item.FloorTableId == 0 && item.MergedFloorTableId > 0) { foreach (var origionalTbl in item.MergedFloorTable.OrigionalTables) { rejectedTables.Add(origionalTbl.FloorTableId); } } else { rejectedTables.Add(item.FloorTableId); } } } /**** Enable Merge table feature enabled start here *****/ var isManualMerge = false; if (model.enableMerging) { foreach (var tbl in table) { if (tbl.MaxCover >= model.Covers && !rejectedTables.Contains(tbl.FloorTableId)) { rejectedTables.Add(tbl.FloorTableId); isManualMerge = true; } } } /**** Enable Merge table feature enabled end here *****/ if (table != null && table.Count() > 0) maxCoversLimit = table.Where(t => !rejectedTables.Contains(t.FloorTableId)).Any() ? table.Where(t => !rejectedTables.Contains(t.FloorTableId)).Max(t => t.MaxCover) : 1; foreach (var tbl in table) { if (tbl.MaxCover < model.Covers) { if (!rejectedTables.Contains(tbl.FloorTableId)) { rejectedTables.Add(tbl.FloorTableId); } } } table = table.Where(t => !rejectedTables.Contains(t.FloorTableId)).ToList(); /**** Table availability feature enabled start here *****/ var availList = db.tabTableAvailabilities .Include("TableAvailabilityFloorTables") .Include("TableAvailabilityWeekDays") .Where(ta => ta.StartDate <= model.resDate && model.resDate <= ta.EndDate && ta.TableAvailabilityWeekDays.Any(taw => taw.DayId == dId)).ToList(); var blockList = db.GetFloorTableBlockTimeList(model.resDate); table = table.Where(t => !availList.CheckAvailStatus(model.resDate, startTm, endTime, t, 2) && !blockList.IsTableBlocked(t.FloorTableId, startTm, endTime)).ToList(); /**** Table availability feature enabled end here *****/ // Ends here if (model.Covers == 0) { model.Covers = 1; } model.ShiftId = Convert.ToInt32(tt[2]); if (string.IsNullOrEmpty(model.Status)) { model.Status = ReservationStatus.Not_confirmed.ToString(); } if (string.IsNullOrEmpty(model.tableIdd) || !table.Any(t => t.FloorTableId == Convert.ToInt64(model.tableIdd))) { if (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) { model.tableIdd = table.First().FloorTableId.ToString(); } else { model.tableIdd = "0"; ViewBag.LevelList = new List<object>() { new { Text = "-No Level-", Value = 0 } }; } } var fTblId = Convert.ToInt64(model.tableIdd); if (!isMerging) { if (table != null && table.Count() > 0 && model.Covers <= maxCoversLimit) { model.FloorPlanId = db.tabFloorTables.Find(fTblId).FloorPlanId; } else model.FloorPlanId = 0; // } else { } if (model.MergeTableId.HasValue && model.MergeTableId.Value > 0) { var mergedTable = db.tabMergedFloorTables.Find(model.MergeTableId.Value); var flrTable = new FloorTable { FloorTableId = 0, TableName = mergedTable.TableName }; table = new List<FloorTable>() { new FloorTable { FloorTableId = 0, TableName = mergedTable.TableName, FloorPlan = mergedTable.FloorPlan, MinCover = mergedTable.MinCover, MaxCover = mergedTable.MaxCover } }; ViewBag.LevelList = new List<object>() { new { Text = "L" + mergedTable.FloorPlan.FLevel.Value + "-" + mergedTable.FloorPlan.FloorName, Value = 0 } }; } ViewBag.MaxAvailCovers = maxCoversLimit; ViewBag.IsAutoMerge = !isManualMerge && (maxCoversLimit < model.Covers); return table.OrderBy(t => t.FloorPlan.FLevel).ThenBy(t => t.TableName, new AlphaNumericComparer()).ToList(); }
public ActionResult UpdateReservationWithPIN(ReservationVM model) { Reservation resDb = null; try { var loginUser = db.Users.Find(User.Identity.GetUserId<long>()); UserProfile pinUser = null; if ((model.PIN.HasValue || loginUser.EnablePIN) && !model.MobileNumber.Contains("9999999999")) { pinUser = db.Users.Where(u => u.UserCode == model.PIN.Value).FirstOrDefault(); if (pinUser == null) { return Json(new { Status = ResponseStatus.Fail, Message = "Please enter a valid user PIN." }, JsonRequestBehavior.AllowGet); } } var fTblId = Convert.ToInt64(model.tableIdd); if (fTblId == 0 && model.MergeTableId == 0) { return Json(new { Status = ResponseStatus.Fail, Message = "Please select a table." }, JsonRequestBehavior.AllowGet); } else { if (fTblId > 0) { model.FloorPlanId = db.tabFloorTables.Find(fTblId).FloorPlanId; model.MergeTableId = 0; } else { model.FloorPlanId = db.tabMergedFloorTables.Find(model.MergeTableId.Value).FloorPlanId; } } if (!string.IsNullOrEmpty(model.time)) { var tt = model.time.Split('-'); var startTime = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var sftId = Convert.ToInt32(tt[2]); resDb = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); resDb.Covers = model.Covers; resDb.Duration = model.Duration; resDb.FoodMenuShiftId = sftId; resDb.ReservationDate = model.resDate; resDb.StatusId = Convert.ToInt32(model.Status); resDb.FoodMenuShiftId = model.ShiftId; resDb.TimeForm = startTime; resDb.TimeTo = startTime.AddMinutes(model.Duration.GetMinutesFromDuration()); resDb.FloorTableId = fTblId; resDb.MergedFloorTableId = model.MergeTableId.Value; resDb.ReservationNote = model.ReservationNote; resDb.UpdatedBy = User.Identity.GetUserId<long>(); resDb.UpdatedOn = DateTime.UtcNow; if (!string.IsNullOrEmpty(model.TablePositionTop) && !string.IsNullOrEmpty(model.TablePositionLeft)) { resDb.TablePositionTop = model.TablePositionTop; resDb.TablePositionLeft = model.TablePositionLeft; } if (!string.IsNullOrEmpty(model.GuestNote)) { resDb.Customers.Notes = model.GuestNote; } //var floorId = db.tabFloorTables.Find(resDb.FloorTableId).FloorPlanId; //resDb.FloorPlanId = floorId; resDb.FloorPlanId = model.FloorPlanId; db.Entry(resDb).State = System.Data.Entity.EntityState.Modified; db.LogEditReservation(resDb, loginUser, pinUser); db.SaveChanges(); var listItem = GetReservationListItem(resDb.ReservationId); return Json(new { Status = ResponseStatus.Success, Message = "Reservation updated successfully...", ListItem = listItem, Time = resDb.TimeForm.TimeOfDay.TotalMinutes }, JsonRequestBehavior.AllowGet); } else { throw new ArgumentNullException("Time"); } } catch (Exception ex) { return Json(new { Status = ResponseStatus.Fail, Message = ex.Message }, JsonRequestBehavior.AllowGet); } finally { this.ClearReservationCache(resDb != null ? (DateTime?)resDb.ReservationDate : null); } }
public ActionResult SaveReservationWithPIN(ReservationVM model) { try { var loginUser = db.Users.Find(User.Identity.GetUserId<long>()); UserProfile pinUser = null; Waiting waiting = null; if ((model.PIN.HasValue || loginUser.EnablePIN) && !model.MobileNumber.Contains("9999999999")) { pinUser = db.Users.Where(u => u.UserCode == model.PIN.Value).FirstOrDefault(); if (pinUser == null) { return Json(new { Status = ResponseStatus.Fail, Message = "Please enter a valid user PIN." }, JsonRequestBehavior.AllowGet); } } FloorTableServer server = null; var fTblId = Convert.ToInt64(model.tableIdd); if (fTblId == 0 && model.MergeTableId == 0) { return Json(new { Status = ResponseStatus.Fail, Message = "Please select a table." }, JsonRequestBehavior.AllowGet); } else { if (fTblId > 0) { var flrTbl = db.tabFloorTables.Find(fTblId); model.FloorPlanId = flrTbl.FloorPlanId; model.MergeTableId = 0; server = flrTbl.FloorTableServer; } else { model.FloorPlanId = db.tabMergedFloorTables.Find(model.MergeTableId.Value).FloorPlanId; } } double time = 0; long resId = 0; if (!string.IsNullOrEmpty(model.Email)) { model.Email = model.Email.Trim(); } model.MobileNumber = model.MobileNumber.Trim(); // model.ShiftId = model.ShiftId; var tt = model.time.Split('-'); var startTime = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); bool isFakeMobileNo = long.Parse(model.MobileNumber) == 0L; if (model.WaitingId > 0) { waiting = db.tabWaitings.Find(model.WaitingId); } var customer = db.tabCustomers.Where(c => !isFakeMobileNo && c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Contains(model.MobileNumber))).FirstOrDefault(); if (isFakeMobileNo && waiting != null) { customer = waiting.Customer; customer.FirstName = model.FirstName; customer.LastName = model.LastName; } model.ShiftId = Convert.ToInt32(tt[2]); model.Status = (!string.IsNullOrEmpty(model.Status)) ? model.Status : ReservationStatus.Not_confirmed.ToString(); if (customer != null) { var reservation = new Reservation() { FloorPlanId = model.FloorPlanId, Covers = model.Covers, CustomerId = customer.CustomerId, FoodMenuShiftId = model.ShiftId, ReservationDate = model.resDate, TimeForm = startTime, TimeTo = startTime.AddMinutes(model.Duration.GetMinutesFromDuration()), FloorTableId = fTblId, MergedFloorTableId = model.MergeTableId.Value, StatusId = Convert.ToInt64(model.Status), UserId = User.Identity.GetUserId<long>(), TablePositionLeft = model.TablePositionLeft, TablePositionTop = model.TablePositionTop, Duration = model.Duration, ReservationNote = model.ReservationNote, CreatedOn = DateTime.UtcNow, UpdatedBy = User.Identity.GetUserId<long>(), UpdatedOn = DateTime.UtcNow }; if (server != null && server.ServerId != null) { reservation.ReservationServer = new ReservationServer() { ServerId = server.ServerId.Value }; } db.tabReservations.Add(reservation); if (!string.IsNullOrEmpty(model.GuestNote)) { customer.Notes = model.GuestNote; } if (!string.IsNullOrEmpty(model.Email)) { if (customer.Emails == null || (customer.Emails != null && !customer.Emails.Any(ce => ce.Email.Contains(model.Email)))) { var cemail = new CustomersEmails() { CustomerId = customer.CustomerId, Email = model.Email, EmailTypeId = 1 }; db.tabCustomersEmails.Add(cemail); } } time = reservation.TimeForm.TimeOfDay.TotalMinutes; db.LogAddReservation(reservation, loginUser, pinUser); } else { var cust = new Customers() { FirstName = model.FirstName, LastName = model.LastName, DateCreated = DateTime.UtcNow.ToDefaultTimeZone(User.Identity.GetDatabaseName()), DateOfBirth = DateTime.UtcNow.ToDefaultTimeZone(User.Identity.GetDatabaseName()), Address1 = "1", Address2 = "2", Anniversary = DateTime.UtcNow.ToDefaultTimeZone(User.Identity.GetDatabaseName()), }; db.tabCustomers.Add(cust); if (!string.IsNullOrEmpty(model.Email)) { var cemail = new CustomersEmails() { CustomerId = cust.CustomerId, Email = model.Email, EmailTypeId = 1 }; db.tabCustomersEmails.Add(cemail); } var cphone = new CustomersPhoneNumbers() { CustomerId = cust.CustomerId, PhoneNumbers = model.MobileNumber, PhoneTypeId = 1 }; db.tabCustomersPhoneNumbers.Add(cphone); var reservation = new Reservation() { FloorPlanId = model.FloorPlanId, Covers = model.Covers, CustomerId = cust.CustomerId, FoodMenuShiftId = model.ShiftId, ReservationDate = model.resDate, TimeForm = startTime, TimeTo = startTime.AddMinutes(model.Duration.GetMinutesFromDuration()), FloorTableId = fTblId, MergedFloorTableId = model.MergeTableId.Value, StatusId = Convert.ToInt64(model.Status), UserId = User.Identity.GetUserId<long>(), TablePositionLeft = model.TablePositionLeft, TablePositionTop = model.TablePositionTop, Duration = model.Duration, ReservationNote = model.ReservationNote, CreatedOn = DateTime.UtcNow, UpdatedBy = User.Identity.GetUserId<long>(), UpdatedOn = DateTime.UtcNow }; if (server != null && server.ServerId != null) { reservation.ReservationServer = new ReservationServer() { ServerId = server.ServerId.Value }; } db.tabReservations.Add(reservation); if (!string.IsNullOrEmpty(model.GuestNote)) { cust.Notes = model.GuestNote; } time = reservation.TimeForm.TimeOfDay.TotalMinutes; db.LogAddReservation(reservation, loginUser, pinUser); } if (waiting != null) { waiting.ReservationId = resId; db.Entry(waiting).State = EntityState.Modified; ClearWaitingCache(); } db.SaveChanges(); return Json(new { Status = ResponseStatus.Success, Message = "Reservation saved successfully.", Time = time }, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(new { Status = ResponseStatus.Fail, Message = "Failed to save reservation, please try later..." }, JsonRequestBehavior.AllowGet); } finally { this.ClearReservationCache(model.resDate); } }
public ActionResult QuickUpdateReservationTable(Int64 resId, Int64 tableId, string top, string left) { Reservation res = null; try { var loginUser = db.Users.Find(User.Identity.GetUserId<long>()); var tables = new List<FloorTable>(); res = db.tabReservations.Single(r => !r.IsDeleted && r.ReservationId == resId); var model = new ReservationVM { ReservationId = res.ReservationId, resDate = res.ReservationDate, Duration = res.Duration, Covers = res.Covers, time = new DateTime().Add(res.TimeForm.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(res.TimeForm.AddMinutes(15).TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + res.FoodMenuShiftId }; IList<Int64> upcomingTableIds; IList<Int64> smallTableIds; tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false).ToList(); if (!tables.Any(t => t.FloorTableId == tableId)) { return Json(new { Status = ResponseStatus.Fail, Message = "Sorry, this table is not available for update. Please select another table." }, JsonRequestBehavior.AllowGet); } res.FloorTableId = tableId; if (!string.IsNullOrEmpty(top) && !string.IsNullOrEmpty(left)) { res.TablePositionTop = top; res.TablePositionLeft = left; } db.Entry(res).State = EntityState.Modified; db.LogEditReservation(res, loginUser, null); db.SaveChanges(); return Json(new { Status = ResponseStatus.Success, Message = "Reservation updated successfully...", }, JsonRequestBehavior.AllowGet); } catch (Exception ex) { return Json(new { Status = ResponseStatus.Fail, Message = ex.Message }, JsonRequestBehavior.AllowGet); } finally { this.ClearReservationCache(res != null ? (DateTime?)res.ReservationDate : null); } }
public static IList<object> GetTimeListForReservation(this UsersContext db, ReservationVM model) { var day = model.resDate.DayOfWeek; int sId = model.ShiftId; var dId = db.tabWeekDays.AsEnumerable().Single(p => p.DayName.Trim() == day.ToString().Trim()).DayId; var openTime = new DateTime(); var closeTime = new DateTime(); var ttime = db.tabMenuShiftHours.Where(p => p.DayId == dId).AsEnumerable(); openTime = Convert.ToDateTime(ttime.Min(p => Convert.ToDateTime(p.OpenAt))); closeTime = Convert.ToDateTime(ttime.Max(p => Convert.ToDateTime(p.CloseAt).AddDays(Convert.ToInt32(p.IsNext)))); if (!string.IsNullOrEmpty(model.Duration)) { closeTime = closeTime.AddMinutes(-(model.Duration.GetMinutesFromDuration() - 15)); } var op = openTime; var cl = closeTime; var TimeList = new List<object>(); var aa = db.tabMenuShiftHours.AsEnumerable().Where(p => p.DayId == dId); while (op < cl) { var startTime = op; op = op.AddMinutes(15); int tShiftId = 0; var timeShift = aa.Where(s => Convert.ToDateTime(s.OpenAt) <= startTime && Convert.ToDateTime(s.CloseAt).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { tShiftId = timeShift.FoodMenuShiftId; } TimeList.Add(new { Text = startTime.ToString("hh:mm tt"), Value = new DateTime().Add(startTime.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(op.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + tShiftId }); } return TimeList; }
public ActionResult Update(ReservationVM model) { var resDb = context.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); try { var clientTime = DateTime.UtcNow.ToDefaultTimeZone(CompanyName); //.ToClientTime(); if (resDb == null || resDb.StatusId == ReservationStatus.Cancelled) { return RedirectToAction("ReserveFail", new { id = 4 , company = context.Database.Connection.Database}); } if (!IsOnlineUser(resDb.UserId)) { return RedirectToAction("ReserveFail", new { id = 6, company = context.Database.Connection.Database }); } if (resDb.ReservationDate < clientTime.Date || clientTime > resDb.TimeForm.AddHours(-2)) { return RedirectToAction("ReserveFail", new { id = 5, company = context.Database.Connection.Database }); } var onlineUserName = context.Users.Where(c => c.Roles.Any(ur => ur.RoleId == context.Roles.Where(r => r.Name == "Online").FirstOrDefault().Id)).Single().UserName; var onlineUser = context.Users.Where(u => u.UserName.Contains(onlineUserName)).First(); var fTblId = Convert.ToInt64(model.tableIdd); var floorTbl = context.tabFloorTables.Find(fTblId); model.FloorPlanId = floorTbl.FloorPlanId; model.MergeTableId = 0; var startTime = model.resDate.Add(DateTime.ParseExact(model.time.Trim(), "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = startTime.AddMinutes(15); int tShiftId = 0; var openTM = new DateTime(); var closeTM = new DateTime(); var day = model.resDate.DayOfWeek.ToString(); var dId = context.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId; var aa = context.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && startTime.Date.Add(openTM.TimeOfDay) <= startTime && startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { tShiftId = timeShift.FoodMenuShiftId; } model.ShiftId = tShiftId; resDb.Covers = model.Covers; resDb.FoodMenuShiftId = model.ShiftId; resDb.ReservationDate = model.resDate; resDb.TimeForm = startTime; resDb.TimeTo = startTime.AddMinutes(defaultDuration); resDb.Duration = "0MIN".AddMinutesToDuration(defaultDuration); resDb.FloorTableId = fTblId; resDb.TablePositionLeft = floorTbl.TLeft; resDb.TablePositionTop = floorTbl.TTop; //resDb.ReservationNote = model.ReservationNote; resDb.UpdatedBy = onlineUser.Id; resDb.UpdatedOn = DateTime.UtcNow; resDb.FloorPlanId = model.FloorPlanId; context.Entry(resDb).State = System.Data.Entity.EntityState.Modified; context.LogEditReservation(resDb, onlineUser, null); context.SaveChanges(); _wfmService.SendCustomerBookingSuccess(this.Url, resDb,context); return Redirect(this.Url.EncodedUrl("ReserveSuccess", "Online", new { id = resDb.ReservationId, company = context.Database.Connection.Database })); } catch (SmtpException) { return Redirect(this.Url.EncodedUrl("ReserveSuccess", "Online", new { id = resDb.ReservationId, company = context.Database.Connection.Database })); } catch (Exception) { return RedirectToAction("ReserveFail", new { id = 2, company = context.Database.Connection.Database }); } finally { this.ClearReservationCache(context.Database.Connection.Database); } }
public PartialViewResult GetAddResAdditionalDetailPartial(ReservationVM model) { if (!string.IsNullOrEmpty(model.MobileNumber)) { var phno = model.MobileNumber.Trim(); ViewBag.AddResCustModel = db.tabCustomers.Where(c => c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Equals(model.MobileNumber))).FirstOrDefault(); } else { ViewBag.AddResCustModel = null; } return PartialView("~/Views/FloorPlan/AddReservationAdditionalDetailPartial.cshtml", model); }
public static IEnumerable<FloorTable> GetAvailableFloorTables(this UsersContext db, Reservation reservation, out IList<Int64> upcomingTableIds, out IList<Int64> smallTableIds, out ReservationVM model, bool considerFloor = false, bool considerCovers = true, long ExceptionalMergeTableId = 0) { model = new ReservationVM { ReservationId = reservation.ReservationId, resDate = reservation.ReservationDate, Duration = reservation.Duration, Covers = reservation.Covers, time = new DateTime().Add(reservation.TimeForm.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(reservation.TimeForm.AddMinutes(15).TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + reservation.FoodMenuShiftId }; return db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, considerFloor, considerCovers, ExceptionalMergeTableId); }
public PartialViewResult GetAddReservtionPartial(ReservationVM model, bool isMobileSource = false, bool isWalkIn = false) { ModelState.Clear(); DateTime resStartTime = new DateTime(); if (model.ReservationId > 0) { var res = db.tabReservations.Where(r => !r.IsDeleted).SingleOrDefault(r => r.ReservationId == model.ReservationId); model.Covers = res.Covers; model.Duration = res.Duration; model.Email = ((res.Customers.Emails.Count() > 0) ? res.Customers.Emails.First().Email : string.Empty); model.FirstName = res.Customers.FirstName; model.LastName = res.Customers.LastName; model.MobileNumber = res.Customers.PhoneNumbers.First().PhoneNumbers; model.resDate = res.ReservationDate; model.ShiftId = res.FoodMenuShiftId; model.Status = res.StatusId.ToString(); model.tableIdd = res.FloorTableId.ToString(); model.TablePositionLeft = res.TablePositionLeft; model.TablePositionTop = res.TablePositionTop; model.ReservationNote = res.ReservationNote; model.MergeTableId = res.MergedFloorTableId; model.FloorPlanId = res.FloorTableId == 0 ? db.tabMergedFloorTables.Find(res.MergedFloorTableId).FloorPlanId : db.tabFloorTables.Find(res.FloorTableId).FloorPlanId; model.enableMerging = res.FloorTableId == 0; resStartTime = res.TimeForm; } if (model.ReservationId == 0 && !DateTime.TryParse(model.time, out resStartTime)) { //var currentClientDateTime = DateTime.UtcNow.ToClientTime(); var currentClientDateTime = DateTime.UtcNow.ToDefaultTimeZone(User.Identity.GetDatabaseName()); currentClientDateTime = currentClientDateTime.AddMinutes(15 - (currentClientDateTime.TimeOfDay.Minutes % 15)); resStartTime = currentClientDateTime; if (string.IsNullOrWhiteSpace(model.MobileNumber)) model.MobileNumber = "0000000000"; } else if (model.ReservationId == 0) { resStartTime = resStartTime.AddMinutes(15); model.MobileNumber = "0000000000"; } if (isWalkIn && model.ReservationId == 0) { model.MobileNumber = "9999999999"; model.FirstName = "WalkIn"; model.LastName = "Guest"; model.Status = ReservationStatus.Seated.ToString(); } var day = model.resDate.DayOfWeek; var dId = db.tabWeekDays.AsEnumerable().Single(p => p.DayName.Trim() == day.ToString().Trim()).DayId; var aa = db.tabMenuShiftHours.AsEnumerable().Where(p => p.DayId == dId); //var startTime = DateTime.UtcNow.ToClientTime().Date.Add(resStartTime.TimeOfDay); var startTime = DateTime.Now.Date.Add(resStartTime.TimeOfDay); var open = new DateTime(); var close = new DateTime(); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out open) && DateTime.TryParse(s.CloseAt, out close)) && startTime.Date.Add(open.TimeOfDay) <= startTime && startTime.Date.Add(close.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { model.time = new DateTime().Add(resStartTime.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(resStartTime.AddMinutes(15).TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + timeShift.FoodMenuShiftId; } else { model.time = null; } var user = db.Users.Find(User.Identity.GetUserId<long>()); ViewBag.UserPin = user.EnablePIN; if (!isMobileSource) { return PartialView("~/Views/FloorPlan/FloorRightAddReservationPartial.cshtml", model); } else { return PartialView("~/Views/Book/MobileAddReservationPartial.cshtml", model); } }
public PartialViewResult UpdateAddReservationOptions(ReservationVM model, bool isDateChanged = false, bool considerFloor = false, bool isMerging = false, bool isMobileSource = false) { ModelState.Clear(); //var table = InitializeAddResOptionsNew(model, isDateChanged, considerFloor, isMerging); var table = InitializeAddResOptionsNew20150512(model, isDateChanged, considerFloor, isMerging); bool anyTable = (table != null && table.Count() > 0); var Tables = (table != null && table.Count() > 0) ? (table.Select(p => new { Id = p.FloorTableId, Name = "L" + p.FloorPlan.FLevel + "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0" + p.TableName + "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0(" + p.MinCover + "/" + p.MaxCover + ")" }).ToList<object>()) : (new List<object>() { new { Id = 0, Name = "No Table" } }); ViewBag.TableList = Tables; ViewBag.TableCount = anyTable ? Tables.Count() : 0; //if (model.MergeTableId.HasValue && model.MergeTableId.Value > 0) //{ // var originalTables = db.tabMergedTableOrigionalTables.Where(mot => mot.MergedFloorTableId == model.MergeTableId.Value).Select(ot => ot.FloorTable).ToList(); // ViewBag.SelectedTables = originalTables; //} // end of code to get tables list if (!isMobileSource) { return PartialView("~/Views/FloorPlan/AddReservationOptionsPartial.cshtml", model); } else { int maxAvailCovers = db.GetMaxFloorCovers(); var coverList = new List<object>(); for (int i = 1; i <= maxAvailCovers; i++) { coverList.Add(new { Value = i, Text = i + " Cover" }); } ViewBag.CoverList = coverList; return PartialView("~/Views/Book/MobileAddReservationOptionsPartial.cshtml", model); } }
public JsonResult GetAvailableTablesForUpdate(Int64 resId) { var tables = new List<FloorTable>(); var res = db.tabReservations.Single(r => !r.IsDeleted && r.ReservationId == resId); var model = new ReservationVM { ReservationId = res.ReservationId, resDate = res.ReservationDate, Duration = res.Duration, Covers = res.Covers, time = new DateTime().Add(res.TimeForm.TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + new DateTime().Add(res.TimeForm.AddMinutes(15).TimeOfDay).ToString("ddMMyyyyhhmmtt") + " - " + res.FoodMenuShiftId }; IList<Int64> upcomingTableIds; IList<Int64> smallTableIds; tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, true).ToList(); var data = new { currentTableId = res.FloorTableId, currentTableName = res.FloorTable.TableName, availTables = tables.Select(x => new { tableId = x.FloorTableId, tableName = x.TableName + " (" + x.MinCover + "/" + x.MaxCover + ")", minCovers = x.MinCover, maxCovers = x.MaxCover }).ToList(), upcomingTableIds = upcomingTableIds, smallTableIds = smallTableIds }; return Json(data, JsonRequestBehavior.AllowGet); }
public static IEnumerable<FloorTable> GetAvailableFloorTables(this UsersContext db, ReservationVM model, out IList<Int64> upcomingTableIds, out IList<Int64> smallTableIds, bool considerFloor = false, bool considerCovers = true, long ExceptionalMergeTableId = 0) { IEnumerable<FloorTable> tables = null; var rejectedTables = new List<long>(); upcomingTableIds = new List<Int64>(); smallTableIds = new List<Int64>(); // code to get tables list var tt = model.time.Split('-'); var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = new DateTime(); if (string.IsNullOrEmpty(model.Duration)) { endTime = model.resDate.Add(DateTime.ParseExact(tt[1].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); } else { endTime = startTm.AddMinutes(model.Duration.GetMinutesFromDuration()); } var reservation = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); if (reservation != null) { model.EdtTableId = reservation.FloorTableId; } var array = new string[] { "Sofa", "Chair", "SofaTable", "Wall", "SolidWall", "GlassWall", "BarTable", "Fence", "Pillar" }; if (considerFloor) { if (model.FloorPlanId == 0) { model.FloorPlanId = 1; } var floorPlan = db.tabFloorPlans.Include("FloorTables").Where(f => f.FloorPlanId == model.FloorPlanId).Single(); tables = floorPlan.FloorTables.Where(t => t.IsDeleted == false).AsEnumerable().Where(t => !array.Contains(t.TableName.Split('-')[0])); } else { tables = db.tabFloorTables.Where(t => t.IsDeleted == false).ToList().Where(t => !array.Contains(t.TableName.Split('-')[0])); } var resList = db.tabReservations.Where(r => !r.IsDeleted && r.ReservationDate == model.resDate ).ToList(); // check if status is FINISHED, CANCELLED, CANCELLED2 var rejectedStatus = new List<long>() { ReservationStatus.Finished, ReservationStatus.Cancelled //ReservationStatus.Cancelled_2 }; resList = resList.Where(r => !rejectedStatus.Contains(r.StatusId.Value)).ToList(); foreach (var item in resList) { var resStart = item.TimeForm; var resEnd = item.TimeForm.AddMinutes(item.Duration.GetMinutesFromDuration()); if ((resStart <= startTm && resEnd >= endTime) || (resStart >= startTm && resEnd <= endTime) || (resStart < startTm && resEnd > startTm) || (resStart < endTime && resEnd > endTime)) //((resStart >= startTm && resStart < endTime) || (resEnd <= endTime && resEnd > startTm)) { if (item.FloorTableId == 0 && item.MergedFloorTableId > 0 && ExceptionalMergeTableId != item.MergedFloorTableId) { // mergedtables = item.MergedFloorTable.OrigionalTables.Select(ot => ot.FloorTable).ToList(); foreach (var origionalTbl in item.MergedFloorTable.OrigionalTables) { //rejectedTables.Add(origionalTbl.FloorTableId); upcomingTableIds.Add(origionalTbl.FloorTableId); } } else { //rejectedTables.Add(item.FloorTableId); upcomingTableIds.Add(item.FloorTableId); } } } if (reservation != null) { if (reservation.ReservationDate.Date == model.resDate.Date && startTm == reservation.TimeForm && reservation.Duration.Trim() == model.Duration.Trim()) { //rejectedTables.Remove(reservation.FloorTableId); upcomingTableIds.Remove(reservation.FloorTableId); } } if (considerCovers) { foreach (var tbl in tables) { if (tbl.MaxCover < model.Covers) { //if (!rejectedTables.Contains(tbl.FloorTableId)) if (!smallTableIds.Contains(tbl.FloorTableId) && !upcomingTableIds.Contains(tbl.FloorTableId)) { //rejectedTables.Add(tbl.FloorTableId); smallTableIds.Add(tbl.FloorTableId); } } } } //if (model.enableMerging) //{ // foreach (var tbl in tables) // { // if (tbl.MaxCover >= model.Covers && !rejectedTables.Contains(tbl.FloorTableId)) // { // rejectedTables.Add(tbl.FloorTableId); // } // } //} rejectedTables.AddRange(upcomingTableIds); rejectedTables.AddRange(smallTableIds); tables = tables.Where(t => !rejectedTables.Contains(t.FloorTableId)); return tables; }
public PartialViewResult GetCustomerVisits(ReservationVM model) { Customers customer = null; if (!string.IsNullOrEmpty(model.MobileNumber)) { var phno = model.MobileNumber.Trim(); customer = db.tabCustomers.Where(c => c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Equals(model.MobileNumber))).FirstOrDefault(); } return PartialView("~/Views/FloorPlan/AddReservationCustomerVisitsPartial.cshtml", customer); }
public ActionResult GetTablesFreeToMerge(ReservationVM model) { ModelState.Clear(); this.UpdateReservationModel(model); IList<Int64> upcomingTableIds; IList<Int64> smallTableIds; var tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false); var data = tables.Select(x => new CheckListVM() { PropertyName = "selectedTables", Name = x.TableName + " (" + x.MinCover + "/" + x.MaxCover + ")", Value = x.FloorTableId, IsChecked = false, IsDisabled = false }); return PartialView("~/Views/TableAvailablity/CheckboxListPartial.cshtml", data); }
//public PartialViewResult GetWaitingReservationList(GetReservationsParamVM model) //{ // var ResList = this.GetFilteredReservations(model); // ViewBag.Covers = 0; // if (ResList != null && ResList.Count() > 0) // { // var coversCount = ResList.Sum(r => r.Covers); // ViewBag.Covers = coversCount; // } // return PartialView("~/Views/FloorPlan/ReservationListPartial.cshtml", ResList.ToList()); //} //public PartialViewResult GetStaffReservationList(GetReservationsParamVM model) //{ // var ResList = this.GetFilteredReservations(model); // ViewBag.Covers = 0; // if (ResList != null && ResList.Count() > 0) // { // var coversCount = ResList.Sum(r => r.Covers); // ViewBag.Covers = coversCount; // } // return PartialView("~/Views/FloorPlan/ReservationListPartial.cshtml", ResList.ToList()); //} public PartialViewResult UpdateAddReservationAdditionalOptions(ReservationVM model, bool isMerging = false) { ModelState.Clear(); //var table = InitializeAddResOptionsNew(model, considerFloor: true, isMerging: isMerging); var table = InitializeAddResOptionsNew20150512(model, considerFloor: true, isMerging: isMerging); ViewBag.TableList = (table != null && table.Count() > 0) ? (table.Select(p => new { Id = p.FloorTableId, Name = p.TableName + "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0(" + p.MinCover + "/" + p.MaxCover + ")" }).ToList<object>()) : (new List<object>() { new { Id = 0, Name = "No Table" } }); // end of code to get tables list return PartialView("~/Views/FloorPlan/AddReservationAdditionalOptionsPartial.cshtml", model); }
public ActionResult Reserve(DateTime date, string time, int covers) { //if (Request.UrlReferrer.LocalPath.ToLower().Contains("fail")) // return RedirectToAction("Index"); var startTime = date.Add(DateTime.ParseExact(time.Trim(), "h:mm tt", CultureInfo.InvariantCulture).TimeOfDay); var endTime = startTime.AddMinutes(defaultDuration); var array = new string[] { "Sofa", "Chair", "SofaTable", "Wall", "SolidWall", "GlassWall", "BarTable", "Fence", "Pillar" }; var tableDB = context.tabFloorTables.Where(p => p.IsDeleted == false).ToList() .Where(p => !array.Contains(p.TableName.Split('-')[0]) && p.MaxCover >= covers).ToList(); var day = date.DayOfWeek.ToString(); var dId = context.GetWeekDays().Single(p => p.DayName.Contains(day)).DayId; var availList = context.tabTableAvailabilities .Include("TableAvailabilityFloorTables") .Include("TableAvailabilityWeekDays") .Where(ta => ta.StartDate <= date && date <= ta.EndDate && ta.TableAvailabilityWeekDays.Any(taw => taw.DayId == dId)).ToList(); ViewBag.BlockId = Guid.Empty; var exactMatchedDBTables = tableDB.Where(t => availList.CheckAvailStatus(date, startTime, endTime, t, 1) && !AnyReservation(t.FloorTableId, startTime, endTime)).ToList(); if (exactMatchedDBTables.Count == 0) return View(); var firstAvailTable = exactMatchedDBTables.First(); int tShiftId = 0; var openTM = new DateTime(); var closeTM = new DateTime(); var aa = context.GetMenuShiftHours().AsEnumerable().Where(p => p.DayId == dId); var timeShift = aa.Where(s => (DateTime.TryParse(s.OpenAt, out openTM) && DateTime.TryParse(s.CloseAt, out closeTM)) && startTime.Date.Add(openTM.TimeOfDay) <= startTime && startTime.Date.Add(closeTM.TimeOfDay).AddDays(s.IsNext.Value) >= startTime).FirstOrDefault(); if (timeShift != null) { tShiftId = timeShift.FoodMenuShiftId; } var model = new ReservationVM { resDate = date, time = time, Covers = covers, tableIdd = firstAvailTable.FloorTableId.ToString(), TablePositionLeft = firstAvailTable.TLeft, TablePositionTop = firstAvailTable.TTop, ShiftId = tShiftId, //Duration = "15MIN" Duration = "0MIN".AddMinutesToDuration(defaultDuration) }; var blockTime = new FloorTableBlock { FloorTableBlockId = Guid.NewGuid(), BlockDate = date, BlockFrom = startTime, BlockTo = endTime, FloorTableId = firstAvailTable.FloorTableId }; context.tabFloorTableBlocks.Add(blockTime); context.SaveChanges(); ViewBag.BlockId = blockTime.FloorTableBlockId; this.ClearReservationCache(context.Database.Connection.Database); return View(model); }
public PartialViewResult UpdateEditReservationPopUpOptions(ReservationVM model) { ModelState.Clear(); //var table = InitializeAddResOptionsNew(model, considerFloor: true); var table = InitializeAddResOptionsNew20150512(model, considerFloor: true); bool anyTable = (table != null && table.Count() > 0); var Tables = (table != null && table.Count() > 0) ? (table.Select(p => new { Id = p.FloorTableId, Name = p.TableName + "\xA0\xA0\xA0\xA0\xA0\xA0\xA0\xA0(" + p.MinCover + "/" + p.MaxCover + ")" }).ToList<object>()) : (new List<object>() { new { Id = 0, Name = "No Table" } }); ViewBag.TableList = Tables; ViewBag.TableCount = anyTable ? Tables.Count() : 0; // end of code to get tables list return PartialView("~/Views/FloorPlan/ReservationEditPopupOptionsPartial.cshtml", model); }
public JsonResult GetJSONTablesFreeToMerge(ReservationVM model) { ModelState.Clear(); this.CleanUpTempMergeTable(); this.UpdateReservationModel(model); IList<Int64> upcomingTableIds; IList<Int64> smallTableIds; var tables = new List<FloorTable>(); var mergedtablesList = new List<FloorTable>(); if (model.ReservationId > 0) { var tt = model.time.Split('-'); var startTm = model.resDate.Add(DateTime.ParseExact(tt[0].Trim(), "ddMMyyyyhhmmtt", CultureInfo.InvariantCulture).TimeOfDay); var reservation = db.tabReservations.SingleOrDefault(r => !r.IsDeleted && r.ReservationId == model.ReservationId); if (reservation != null) { if (reservation.MergedFloorTableId > 0 && reservation.ReservationDate.Date == model.resDate.Date && startTm == reservation.TimeForm && reservation.Duration.Trim() == model.Duration.Trim()) { mergedtablesList = db.tabMergedFloorTables.Find(reservation.MergedFloorTableId).OrigionalTables.Select(ot => ot.FloorTable).ToList(); tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false).ToList(); } else if (reservation.MergedFloorTableId > 0) { tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false, reservation.MergedFloorTableId).ToList(); mergedtablesList = new List<FloorTable>(); } else { tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false).ToList(); } } else { tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false).ToList(); } } else { tables = db.GetAvailableFloorTables(model, out upcomingTableIds, out smallTableIds, true, false).ToList(); } var data = new { availTables = tables.Select(x => new { tableId = x.FloorTableId, tableName = x.TableName + " (" + x.MinCover + "/" + x.MaxCover + ")", minCovers = x.MinCover, maxCovers = x.MaxCover }).ToList(), mergedTables = mergedtablesList.Select(x => new { tableId = x.FloorTableId, tableName = x.TableName + " (" + x.MinCover + "/" + x.MaxCover + ")", minCovers = x.MinCover, maxCovers = x.MaxCover }).ToList() }; return Json(data, JsonRequestBehavior.AllowGet); }