public ActionResult Create(CategoryViewModel model)
        {
            if (model.IsEmpty())
            {
                return(View(model));
            }

            _repository.AddItemAsync(model);
            return(Redirect("ListAdmin"));
        }
 public async Task <IActionResult> AddCategory(CategoryForCreationDto categoryForCreationDto)
 {
     if (categoryForCreationDto != null)
     {
         var allCategories = _repo.AllItems.ToList();
         foreach (var item in allCategories)
         {
             if (item.Name == categoryForCreationDto.Name)
             {
                 return(BadRequest("Наименование категории уже существует"));
             }
         }
         var categoryToCreation = _mapper.Map <Category>(categoryForCreationDto);
         if (await _repo.AddItemAsync(categoryToCreation))
         {
             var catRet = _mapper.Map <CategoryToReturnDto>(categoryToCreation);
             return(Ok(catRet));
         }
     }
     return(BadRequest());
 }