Пример #1
0
        public ActionResult SubCategory(SubCategoryModels model)
        {
            ViewBag.SuccessMsg = ViewBag.Failuremessage = "";
            if (ModelState.IsValid)
            {
                int seltedID = model.SubmitFormModel.SubCategoryID;
                //Api.MembershipCreateStatus createStatus;
                Api.ProductCategorySubCategory createStatus;
                string currentUser = HttpContext.User.Identity.Name;

                if (seltedID == 0)
                {
                    _accountService.CreateSubCategory(model.SubmitFormModel.CategoryID, model.SubmitFormModel.SubCategoryName,
                                                      model.SubmitFormModel.SubCategoryDescription, out createStatus);

                    if (createStatus == Api.ProductCategorySubCategory.Success)
                    {
                        ModelState.Clear();
                        ViewBag.SuccessMsg = "SubCategory careated successfully";
                    }
                    else if (createStatus == Api.ProductCategorySubCategory.DuplicateName)
                    {
                        ViewBag.Failuremessage = "Unable to create Subcategor, As Subcategory already exist!";
                    }
                }
                else
                {
                    bool returnResult = _accountService.UpdateCategory(model.SubmitFormModel.CategoryID, model.SubmitFormModel.SubCategoryName,
                                                                       model.SubmitFormModel.SubCategoryDescription, model.SubmitFormModel.SubCategoryID);

                    if (returnResult == true)
                    {
                        ModelState.Clear();
                        ViewBag.SuccessMsg = "Category updated successfully";
                    }
                    else
                    {
                        ViewBag.Failuremessage = "Unable to update please try again later!";
                    }
                }
            }
            SubCategoryModels       scvm             = new SubCategoryModels();
            List <SubCategoryList>  allSubCategories = _accountService.SubCategory();
            SubCategoryDisplayModel modeldisplay     = new SubCategoryDisplayModel();

            ViewBag.Categories        = _accountService.GetAllCategory();
            modeldisplay.SubCategorys = allSubCategories;
            scvm.ListDataModel        = modeldisplay;
            return(View(scvm));
        }
Пример #2
0
        public ActionResult SubCategory(SubCategoryModel model)
        {
            ViewBag.Categories = _accountService.GetAllCategory();
            if (ModelState.IsValid)
            {
                //Api.MembershipCreateStatus createStatus;
                Api.ProductCategorySubCategory createStatus;
                string currentUser = HttpContext.User.Identity.Name;
                _accountService.CreateSubCategory(model.SelectedCategoryId, model.SubCategoryName, model.SubCategoryDescription, out createStatus);

                if (createStatus == Api.ProductCategorySubCategory.Success)
                {
                    ViewBag.SuccessMsg = 1;
                }
                else
                {
                    // ModelState.AddModelError("", ErrorCodeToString(createStatus));
                    ModelState.AddModelError("", ErrorCodeToStringProduct(createStatus));
                }
            }
            return(View());
        }