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

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

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

            return(View("Details"));
        }