public async Task <GetGroceryCategoryDto?> UpdateGroceryCategory(UpdateGroceryCategoryDto updatedGroceryCategory) { try { GroceryCategory?groceryCategory = await _context.GroceryCategories.FindAsync(updatedGroceryCategory.Id); _mapper.Map(updatedGroceryCategory, groceryCategory); await _context.SaveChangesAsync(); return(_mapper.Map <GetGroceryCategoryDto>(groceryCategory)); } catch (Exception) { return(null); } }
public async Task <IActionResult> UpdateGroceryCategory(UpdateGroceryCategoryDto dto) { var result = await _groceryCategoryRepository.UpdateGroceryCategory(dto); return(result != null?Ok(result) : BadRequest()); }