Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
 public async Task CreateItemAsync(Item item)
 {
     _context.Items.Add(item);
     await _context.SaveChangesAsync();
 }