public Room Get(int id) { using (HotelBookingContext ctx = new HotelBookingContext()) { return(ctx.Rooms.FirstOrDefault(r => r.Id == id)); } }
public IEnumerable <Room> GetAll() { using (HotelBookingContext ctx = new HotelBookingContext()) { return(ctx.Rooms.ToList()); } }
public IEnumerable <Booking> GetAll() { using (var ctx = new HotelBookingContext()) { return(ctx.Bookings.Include(b => b.Customer).Include(b => b.Room).ToList()); } }
public Booking Get(int id) { using (var ctx = new HotelBookingContext()) { return(ctx.Bookings.FirstOrDefault(c => c.Id == id)); } }
public IEnumerable <Customer> GetAll() { using (var ctx = new HotelBookingContext()) { return(ctx.Customers.ToList()); } }
public void Delete(int id) { using (var ctx = new HotelBookingContext()) { var cus = ctx.Rooms.FirstOrDefault(x => x.Id == id); ctx.Rooms.Remove(cus); ctx.SaveChanges(); } }
public Room Add(Room entity) { using (HotelBookingContext ctx = new HotelBookingContext()) { Room newRoom = ctx.Rooms.Add(entity); ctx.SaveChanges(); return(newRoom); } }
public Booking Add(Booking entity) { using (var ctx = new HotelBookingContext()) { var result = ctx.Bookings.Add(entity); ctx.SaveChanges(); return(result); } }
public Customer Add(Customer entity) { using (var ctx = new HotelBookingContext()) { var result = ctx.Customers.Add(entity); ctx.SaveChanges(); return(result); } }
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); } }
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); } }
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); } }