public ActionResult CheckOutGuestCreateDebtorAccount(int?id, int?roomId, int?companyId) { var guest = _guestService.GetById(id.Value); var company = _businessAccountService.GetById(companyId.Value); if (companyId.Value > 0) { var guestBalance = guest.GetGuestBalance(); //At some point record the refund if any made to guest var reservationIds = guest.GuestReservations.Select(x => x.Id).ToList(); var guestRoomsIds = guest.GuestRooms.Select(x => x.Id).ToList(); var roomIds = guest.GuestReservations.Select(x => x.RoomId).ToList(); //Create a new GuestRoom Account for any refund# var accountRooms = guest.GuestRooms.ToList(); _businessAccountService.Update(company, accountRooms); foreach (var existingReservation in reservationIds.Select(rsId => _guestReservationService.GetById(rsId))) { existingReservation.EndDate = DateTime.Now; existingReservation.IsActive = false; _guestReservationService.Update(existingReservation); } foreach (var existingGuestRoom in guestRoomsIds.Select(gsId => _guestRoomService.GetById(gsId))) { existingGuestRoom.CheckoutDate = DateTime.Now; existingGuestRoom.IsActive = false; _guestRoomService.Update(existingGuestRoom); } foreach (var existingRoom in roomIds.Select(rmId => _roomService.GetById(rmId))) { existingRoom.StatusId = (int)RoomStatusEnum.Dirty; _roomService.Update(existingRoom); } guest.IsActive = false; guest.Status = "PAST"; guest.CompanyId = companyId; _guestService.Update(guest); return(RedirectToAction("PrintLandingForGuest", "Home", new { id = id.Value })); } else { return(RedirectToAction("CheckOutGuest", "Home", new { id = id.Value, roomId = roomId.Value })); } }
public ActionResult RemoveReservation(int?id) { var reservation = _guestReservationService.GetById(id.Value); if (reservation != null) { reservation.IsActive = false; _guestReservationService.Update(reservation); } return(RedirectToAction("FutureBooking")); }