public ActionResult AddSupplier(Supplier supplier)
        {
            SupplierDAO suppDAO = new SupplierDAO();

            bool saved = false;
            //string duplicateMsg = "supplier ID already exist";

            Supplier existingSupp = suppDAO.FindSupplierById(supplier.Id);

            if (supplier.Id == existingSupp.Id)
            {
                SetFlash(Enums.FlashMessageType.Error, "Supplier information for supplier name: " + supplier.Name + " was not added due to duplicate Supplier ID: " + supplier.Id + ".");
                return(RedirectToAction("Suppliers"));
            }
            else if (supplier.Id != existingSupp.Id)
            {
                saved = suppDAO.AddSupplier(supplier);
                if (saved)
                {
                    SetFlash(Enums.FlashMessageType.Success, "Supplier record for Supplier ID: " + supplier.Id + " successfully added!");
                    return(RedirectToAction("Suppliers"));
                }

                SetFlash(Enums.FlashMessageType.Error, "Failed to add supplier record for Supplier ID: " + supplier.Id + ".");
                return(RedirectToAction("Suppliers"));
            }
            else
            {
                SetFlash(Enums.FlashMessageType.Error, "Supplier record for Supplier ID: " + supplier.Id + " not saved.");
                return(RedirectToAction("Suppliers"));
            }
        }
Ejemplo n.º 2
0
 public ActionResult DeleteConfirmed(string id)
 {
     try
     {
         Supplier supplier = SupplierDAO.FindSupplierById(id);
         SupplierDAO.DeleteSupplier(supplier);
         return(RedirectToAction("Index"));
     }
     catch (Exception e)
     {
         return(View("~/Views/Shared/Error.cshtml"));
     }
 }
Ejemplo n.º 3
0
        // GET: Suppliers/Details/5
        public ActionResult Details(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Supplier supplier = SupplierDAO.FindSupplierById(id);

            if (supplier == null)
            {
                return(HttpNotFound());
            }
            return(View(supplier));
        }
Ejemplo n.º 4
0
 // GET: Suppliers/Edit/5
 public ActionResult Edit(string id)
 {
     try
     {
         if (id == null)
         {
             return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
         }
         Supplier supplier = SupplierDAO.FindSupplierById(id);
         if (supplier == null)
         {
             return(HttpNotFound());
         }
         return(View(supplier));
     }
     catch (Exception e)
     {
         return(View("~/Views/Shared/Error.cshtml"));
     }
 }