public ActionResult Finalize() { try { double price = 0; List <Domain.Model.Item> orderItemsList = new List <Domain.Model.Item>(); foreach (var val in MyOrder.itemsInOrder) { orderItemsList.Add(RepoItem.GetItemById(val)); price = price + RepoItem.GetItemById(val).Price; } Domain.Model.Order myNewOrder = new Domain.Model.Order { UserId = RepoPers.GetPeopleByName(MyOrder.Username).First().Id, Date = DateTime.Now, Price = price, Items = orderItemsList }; RepoOrd.AddOrder(myNewOrder); RepoOrd.Save(); MyOrder.Username = ""; MyOrder.itemsInOrder = null; } catch { return(RedirectToAction("Index", "Home")); } return(RedirectToAction("Index", "Home")); }
public ActionResult Delete(int id, [BindNever] IFormCollection collection) { try { RepoItem.DeleteItemByOrderId(id); RepoOrd.DeleteOrderById(id); RepoOrd.Save(); return(RedirectToAction(nameof(Index))); } catch { return(View()); } }