// POST api/<controller>
        public IHttpActionResult Post(HistoryBookingView hb)
        {
            var his = new HistoryBooking {
                IDBook = hb.IDBook, NameHisBook = hb.NameHisBook, DayCreateHisBook = DateTime.Now
            };

            Repositories.CreateHisBook(his);
            return(Ok());
        }
Example #2
0
        public static bool CreateHisBook(HistoryBooking hb)
        {
            HotelAPIManagementEntities hm = new HotelAPIManagementEntities();

            hm.HistoryBookings.Add(hb);
            if (hm.SaveChanges() > 0)
            {
                return(true);
            }
            return(false);
        }
        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);
        }
Example #5
0
        public static bool ExecuteCheckOut(string token, bool payment)
        {
            var book       = BookingBUS.GetBookingByToken(token);
            var lsRoomBook = BookingBUS.GetRB(book.IDBooking);

            foreach (var item in lsRoomBook)
            {
                RoomBUS.UpdateRoomEmpty(item.IDRoom);
            }
            if (OrderBUS.UpdatePayment(book.IDBooking, payment) == true)
            {
                var paytype = payment == true ? "(Cash)" : "(Paypal)";
                var hisBook = new HistoryBooking {
                    IDBook = book.IDBooking, NameHisBook = "Thanh toán " + paytype + " và trả phòng thành công(PC)", DayCreateHisBook = DateTime.Now
                };
                BookingBUS.CreateHisBook(hisBook);
                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);
        }
Example #8
0
 public static bool CreateHisBook(HistoryBooking hb)
 {
     return(HistoryBookingDAO.CreateHisBook(hb));
 }