public virtual bool Delete(int id)
 {
     try
     {
         TEntity model = _context.Set <TEntity>().Find(id);
         _context.Set <TEntity>().Remove(model);
         _context.Entry <TEntity>(model).State = Microsoft.EntityFrameworkCore.EntityState.Deleted;
         _context.SaveChanges();
         return(true);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Пример #2
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description")] Category category)
 {
     if (ModelState.IsValid)
     {
         db.Entry(category).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(category));
 }
Пример #3
0
 public ActionResult Edit([Bind(Include = "Id,Name,Symbol")] Currency currency)
 {
     if (ModelState.IsValid)
     {
         db.Entry(currency).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(currency));
 }
Пример #4
0
 public ActionResult Edit([Bind(Include = "Id,Name")] Location location)
 {
     if (ModelState.IsValid)
     {
         db.Entry(location).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(location));
 }
Пример #5
0
 public ActionResult Edit([Bind(Include = "Id,Name,TaxInclusive,CurrencyId")] Price price)
 {
     if (ModelState.IsValid)
     {
         db.Entry(price).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CurrencyId = new SelectList(db.Currencies, "Id", "Name", price.CurrencyId);
     return(View(price));
 }
Пример #6
0
 public ActionResult Edit([Bind(Include = "Id,ItemId,PriceId,SalesPrice")] ItemPrice itemPrice)
 {
     if (ModelState.IsValid)
     {
         db.Entry(itemPrice).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ItemId  = new SelectList(db.Items, "Id", "Name", itemPrice.ItemId);
     ViewBag.PriceId = new SelectList(db.Prices, "Id", "Name", itemPrice.PriceId);
     return(View(itemPrice));
 }
Пример #7
0
 public ActionResult Edit([Bind(Include = "Id,ItemId,LocationId,Quantity")] Inventory inventory)
 {
     if (ModelState.IsValid)
     {
         db.Entry(inventory).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.ItemId     = new SelectList(db.Items, "Id", "Name", inventory.ItemId);
     ViewBag.LocationId = new SelectList(db.Locations, "Id", "Name", inventory.LocationId);
     return(View(inventory));
 }
Пример #8
0
 public ActionResult Edit([Bind(Include = "Id,Name,Description,Notes,Cost,TypeId,CategoryId")] Item item)
 {
     if (ModelState.IsValid)
     {
         db.Entry(item).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.CategoryId = new SelectList(db.Categories, "Id", "Name", item.CategoryId);
     ViewBag.TypeId     = new SelectList(db.Types, "Id", "Name", item.TypeId);
     return(View(item));
 }