Ejemplo n.º 1
0
        public Confirm CreateReservation(ReservationBE reservationBE)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel       = new HotelEntities();
                Reservation   reservation = new Reservation();

                reservation.AdmissionDate = reservationBE.AdmissionDate;
                reservation.DepartureDate = reservationBE.DepartureDate;
                reservation.CustomerId    = reservationBE.CustomerId;
                reservation.RoomId        = reservationBE.RoomId;
                reservation.HotelId       = reservationBE.HotelId;

                hotel.Reservation.Add(reservation);
                hotel.SaveChanges();

                SendMessage sendMessage = new SendMessage();
                sendMessage.Send(reservationBE);

                confirm.Clase  = "CreateReservation";
                confirm.Status = "OK";
            }
            catch (Exception e)
            {
                confirm.Clase  = "CreateReservation";
                confirm.Status = e.Message;
                //throw new Exception(e.Message);
            }

            return(confirm);
        }
Ejemplo n.º 2
0
        public Confirm UpdateReservation(ReservationBE reservationBE, int reservationId)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel = new HotelEntities();

                var query = (from r in hotel.Reservation where r.id == reservationId select r).FirstOrDefault();
                query.CustomerId    = reservationBE.CustomerId;
                query.HotelId       = reservationBE.HotelId;
                query.RoomId        = reservationBE.RoomId;
                query.AdmissionDate = reservationBE.AdmissionDate;
                query.DepartureDate = reservationBE.DepartureDate;

                hotel.SaveChanges();

                confirm.Clase  = "UpdateReservation";
                confirm.Status = "OK";
            }
            catch (Exception e)
            {
                confirm.Clase  = "UpdateReservation";
                confirm.Status = e.Message;
                throw new Exception(e.Message);
            }

            return(confirm);
        }