Ejemplo n.º 1
0
        public List <ReservationBE> ListReservation()
        {
            try
            {
                HotelEntities hotel = new HotelEntities();

                //var data = hotel.Reservation.ToList();

                var data = (from r in hotel.Reservation
                            join c in hotel.Customer on r.CustomerId equals c.id
                            join u in hotel.Room on r.RoomId equals u.id
                            join h in hotel.Hotel on r.HotelId equals h.id
                            orderby r.id descending
                            select new ReservationBE
                {
                    Id = r.id,
                    CustomerId = r.CustomerId,
                    CustomerName = c.Name + " " + c.SurName,
                    HotelId = r.HotelId,
                    HotelName = h.Name,
                    RoomId = u.id,
                    RoomName = u.TypeRoom,
                    AdmissionDate = r.AdmissionDate,
                    DepartureDate = r.DepartureDate,
                }).ToList();

                return(data);
            }
            catch (Exception e)
            {
                throw new Exception("Error en ListReservation: " + e.Message);
            }
        }
        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);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 4
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);
        }
Ejemplo n.º 5
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);
        }
Ejemplo n.º 6
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);
        }
Ejemplo n.º 7
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);
        }
 public List <Room> GetAll()
 {
     try
     {
         HotelEntities hotel = new HotelEntities();
         var           data  = hotel.Room.ToList();
         return(data);
     }catch (Exception e)
     {
         throw new Exception(e.Message);
     }
 }
        public List <Hotel> ListHotel()
        {
            try
            {
                HotelEntities hotel = new HotelEntities();

                var data = hotel.Hotel.ToList();

                return(data);
            }
            catch (Exception e)
            {
                throw new Exception("Error en ListReservation: " + e.Message);
            }
        }
        public List <Room> Find(string type)
        {
            try
            {
                HotelEntities hotel = new HotelEntities();
                var           data  = (from r in hotel.Room where r.TypeRoom.Contains(type) select r).ToList();

                return(data);
            }catch (Exception e)
            {
                throw new Exception(e.Message);
            }


            throw new NotImplementedException();
        }
Ejemplo n.º 11
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);
            }
        }
        public List <Room> ListRoom(int HotelID, int CustomerID)
        {
            try
            {
                HotelEntities hotel = new HotelEntities();

                var data = (from r in hotel.Room
                            join e in hotel.Reservation on r.id equals e.RoomId
                            where e.HotelId == HotelID && e.CustomerId == CustomerID
                            select r).ToList();

                var query = hotel.Room.ToList().Except(data).ToList();

                return(query);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }
        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);
        }
        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);
        }
Ejemplo n.º 15
0
        public List <CustomerBE> ListCustomer()
        {
            HotelEntities hotelEntities = new HotelEntities();

            try
            {
                //var data = hotelEntities.Customer.ToList();
                var data = (from c in hotelEntities.Customer select new CustomerBE {
                    Id = c.id,
                    Name = c.Name,
                    SurName = c.SurName,
                    DocumentType = c.DocumentType,
                    DocumentNumber = c.DocumentNumber,
                    Phone = c.Phone,
                    FullName = c.Name + " " + c.SurName,
                }).ToList();

                return(data);
            }
            catch (Exception e)
            {
                throw new Exception(e.Message);
            }
        }