public async Task <CategoryResponse> UpdateAsync(int id, Category category) { var existingCategory = await _categoryRepository.FindByIdAsync(id); if (existingCategory == null) { return(new CategoryResponse("Category not found")); } existingCategory.Name = category.Name; try { _categoryRepository.Update(existingCategory); await _unitOfWork.CompleteAsync(); return(new CategoryResponse(existingCategory)); } catch (Exception ex) { return(new CategoryResponse($"An error occurred when updating the category: {ex.Message}")); } }
public void Update(Category category) { categoryRespository.Update(category); }