public ActionResult Create(Customer customer) { Customer foundCustomer = facade.GetCustomerRepository().Find(customer.ID); if (foundCustomer == null) { facade.GetCustomerRepository().Add(customer); } else { facade.GetCustomerRepository().Edit(customer); } Order order = new Order(); ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart; if (cart == null) { cart = new ShoppingCart(); } foreach (var item in cart.OrderLines) { order.OrderLines.Add(item); } order.Customer = customer; facade.GetOrderRepository().Add(order); Session["ShoppingCart"] = cart; return Redirect("Confirmation"); }
public ActionResult AddToCart(int movieID) { ShoppingCart cart = Session["ShoppingCart"] as ShoppingCart; if (cart == null) { cart = new ShoppingCart(); } //OrderLine not added to DB Movie movie = facade.GetMovieRepository().Find(movieID); OrderLine line = new OrderLine() { Movie = movie, Amount = 1 }; cart.Add(line); Session["ShoppingCart"] = cart; return Redirect("Index"); }
public void Setup() { orderList = new List<OrderLine>(); Genre g1 = new Genre() { Name = "Action" }; Genre g2 = new Genre() { Name = "Drama" }; movie = new Movie() { Title = "The Shawshank Redemption", Year = 1994, Price = 9.99, Genres = new List<Genre> { g1, g2 }, ImageURL = "http://ia.media-imdb.com/images/M/MV5BODU4MjU4NjIwNl5BMl5BanBnXkFtZTgwMDU2MjEyMDE@._V1_SX214_AL_.jpg", TrailerURL = "https://www.youtube.com/embed/NmzuHjWmXOc" }; line = new OrderLine(); line.Movie = movie; line.Amount = 1; cart = new ShoppingCart(); }