public void Test_if_Order_can_be_created() { List<Movie> m = Facade.MoviRepository().GetAll("").ToList(); Customer c = Facade.CustRepository().GetAll("").FirstOrDefault(); Order o = new Order() { Movies = m, Customers = c, Date = DateTime.Today, Customer_Id = c.Id }; Facade.OrdreRepository().Add(o); Order OrderFromDB = Facade.OrdreRepository().GetAll("").FirstOrDefault(a => a.Customers.Email.Equals(o.Customers.Email)); Assert.NotNull(OrderFromDB); Assert.NotNull(OrderFromDB.Customers); Assert.NotNull(OrderFromDB.Movies); }
public ActionResult Edit(Order order) { try { Facade.OrdreRepository().Edit(order); return RedirectToAction("Index"); } catch { return View(); } }
public ActionResult FinalOrderConfirmation(Customer cust) { cust = Facade.CustRepository().GetAll("").FirstOrDefault(a => a.Email == cust.Email); shoppingCardModel.Customer = cust; Order order = new Order(); order.Customers = cust; List<Movie> movies = new List<Movie>(); order.Date = DateTime.Today.Date; order.Customer_Id = cust.Id; foreach (var item in shoppingCardModel.Items) { movies.Add(new Movie () { Id = item.Id }); } order.Movies = movies; Facade.OrdreRepository().Add(order); return View(shoppingCardModel); }