コード例 #1
0
        public Confirm DeleteReservation(int reservationId)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel = new HotelEntities();

                var remove = (from r in hotel.Reservation where r.id == reservationId select r).First();

                if (remove != null)
                {
                    hotel.Reservation.Remove(remove);
                    hotel.SaveChanges();
                }

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

            return(confirm);
        }
コード例 #2
0
        public Confirm Update(Room room)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel = new HotelEntities();
                var           query = (from r in hotel.Room where r.id == room.id select r).FirstOrDefault();
                query.NumberRoom = room.NumberRoom;
                query.Price      = room.Price;
                query.TypeRoom   = room.TypeRoom;
                hotel.SaveChanges();

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

            return(confirm);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }
コード例 #5
0
        public Confirm UpdateCustomer(Customer customer)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel   = new HotelEntities();
                Customer      custome = new Customer();

                var query = (from c in hotel.Customer where c.id == customer.id select c).FirstOrDefault();

                query.Name           = customer.Name;
                query.SurName        = customer.SurName;
                query.DocumentType   = customer.DocumentType;
                query.DocumentNumber = customer.DocumentNumber;
                query.Phone          = customer.Phone;

                hotel.SaveChanges();

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

            return(confirm);
        }
コード例 #6
0
        public Confirm CreateCustomer(CustomerBE customerBE)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel    = new HotelEntities();
                Customer      customer = new Customer();

                customer.Name           = customerBE.Name;
                customer.SurName        = customerBE.SurName;
                customer.DocumentType   = customerBE.DocumentType;
                customer.DocumentNumber = customerBE.DocumentNumber;
                customer.Phone          = customerBE.Phone;

                hotel.Customer.Add(customer);
                hotel.SaveChanges();

                confirm.Clase  = "CreateCustomer";
                confirm.Status = "OK";
            }
            catch (Exception e)
            {
                confirm.Clase  = "CreateCustomer";
                confirm.Status = e.Message;
                //throw new Exception(e.Message);
            }
            return(confirm);
        }
コード例 #7
0
        public void DeleteCustomer(int customerId)
        {
            try
            {
                HotelEntities hotel = new HotelEntities();

                var remove = (from c in hotel.Customer where c.id == customerId select c).First();

                if (remove != null)
                {
                    hotel.Customer.Remove(remove);
                    hotel.SaveChanges();
                }
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
コード例 #8
0
        public Confirm Create(Room room)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel = new HotelEntities();
                hotel.Room.Add(room);
                hotel.SaveChanges();

                confirm.Status = "OK";
                confirm.Clase  = "CreateRoom";
            }
            catch (Exception e)
            {
                confirm.Status = e.Message;
                confirm.Clase  = "CreateRoom";
                //throw new Exception(e.Message);
            }
            return(confirm);
        }
コード例 #9
0
        public Confirm Delete(int idRoom)
        {
            Confirm confirm = new Confirm();

            try
            {
                HotelEntities hotel = new HotelEntities();
                var           query = (from r in hotel.Room where r.id == idRoom select r).FirstOrDefault();
                hotel.Room.Remove(query);
                hotel.SaveChanges();

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