Ejemplo n.º 1
0
 public void SaveSupplier(Supplier supplier)
 {
     if (supplier.SupplierID == 0)
         context.Suppliers.Add(supplier);
     else
     {
         Supplier supplier_ = context.Suppliers.Single(s => s.SupplierID == supplier.SupplierID);
         context.Entry(supplier_).CurrentValues.SetValues(supplier);
     }
     context.SaveChanges();
     Logger.Info(string.Format("Supplier with id {0} and CompanyName {1} saved in database", supplier.SupplierID, supplier.CompanyName));
 }
Ejemplo n.º 2
0
 public ActionResult AddSupplier(Supplier model)
 {
     if (ModelState.IsValid)
     {
         Supplier supplier = model;
         repository.SaveSupplier(supplier);
         return RedirectToAction("Suppliers", new { app_culture = Request.RequestContext.RouteData.Values["app_culture"] });
     }
     else
         return View("EditSupplier", model);
 }
Ejemplo n.º 3
0
 public void DeleteSupplier(Supplier supplier)
 {
     context.Suppliers.Remove(supplier);
     context.SaveChanges();
     Logger.Info(string.Format("Supplier with id {0} and CompanyName {1} removed from database", supplier.SupplierID, supplier.CompanyName));
 }