예제 #1
0
        public async Task <IActionResult> PutCategoria([FromRoute] int id, [FromBody] Categoria categoria)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != categoria.IdCategoria)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
예제 #2
0
 public async Task<IActionResult> Create([Bind("Id,Nome")] Department department)
 {
     if (ModelState.IsValid)
     {
         _context.Add(department);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     return View(department);
 }
예제 #3
0
 public async Task InsertAsync(Seller seller)
 {
     _context.Seller.Add(seller);
     await _context.SaveChangesAsync();
 }