public void Delete(int id)
        {
            var entity = this.Get(id);

            _shoppingListDbContext.Entry(entity).State = EntityState.Deleted;
            _shoppingListDbContext.SaveChanges();
        }
        public async Task <IActionResult> PutProduct(int id, Product product)
        {
            //if (id != product.Id)
            //{
            //    return BadRequest();
            //}

            product.Id = id;

            _context.Entry(product).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutShoppingListProduct(int id, ShoppingListProduct shoppingListProduct)
        {
            if (id != shoppingListProduct.ShoppingListId)
            {
                return(BadRequest());
            }

            _context.Entry(shoppingListProduct).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ShoppingListProductExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }