Пример #1
0
        public Room Update(Room entity)
        {
            using (HotelBookingContext ctx = new HotelBookingContext())
            {
                Room roomDB = ctx.Entry(entity).Entity;

                if (roomDB == null)
                {
                    return(null);
                }

                roomDB.Description = entity.Description;

                ctx.Entry(roomDB).State = EntityState.Modified;
                ctx.SaveChanges();
                return(roomDB);
            }
        }
Пример #2
0
        public Customer Update(Customer entity)
        {
            using (var ctx = new HotelBookingContext())
            {
                Customer customerDB = ctx.Entry(entity).Entity;

                if (customerDB == null)
                {
                    return(null);
                }

                //var customerDB = ctx.Customers.FirstOrDefault(c => c.Id == customer.Id);
                customerDB.Email = entity.Email;
                customerDB.Name  = entity.Name;

                ctx.Entry(customerDB).State = EntityState.Modified;
                ctx.SaveChanges();
                return(customerDB);
            }
        }
Пример #3
0
        public Booking Update(Booking entity)
        {
            using (var ctx = new HotelBookingContext())
            {
                Booking bookingDB = ctx.Entry(entity).Entity;

                if (bookingDB == null)
                {
                    return(null);
                }

                //var bookingDB = ctx.Bookings.FirstOrDefault(c => c.Id == booking.Id);
                bookingDB.IsActive   = entity.IsActive;
                bookingDB.StartDate  = entity.StartDate;
                bookingDB.EndDate    = entity.EndDate;
                bookingDB.RoomId     = entity.RoomId;
                bookingDB.CustomerId = entity.CustomerId;

                ctx.Entry(bookingDB).State = EntityState.Modified;
                ctx.SaveChanges();
                return(bookingDB);
            }
        }