// [ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int?id, [FromBody] Customer customer)
        {
            //    if (id != customer.Id)
            //    {
            //        return NotFound();
            //    }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(customer);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!CustomerExists(customer.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Ok());
            }
            return(ValidationProblem());
        }
Exemplo n.º 2
0
        // [ValidateAntiForgeryToken]
        public async Task <IActionResult> Edit(int?id, [FromBody] Sales Sale)
        {
            //    if (id != Sale.Id)
            //    {
            //        return NotFound();
            //    }

            if (ModelState.IsValid)
            {
                try
                {
                    //Sale.Datesold = DateTime.Now;
                    _context.Update(Sale);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SaleExists(Sale.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(Ok());
            }
            return(ValidationProblem());
        }