예제 #1
0
        public IActionResult CreateHall([FromBody] HallInfo hall, int cinemaId)
        {
            if (!_сinemaService.CheckCinemaExists(cinemaId))
            {
                return(NotFound(new Response(ErrorOfCinemaNonexistence)));
            }

            if (_сinemaService.CheckHallExists(cinemaId, hall))
            {
                return(NotFound(new Response(ErrorOfHallExistence)));
            }

            if (!ModelState.IsValid)
            {
                return(BadRequest(new Response(ModelState)));
            }

            var id = _сinemaService.CreateHall(cinemaId, hall);

            var response = new CreateResponse(id);

            return(CreatedAtAction(nameof(GetHall), new { cinemaId, hallId = response.Id }, response));
        }