public ActionResult SubCategory() { ViewBag.SuccessMsg = ViewBag.Failuremessage = ""; SubCategoryModels scvm = new SubCategoryModels(); List <SubCategoryList> allSubCategories = _accountService.SubCategory(); SubCategoryDisplayModel model = new SubCategoryDisplayModel(); ViewBag.Categories = _accountService.GetAllCategory(); model.SubCategorys = allSubCategories; scvm.ListDataModel = model; return(View(scvm)); }
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)); }