public ActionResult Create(Supplier supplier) { if (ModelState.IsValid) { //db.Suppliers.Add(supplier); //db.SaveChanges(); SuppMgr.AddSupplier(supplier); return RedirectToAction("Index"); } ViewBag.ParishID = new SelectList(db.Parish, "ParishID", "name", supplier.ParishID); return View(supplier); }
//updates a supplier public void UpdateSupplier(Supplier supplier) { try { ISupplierSvc supplierSvc = (ISupplierSvc)GetService(typeof(ISupplierSvc).Name); supplierSvc.UpdateSupplier(supplier); } catch (ServiceLoadException e) { throw new SupplierMgrException(e.Message); } catch (DBProcessingException e) { throw new SupplierMgrException(e.Message); } }
//searches for a supplier via supplier code public Supplier SearchSupplier(string supplierCode) { Supplier supplier = new Supplier(); try { ISupplierSvc supplierSvc = (ISupplierSvc)GetService(typeof(ISupplierSvc).Name); supplier = supplierSvc.SearchSupplier(supplierCode); } catch (ServiceLoadException e) { throw new SupplierMgrException(e.Message); } catch (DBProcessingException e) { throw new SupplierMgrException(e.Message); } return supplier; }
public void AddSupplierTest() { Factory factory = Factory.GetInstance(); Supplier supplier = new Supplier(); // TODO: Initialize to an appropriate value supplier.SupplierCode = "RIBI-100"; supplier.SupplierName = "Richels's Juices"; supplier.StreetAddress = "22 Hope Road Kingston"; supplier.ParishID = 1; try { ISupplierSvc supplierSvc = (ISupplierSvc)factory.GetService(typeof(ISupplierSvc).Name); supplierSvc.AddSupplier(supplier);//adds product } catch (Exception e) { Assert.Fail(e.ToString());//force fail of test } }
public ActionResult Edit(Supplier supplier) { if (ModelState.IsValid) { //db.Entry(supplier).State = EntityState.Modified; // db.SaveChanges(); SuppMgr.UpdateSupplier(supplier); return RedirectToAction("Index"); } ViewBag.ParishID = new SelectList(db.Parish, "ParishID", "name", supplier.ParishID); return View(supplier); }
//method for updating a product public void UpdateSupplier(Supplier supplier) { db.Entry(supplier).State = EntityState.Modified; db.SaveChanges(); }
//service for adding Supplierinformation public void AddSupplier(Supplier supplier) { db.Suppliers.Add(supplier); db.SaveChanges(); }