public ActionResult Create(SupplierViewModel supplierVM) { string code = supplierVM.SupplierCode.ToUpper().Trim(); supplierVM.SupplierCode = code; if (supplierService.isExistingCode(code)) { string errorMessage = String.Format("{0} has been used.", code); ModelState.AddModelError("SupplierCode", errorMessage); } else if (ModelState.IsValid) { try { supplierService.AddNewSupplier(supplierVM); TempData["SuccessMessage"] = String.Format("Supplier '{0}' is added.", code); return(RedirectToAction("Index")); } catch (Exception e) { TempData["ErrorMessage"] = e.Message; } } return(View(supplierVM)); }
public ActionResult AddNewSupplier(SupplierCreateDTO supplier) { var guid = supplierService.AddNewSupplier(supplier); string location = linkGenerator.GetPathByAction("GetSupplierByID", "Supplier", new { supplierID = guid }); return(Created(location, guid)); }
public void AddNewSupplier_ShouldPass() { var s = new Supplier { Name = "Cyclops" }; _supplierService.AddNewSupplier(s); }
public Guid AddSupplier(NewSupplierDto data) { return(service.AddNewSupplier(data)); }