public ActionResult Create([Bind(Include = "bookingRuleId,organizationID,daysInAdvance,numOfBookings,numOfStrikes,dayStart,bookingLength")] BookingRule bookingRule) { if (Session["currentUser"] == null) { TempData["message"] = "Please login to continue."; return(RedirectToAction("VerifyLogin")); } if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1) { TempData["message"] = "You must be an administrator to access this page."; return(RedirectToAction("VerifyLogin", "Login")); } try { if (ModelState.IsValid) { db.BookingRules.Add(bookingRule); db.SaveChanges(); return(RedirectToAction("Index")); } } catch { TempData["Message"] = "ERROR - Please try again"; return(View()); } return(View(bookingRule)); }
public BookingRuleDataset(BookingRule bookingRule, string account) { this.LookupText = bookingRule.LookupText; this.LookupValue = bookingRule.LookupValue; this.BookingText = bookingRule.BookingText; this.Id = bookingRule.Id; this.AccountId = bookingRule.AccountId; this.Account = account; }
/// <summary> /// Save a booking rule (insert/update) /// </summary> public void SaveBookingRule(BookingRule bookingRule) { var bookingRules = GetBookingRuleList(); var existingRule = bookingRules.FirstOrDefault(a => a.Id == bookingRule.Id); if (existingRule == null) { existingRule = new BookingRule(); bookingRules.Add(existingRule); bookingRule.Id = Guid.NewGuid().ToString(); } bookingRule.Copy(existingRule); Save(bookingRules, BOOKING_RULES); }
public ActionResult DeleteConfirmed(int id) { if (Session["currentUser"] == null) { TempData["message"] = "Please login to continue."; return(RedirectToAction("VerifyLogin")); } if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1) { TempData["message"] = "You must be an administrator to access this page."; return(RedirectToAction("VerifyLogin", "Login")); } BookingRule bookingRule = db.BookingRules.Find(id); db.BookingRules.Remove(bookingRule); db.SaveChanges(); return(RedirectToAction("Index")); }
// GET: BookingRules/Details/5 public ActionResult Details(int?id) { if (Session["currentUser"] == null) { TempData["message"] = "Please login to continue."; return(RedirectToAction("VerifyLogin")); } if (((TotalSquashNext.Models.User)Session["currentUser"]).accountId != 1) { TempData["message"] = "You must be an administrator to access this page."; return(RedirectToAction("VerifyLogin", "Login")); } if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } BookingRule bookingRule = db.BookingRules.Find(id); if (bookingRule == null) { return(HttpNotFound()); } return(View(bookingRule)); }
public JsonResult Save([FromBody] BookingRule bookingRule) { bookingRuleRepository.SaveBookingRule(bookingRule); return(new JsonResult("")); }