示例#1
0
        public IActionResult CreateSeance([FromBody] SeanceInfo seance)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(new Response(ModelState)));
            }

            if (_seanceService.CheckHallExists(seance.HallId))
            {
                return(BadRequest(new Response(ErrorOfHallNonexistence)));
            }

            if (_seanceService.CheckCorrectSeanceTime(seance))
            {
                return(BadRequest(new Response(ErrorOfSeanceTime)));
            }

            if (_seanceService.CheckSeanceExists(seance))
            {
                return(BadRequest(new Response(ErrorOfSeanceExistence)));
            }

            if (_seanceService.СheckForNonmatchingSeanceTime(seance))
            {
                return(BadRequest(new Response(ErrorOfNonmatchingSeanceTime)));
            }

            if (_seanceService.CheckCorrectMovie(seance))
            {
                return(BadRequest(new Response(ErrorOfMovieNonexistence)));
            }

            int id = _seanceService.CreateSeance(seance);

            var response = new CreateResponse(id);

            return(CreatedAtAction(nameof(GetSeance), new { id = response.Id }, response));
        }