public async Task <IActionResult> PutProduto(long id, Produto produto)
        {
            if (id != produto.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Пример #2
0
        public async Task <IActionResult> PutCategory(int id, Category category)
        {
            if (id != category.CategoryID)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
        public async Task <ActionResult <Product> > Post(Product product)
        {
            if (product == null)
            {
                return(BadRequest());
            }

            db.Prod.Add(product);
            await db.SaveChangesAsync();

            return(Ok(product));
        }
        public async Task <ActionResult <ProductMovements> > Post(ProductMovements movements)
        {
            if (movements == null)
            {
                return(BadRequest());
            }

            db.Movements.Add(movements);
            await db.SaveChangesAsync();

            return(Ok(movements));
        }