public void Add(Order order) { using (var ctx = new ShopContextConnection()) { ctx.Orders.Attach(order); ctx.Orders.Add(order); ctx.SaveChanges(); } }
// GET: Orders public ActionResult Index([Bind(Include = "Id")] Movie movie) { Movie moviee = db.Movies.Find(movie.Id); string UserId = User.Identity.GetUserId(); var date = DateTime.Now; Order order = new Order(); order.UserId = UserId; order.MovieId = moviee.Id; order.OrderDate = date; facade.GetOrderRepository().Add(order); return View(moviee); }