Ejemplo n.º 1
0
        public ActionResult Edit(ItemCategory model)
        {
            model.OrganizationId = OrganizationId;
            model.CreatedDate    = System.DateTime.Now;
            model.CreatedBy      = UserID.ToString();

            var  repo     = new ItemCategoryRepository();
            bool isexists = repo.IsFieldExists(repo.ConnectionString(), "ItemCategory", "CategoryName", model.CategoryName, "itmCatId", model.itmCatId);

            if (!isexists)
            {
                var result = new ItemCategoryRepository().UpdateItemCategory(model);
                if (result.itmCatId > 0)
                {
                    TempData["Success"]     = "Updated Successfully! (" + result.itmCatRefNo + ")";
                    TempData["itmCatRefNo"] = result.itmCatRefNo;
                    return(RedirectToAction("Create"));
                }

                else
                {
                    TempData["error"] = "Some error occurred. Please try again.";
                    return(View("Create", model));
                }
            }
            else
            {
                TempData["error"]       = "This material/spare category name already exists!";
                TempData["itmCatRefNo"] = null;
                return(View("Create", model));
            }
        }