Exemplo n.º 1
0
        public ActionResult ForceToVacant(int?id)
        {
            var room = _roomService.GetById(id.Value);

            if (room != null)
            {
                var guestRooms = room.GuestRooms.Where(x => x.IsActive).Select(x => x.Id);

                foreach (var ids in guestRooms)
                {
                    var gr = _guestRoomService.GetById(ids);

                    if (gr != null)
                    {
                        gr.IsActive = false;
                        _guestRoomService.Update(gr);
                    }
                }

                room.StatusId = (int)RoomStatusEnum.Vacant;

                _roomService.Update(room);
            }

            var           rooms = _roomService.GetAll(1).Where(x => x.IsActive && x.StatusId != (int)RoomStatusEnum.Occupied && x.StatusId != (int)RoomStatusEnum.Vacant).ToList();
            RoomViewModel model = new RoomViewModel();

            model.Rooms = rooms;
            return(View("ForceRoomToVacant", model));
        }
Exemplo n.º 2
0
        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 }));
            }
        }