public virtual async Task <ActionResult> Create(AddCategoryViewModel viewModel) { if (ModelState.IsValid) { var category = new Category { Description = viewModel.Description, ParentId = viewModel.ParentId == 0 ? null : viewModel.ParentId, KeyWords = viewModel.KeyWords, Name = viewModel.Name, DisplayOrder = viewModel.DisplayOrder, DiscountPercent = viewModel.DiscountPercent }; _attributeService.AddParentAttributeToChild(category.ParentId, category.Id); var status = _categoryService.Add(category); if (status == AddCategoryStatus.CategoryNameExist) { ModelState.AddModelError("Name", "این نام قبلا ثبت شده است"); return(View(viewModel)); } await _unitOfWork.SaveChangesAsync(); CacheManager.InvalidateChildActionsCache(); return(RedirectToAction(MVC.Admin.Category.ActionNames.Create, MVC.Admin.Category.Name)); } PopulateCategoriesDropDownList(_categoryService.GetFirstLevelCategories(), viewModel.ParentId); return(View(viewModel)); }