示例#1
0
        public static Supplier CreateNewSupplier(Supplier newSupplier)
        {
            var createdSupplier = new Supplier();
              createdSupplier = newSupplier;

              return createdSupplier;
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }