Example #1
0
        private List <CheckOutListModel> GetViewCheckoutListAll()
        {
            var reservations = new List <Reservation>(
                _reservationHandler.GetAllReservationsCanBeCheckedOut(DateTimeHandler.GetCurrentEndTime().AddDays(1)));
            var models = new List <CheckOutListModel>();

            foreach (Reservation reservation in reservations)
            {
                var firstGuest = reservation.Guests.ToList().ToGuestModelList().FirstOrDefault();
                var firstName  = "";
                var lastName   = "";
                if (firstGuest != null)
                {
                    firstName = firstGuest.FirstName;
                    lastName  = firstGuest.LastName;
                }
                if (reservation.CheckInDate != null && reservation.CheckOutDate == null && !reservation.IsCancelled)
                {
                    models.Add(new CheckOutListModel
                    {
                        Id                = reservation.Id,
                        FirstName         = firstName,
                        LastName          = lastName,
                        CheckInDate       = reservation.StartDate,
                        CheckOutDate      = reservation.EndDate,
                        ActualCheckInDate = reservation.CheckInDate ??
                                            DateTimeHandler.GetCurrentTime().Subtract(TimeSpan.FromDays(1))
                    });
                }
            }
            return(models);
        }
Example #2
0
        public ActionResult CheckOutAllExpired()
        {
            var reservations = new List <Reservation>(
                _reservationHandler.GetExpiredReservations(DateTimeHandler.GetCurrentEndTime()));

            // check out today's reservation if passed 2:00 p.m.
            var includeToday = DateTimeHandler.GetCurrentTime() > DateTimeHandler.GetCurrentEndTime();
            List <CheckOutListModel> models = new List <CheckOutListModel>();

            foreach (Reservation reservation in reservations)
            {
                if (reservation.EndDate < DateTimeHandler.GetCurrentEndTime() ||
                    reservation.EndDate == DateTimeHandler.GetCurrentEndTime() && includeToday)
                {
                    DateTime realCheckInDate = reservation.CheckInDate ?? reservation.StartDate;
                    // handling no show, will conflict with the logic of "stay" so commented out
                    //if (reservation.CheckInDate == null)
                    //{
                    //    _reservationHandler.CheckIn(reservation.Id, realCheckInDate);
                    //}
                    _reservationHandler.CheckOut(reservation.Id, DateTimeHandler.GetCurrentTime());
                    Guest firstGuest = reservation.Guests.OrderBy(guest => guest.Order).FirstOrDefault();
                    var   firstName  = "";
                    var   lastName   = "";
                    if (firstGuest != null)
                    {
                        firstName = firstGuest.FirstName;
                        lastName  = firstGuest.LastName;
                    }
                    models.Add(new CheckOutListModel
                    {
                        Id                = reservation.Id,
                        FirstName         = firstName,
                        LastName          = lastName,
                        CheckInDate       = reservation.StartDate,
                        CheckOutDate      = reservation.EndDate,
                        ActualCheckInDate = realCheckInDate
                    });
                }
            }

            return(View(models));
        }