示例#1
0
        public IActionResult BookMovie([FromBody] BookingDto booking)
        {
            if (booking == null)
            {
                return(BadRequest());
            }
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }
            if (booking.SeatNo.Split(',').Count() > 5)
            {
                return(StatusCode(405, new { message = "More than 5 seats are not allowed." }));
            }

            int bookedId = _bookingRepository.BookMovieInMultiplex(booking);

            if (bookedId <= 0)
            {
                return(StatusCode(500, "A problem happened while handling your request"));
            }

            return(Created("bookingDetails", new { id = bookedId }));
        }