Пример #1
0
        public ActionResult ChangeRoomAndReservationMapping(Guid reservationId, Guid roomId, Guid roomTypeId, DateTime?date)
        {
            try
            {
                var reservationDetail = reservationRepository.GetReservationById(reservationId, LogInManager.LoggedInUserId).FirstOrDefault();

                if (reservationDetail != null)
                {
                    DateTime?arrivalDate = null, departureDate = null;
                    if (date.HasValue)
                    {
                        var noOfNight = reservationDetail.NoOfNight;

                        arrivalDate   = date.Value;
                        departureDate = date.Value.AddDays(noOfNight);
                    }

                    //Update dates in Reservation, ReservationLog, CheckInCheckOutDetail Tables & RoomId into ReservationLog, ReservationRoomMapping Tables.
                    var id = roomRepository.ChangeRoomAndReservationMappingDetails(reservationId, roomId, roomTypeId, arrivalDate, departureDate, LogInManager.LoggedInUserId);

                    return(Json(new
                    {
                        IsSuccess = true,
                        ReservationId = id
                    }));
                }
                else
                {
                    return(Json(new
                    {
                        IsSuccess = false,
                        errorMessage = "Reservation details not exist"
                    }));
                }
            }
            catch (Exception e)
            {
                Utility.Utility.LogError(e, "ChangeRoomAndReservationMapping");
                return(Json(new
                {
                    IsSuccess = false,
                    errorMessage = e.Message
                }));
            }
        }