public async Task <ResponseFromApi <int> > CreateCategory(CategoryBlazorVM categoryViewModel) { try { ResponseFromApi <int> apiResponse = new ResponseFromApi <int>(); CreatedCategoryCommand createCategoryCommand = _mapper.Map <CreatedCategoryCommand>(categoryViewModel); var createCategoryCommandResponse = await _client.AddCategoryAsync(createCategoryCommand); if (createCategoryCommandResponse.Success) { apiResponse.Data = createCategoryCommandResponse.CategoryId.Value; apiResponse.Success = true; } else { apiResponse.Data = -1; foreach (var error in createCategoryCommandResponse.ValidationErrors) { apiResponse.ValidationErrors += error + Environment.NewLine; } } return(apiResponse); } catch (ApiException ex) { return(ex.ConvertApiExceptions()); } }