Ejemplo n.º 1
0
        public async Task <IActionResult> BookRoom(AddReservationDto addReservationDto)
        {
            if (!ModelState.IsValid)
            {
                foreach (var model in ModelState.Values)
                {
                    foreach (var error in model.Errors)
                    {
                        Console.WriteLine(error.ErrorMessage);
                    }
                }
                return(RedirectToAction("BookRoom", "Reservation", new { roomId = addReservationDto.RoomId }));
            }
            var reservationId = await _reservationService.AddReservationAsync(addReservationDto);

            foreach (var bookedService in addReservationDto.MinuteServices)
            {
                await _reservationService.AssignMinuteServiceAsync(new AddMinuteServiceToReservationDto()
                {
                    ReservationId   = reservationId,
                    MinuteServiceId = bookedService.MinuteServiceId,
                    Duration        = bookedService.Duration
                });
            }

            return(RedirectToAction("Manage", "Reservation", new { reservationId = reservationId }));
        }