public static bool CreateBooking(Booking b) { HotelAPIManagementEntities hm = new HotelAPIManagementEntities(); b.NewBooking = true; b.DayCreateBooking = DateTime.Now; hm.Bookings.Add(b); if (hm.SaveChanges() > 0) { var his = new HistoryBooking { IDBook = b.IDBooking, NameHisBook = "Đặt phòng thành công(CBS)", DayCreateHisBook = b.DayCreateBooking }; HistoryBookingDAO.CreateHisBook(his); return(true); } return(false); }
public static bool UpdateCus(Customer cus, int idBooking) { HotelAPIManagementEntities hm = new HotelAPIManagementEntities(); var item = hm.Customers.SingleOrDefault(s => s.IDCus == cus.IDCus); item.NameCus = cus.NameCus; item.PhoneCus = cus.PhoneCus; item.AddressCus = cus.AddressCus; item.EmailCus = cus.EmailCus; if (hm.SaveChanges() > 0) { var his = new HistoryBooking { IDBook = idBooking, NameHisBook = "Cập nhật thông tin cá nhân", DayCreateHisBook = DateTime.Now }; HistoryBookingDAO.CreateHisBook(his); return(true); } return(false); }
public static bool UpdateBooking(Booking b) { HotelAPIManagementEntities hm = new HotelAPIManagementEntities(); var item = hm.Bookings.SingleOrDefault(s => s.IDBooking == b.IDBooking); item.NumberRoom = b.NumberRoom; item.DateIn = b.DateIn; item.DateOut = b.DateOut; item.DurationStay = b.DurationStay; item.IDCateRoom = b.IDCateRoom; if (hm.SaveChanges() > 0) { var his = new HistoryBooking { IDBook = b.IDBooking, NameHisBook = "Cập nhật thông tin phòng", DayCreateHisBook = DateTime.Now }; HistoryBookingDAO.CreateHisBook(his); return(true); } return(false); }
public static bool UpdateRB(RoomBooking rb, string reason) { HotelAPIManagementEntities hm = new HotelAPIManagementEntities(); var item = hm.RoomBookings.SingleOrDefault(s => s.IDRoomBook == rb.IDRoomBook); var idRoomOld = item.IDRoom; var roomOld = item.Room.NameRoom; var roomNew = hm.Rooms.SingleOrDefault(w => w.IDRoom == rb.IDRoom).NameRoom; item.IDRoom = rb.IDRoom; if (hm.SaveChanges() > 0) { var his = new HistoryBooking { IDBook = rb.IDBook, NameHisBook = "Đổi phòng thành công (" + roomOld + " -> " + roomNew + ": " + reason + ")", DayCreateHisBook = DateTime.Now }; HistoryBookingDAO.CreateHisBook(his); RoomDAO.UpdateRoomEmpty(idRoomOld); RoomDAO.UpdateRoomEmpty(rb.IDRoom); return(true); } return(false); }