Example #1
0
        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"));
        }
Example #2
0
        public IHttpActionResult Post(ShowCreate show)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            ShowService showService = CreateShowService();

            if (!showService.CreateShow(show))
            {
                return(InternalServerError());
            }
            return(Ok());
        }
Example #3
0
        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"));
        }
Example #4
0
        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));
        }
Example #5
0
        public ActionResult Create(CreateShowViewModel viewModel)
        {
            if (!ModelState.IsValid)
            {
                return(View(viewModel));
            }

            try
            {
                ShowService.CreateShow(viewModel);
            }
            catch (Exception)
            {
                throw;
            }

            return(View("Details"));
        }