public ActionResult AddTour(Int32 id = -1) { if (id != -1) { var tourRepository = new TourRepository(); Tour tour = tourRepository.GetById(id); if (tour != null) { var model = new TourModel { Id = tour.Id, Name = tour.Name, StartDate = tour.StartDate, EndDate = tour.EndDate, PlaceCount = tour.PlaceCount, Price = tour.Price, Description = tour.Description }; return View(model); } } return View(new TourModel()); }
public ActionResult Tour(int id) { TourRepository tourRepository = new TourRepository(); Tour tour = tourRepository.GetById(id); return View(tour); }
public ActionResult OrderTour(int id, int placeNumber) { UserRepository userRepository = new UserRepository(); OrderRepository orderRepository = new OrderRepository(); TourRepository tourRepository = new TourRepository(); Tour tour = tourRepository.GetById(id); if (tour != null) { Order order = new Order(); order.Date = DateTime.Now; order.PlaceCount = placeNumber; order.Tour = tour; order.User = userRepository.GetBy(x => x.Email == User.Identity.Name); orderRepository.AddOrder(order); } return Redirect("/Tour/Orders"); }