public void SaveEditedPurchase(Purchase purchase)
 {
     dbcontex.Entry(purchase).State = EntityState.Modified;
     dbcontex.SaveChanges();
 }
 public void DeletePurchase(Purchase purchase)
 {
     dbcontex.Purchases.Remove(purchase);
     dbcontex.SaveChanges();
 }
 public void CreatePurchase(Purchase purchase)
 {
     dbcontex.Purchases.Add(purchase);
     dbcontex.SaveChanges();
 }
 public ActionResult EditPurchase(Purchase purchase)
 {
     purchase.Date = DateTime.Now;
     repository.SaveEditedPurchase(purchase);
     return RedirectToAction("PurchasesList");
 }
 public ActionResult CreatePurchase(Purchase purchase)
 {
     purchase.Date = DateTime.Now;
     repository.CreatePurchase(purchase);
     // перенаправляем на главную страницу
     return RedirectToAction("PurchasesList");
 }
        public ActionResult CreatePurchase()
        {
            // Формируем список для передачи в представление
            ViewBag.Goods = new SelectList(repository.PureGoods().ToList(), "Id", "Title");//категории для формирования DropListDown

            Purchase newitem = new Purchase();
            return PartialView("PartialCreatePurchase", newitem);
        }