public void BookTour(OrderTour orderTour, OrderTourDetail orderTourDetail) { orderTour.OrderDate = DateTime.Now; //update quantity of tour var tour = _tourRepository.GetById(orderTourDetail.TourId); tour.QuantityPeople -= (orderTourDetail.QuantityAdult + orderTourDetail.QuantityChild); _tourRepository.Update(tour); orderTourDetail.OrderTour = orderTour; _orderTourDetailRepository.Add(orderTourDetail); }
public ActionResult OrderTour(OrderTourDetail orderTourDetail, decimal SumPrice) { //get custommer from session var cusInfor = (User)Session["username"]; if (ModelState.IsValid) { var orderTour = new OrderTour(); orderTour.SumPrice = SumPrice; orderTour.UserId = cusInfor.Id; orderTour.Status = "Pending"; _bookTourRepository.BookTour(orderTour, orderTourDetail); return(RedirectToAction("CompleteOrder")); } return(View(orderTourDetail)); }