Esempio n. 1
0
        public Reservation ChangeReservationStatus(int reservationId, ReservationStatusEnum statusToSet)
        {
            var reservation = db.Reservations.FirstOrDefault(r => r.ReservationId == reservationId);

            reservation.ReservationStatusId = statusToSet;
            reservation = this.EditReservation(reservation);

            return(reservation);
        }
 public ReservationStatusEf(ReservationStatusEnum @enum)
 {
     Id   = (int)@enum;
     Name = @enum.GetDescription();
 }
Esempio n. 3
0
 public Reservation ChangeReservationStatus(int reservationId, ReservationStatusEnum statusToSet)
 {
     return(this.reservationRepository.ChangeReservationStatus(reservationId, statusToSet));
 }
Esempio n. 4
0
        public Reservation AddReservation(int roomId, int arrangerId, DateTime requestedAccomodationDate, DateTime requestedCheckOutDate, ReservationStatusEnum reservationStatus, HotelBookingSiteEnum hotelBookingSite, decimal totalCost)
        {
            var newReservation = new Reservation
            {
                UserId = arrangerId,
                ReservationStatusId = reservationStatus,
                AccomodationDate    = requestedAccomodationDate,
                CheckOutDate        = requestedCheckOutDate,
                HotelBookingSiteId  = hotelBookingSite,
                TotalCost           = totalCost
            };

            using (var dbContextTransaction = db.Database.BeginTransaction())
            {
                try
                {
                    db.Reservations.Add(newReservation);
                    db.SaveChanges();
                    db.RoomReservations.Add(new RoomReservation
                    {
                        ReservationId = newReservation.ReservationId,
                        RoomId        = roomId
                    });
                    db.SaveChanges();
                    dbContextTransaction.Commit();
                    return(newReservation);
                }
                catch
                {
                    dbContextTransaction.Rollback();
                    return(null);
                }
            }
        }
Esempio n. 5
0
        public Reservation AddReservation(int roomId, int arrangerId, DateTime requestedAccomodationDate, DateTime requestedCheckOutDate, ReservationStatusEnum reservationStatus, HotelBookingSiteEnum hotelBookingSite)
        {
            var room         = this.roomRepository.GetRoom(roomId);
            var numberOfDays = (int)Math.Ceiling((requestedCheckOutDate - requestedAccomodationDate).TotalDays);
            var totalCost    = Math.Round(numberOfDays * room.Cost, 2);

            return(this.reservationRepository.AddReservation(roomId, arrangerId, requestedAccomodationDate, requestedCheckOutDate, reservationStatus, hotelBookingSite, totalCost));
        }