public async Task UpdateCategoryAsync(int catId, Category category) { var catExists = await CategoryExistsAsync(catId); if (!catExists) { //return NotFound(); ThrowNotFoundException(catId); } try { _context.Entry(category).State = EntityState.Modified; await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException ex) { throw new CategoryServiceException($"Cannot update category {catId}", ex); } }
public async Task CreateItemAsync(Item item) { _context.Items.Add(item); await _context.SaveChangesAsync(); }