public ActionResult CheckIn(int idBooking, string tokenBook, int number) { HttpResponseMessage resBooking = GlobalVariables.client.GetAsync("Booking?token=" + tokenBook).Result; BookingView book = resBooking.Content.ReadAsAsync <BookingView>().Result; OrderDetailView ord = new OrderDetailView { NameService = number + " phòng (" + book.NameCateRoom + ") x " + book.DurationStay + " day(s)", PriceOrdD = book.PriceCateRoom, Quantity = number, Amount = book.PriceCateRoom * number * book.DurationStay }; System.Threading.Tasks.Task <HttpResponseMessage> resOrd = GlobalVariables.client.PostAsJsonAsync("OrderService?idBook=" + book.IDBooking, ord); if (book.NumberRoom == book.CountRoomBook + number || book.NumberRoom == number) { HistoryBookingView full = new HistoryBookingView { IDBook = idBooking, NameHisBook = "Check in đủ số lượng phòng đã đặt(CI)", DayCreateHisBook = DateTime.Now }; HttpResponseMessage resHisfull = GlobalVariables.client.PostAsJsonAsync("HistoryBooking", full).Result; } else { HistoryBookingView less = new HistoryBookingView { IDBook = idBooking, NameHisBook = "Check in chưa đủ số lượng phòng đã đặt(CI)", DayCreateHisBook = DateTime.Now }; HttpResponseMessage resHisless = GlobalVariables.client.PostAsJsonAsync("HistoryBooking", less).Result; } return(RedirectToAction("InformationBooking", new { token = tokenBook })); }
// 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()); }
public ActionResult CancelBooking(int idBooking) { HistoryBookingView his = new HistoryBookingView { IDBook = idBooking, NameHisBook = "Đặt phòng đã đc hủy(CCBS)", DayCreateHisBook = DateTime.Now }; HttpResponseMessage res = GlobalVariables.client.PostAsJsonAsync("HistoryBooking", his).Result; TempData["success"] = "Cancel booking successfully"; return(RedirectToAction("Index")); }