public ActionResult CreateShow(ShowModel show) { if (show.Title == null || show.Seats <= 0 || show.Day == null) { TempData["error"] = "all fields are mandatory"; return(View()); } if (show.Seats > Constants.Rows * Constants.Seats) { TempData["error"] = "maximum number of seats is " + Constants.Rows * Constants.Seats; return(View()); } if (showService.GetShowByDay(show.Day) != null) { TempData["error"] = "There is a show that day"; return(View()); } showService.CreateShow(show); return(RedirectToAction("Shows")); }
public IHttpActionResult Post(ShowCreate show) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } ShowService showService = CreateShowService(); if (!showService.CreateShow(show)) { return(InternalServerError()); } return(Ok()); }
public ActionResult Create(ShowCreate model) { if (!ModelState.IsValid) { return(View(model)); } var userId = Guid.Parse(User.Identity.GetUserId()); var service = new ShowService(userId); service.CreateShow(model); return(RedirectToAction("Index")); }
public ActionResult Create(ShowCreate model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "Could not add show, please make sure all fields are filled"); return(View(model)); } ShowService service = new ShowService(); if (service.CreateShow(model)) { return(RedirectToAction("AllShows")); } return(View(model)); }
public ActionResult Create(CreateShowViewModel viewModel) { if (!ModelState.IsValid) { return(View(viewModel)); } try { ShowService.CreateShow(viewModel); } catch (Exception) { throw; } return(View("Details")); }