public static Supplier CreateNewSupplier(Supplier newSupplier) { var createdSupplier = new Supplier(); createdSupplier = newSupplier; return createdSupplier; }
public ActionResult Edit(int? id) { var supplierToEdit = new Supplier(); if (id.HasValue) { supplierToEdit = (from i in Core.DataContext.Suppliers where i.ID == id.Value select i).SingleOrDefault(); } return View(supplierToEdit); }
public ActionResult Edit(Supplier supplier) { if (ModelState.IsValid) { if (supplier.ID > 0) { Supplier supplierToUpdate = SuppliersManager.GetSupplierById(supplier.ID); if (supplierToUpdate != null) { TryUpdateModel(supplierToUpdate); } } else { Core.DataContext.Suppliers.Add(SuppliersManager.CreateNewSupplier(supplier)); } Core.DataContext.SaveChanges(); return RedirectToAction("List"); } return View(); }