Esempio n. 1
0
        public ActionResult Edit(Supplier model)
        {
            ViewBag.Title        = "Edit";
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();

            var  repo     = new SupplierRepository();
            bool isexists = repo.IsFieldExists(repo.ConnectionString(), "Supplier", "SupplierName", model.SupplierName, "SupplierId", model.SupplierId);

            if (!isexists)
            {
                var result = new SupplierRepository().UpdateSupplier(model);
                if (result.SupplierId > 0)
                {
                    TempData["Success"]       = "Updated Successfully!";
                    TempData["SupplierRefNo"] = result.SupplierRefNo;
                    return(RedirectToAction("Index"));
                }

                else
                {
                    FillCategoryDropdown();
                    FillCountryDropdown();
                    FillCurrencyDropdown();
                    FillPurchaseType();
                    TempData["error"]         = "Oops!!..Something Went Wrong!!";
                    TempData["SupplierRefNo"] = null;
                    return(View("Create", model));
                }
            }
            else
            {
                FillCategoryDropdown();
                FillCountryDropdown();
                FillCurrencyDropdown();
                FillPurchaseType();
                TempData["error"]         = "This Name Alredy Exists!!";
                TempData["SupplierRefNo"] = null;
                return(View("Create", model));
            }
        }