public ActionResult Save(SubCategory subCategory)
        {
            List <SubCategory> subCategories = subCategoryManager.GetAll();

            ViewBag.SubCategoryList = subCategories;
            List <GeneralCatagory> generalCatagories = generalCategoryManager.GetAll();

            ViewBag.GeneralcategoryList = generalCatagories;
            List <CategorySetup> categorySetups = categorySetupManager.GetAll();

            ViewBag.CategorySetupList = categorySetups;

            if (subCategory.Name == null || subCategory.Code == null || subCategory.CategorySetupId == 0 ||
                subCategory.GeneralCtegoryId == 0)
            {
                ViewBag.message = "input field is requird";
            }
            else
            {
                if (subCategory.Code.Length > 5)
                {
                    ViewBag.message = "Code lenth is greatr than 5 not allowed";
                }
                else
                {
                    bool IsCodeExist = subCategoryManager.isCodeExist(subCategory.Code);
                    if (IsCodeExist)
                    {
                        ViewBag.message = "code is already exist !";
                    }
                    else
                    {
                        bool Save = subCategoryManager.Add(subCategory);
                        if (Save)
                        {
                            ViewBag.message = "Save successfull";
                        }
                        else
                        {
                            ViewBag.message = "Save failed";
                        }
                    }
                }
            }



            return(View());
        }
        public ActionResult Create([Bind(Include = "SubCategoryID,CategoryID,SubCategoryName,SubCategoryCode,SubCategoryDescription")] SubCategory subcategory)
        {
            if (ModelState.IsValid)
            {
                //db.SubCategories.Add(subcategory);
                //db.SaveChanges();
                _subCategoryManager.Add(subcategory);
                return(RedirectToAction("Index"));
            }

            var categoryList = _categoryManager.GetAll();

            ViewBag.CategoryID = new SelectList(categoryList, "CategoryID", "CategoryName");
            return(View(subcategory));
        }
Exemplo n.º 3
0
        public ActionResult Entry(SubCategory subcategory)
        {
            var isAdded = _manager.Add(subcategory);

            return(RedirectToAction("Entry", "SubCategory"));
        }