public ActionResult GetAddToWaiting(WaitingVM model) { var coverList = new List<object>(); for (int i = 1; i <= 16; i++) { coverList.Add(new { Value = i, Text = i + " Cover" }); } ViewBag.CoverList = coverList; model.MobileNumber = "0000000000"; return PartialView("AddToWaitListPartial", model); }
public ActionResult SaveWaiting(WaitingVM model) { try { bool isFakeMobileNo = long.Parse(model.MobileNumber) == 0L; if (!string.IsNullOrEmpty(model.Email)) { model.Email = model.Email.Trim(); } model.MobileNumber = model.MobileNumber.Trim(); var customer = db.tabCustomers.Where(c => !isFakeMobileNo && c.PhoneNumbers.Any(cn => cn.PhoneNumbers.Contains(model.MobileNumber))).FirstOrDefault(); if (customer != null) { var waiting = new Waiting() { Covers = model.Covers, CustomerId = customer.CustomerId, WaitingDate = model.WaitDate, Notes = model.Notes, CreatedOn = DateTime.UtcNow }; db.tabWaitings.Add(waiting); } else { var cust = new Customers() { FirstName = model.FirstName, LastName = model.LastName, DateCreated = DateTime.UtcNow, DateOfBirth = DateTime.UtcNow, Address1 = "1", Address2 = "2", Anniversary = DateTime.UtcNow, }; 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 waiting = new Waiting() { Covers = model.Covers, CustomerId = cust.CustomerId, WaitingDate = model.WaitDate, Notes = model.Notes, CreatedOn = DateTime.UtcNow }; db.tabWaitings.Add(waiting); } db.SaveChanges(); ClearWaitingCache(); return Json(new { Status = ResponseStatus.Success, Message = "Waitlist updated successfully.", }, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(new { Status = ResponseStatus.Fail, Message = "Failed to add waitlist booking, please try later..." }, JsonRequestBehavior.AllowGet); } }
public ActionResult UpdateWaiting(WaitingVM model) { try { var waiting = db.tabWaitings.Find(model.WaitingId); waiting.Covers = model.Covers; waiting.Notes = model.Notes; if (!string.IsNullOrEmpty(model.GuestNote)) { waiting.Customer.Notes = model.GuestNote; } db.SaveChanges(); ClearWaitingCache(); return Json(new { Status = ResponseStatus.Success, Message = "Waitlist updated successfully.", }, JsonRequestBehavior.AllowGet); } catch (Exception) { return Json(new { Status = ResponseStatus.Fail, Message = "Failed to update waitlist booking, please try later..." }, JsonRequestBehavior.AllowGet); } }