public async Task <IActionResult> UpdateItem([FromRoute] int id, [FromBody] DP03A110 model) { if (id != model.Id) { return(BadRequest()); } _context.Entry(model).State = EntityState.Modified; await _context.SaveChangesAsync(); return(NoContent()); }
public bool CheckNoparte([FromRoute] string codigo) { if (!ModelState.IsValid) { return(false); } DP03A110 producto = _context.DP03A110.Where(m => m.No_parte == codigo).FirstOrDefault(); if (producto == null) { return(false); } return(true); }
public async Task <ActionResult <DP03A110> > GetProductoByCodigo([FromRoute] string codigo) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } DP03A110 producto = await _context.DP03A110.Where(m => m.No_parte == codigo).FirstOrDefaultAsync(); if (producto == null) { return(NotFound()); } return(Ok(producto)); }
public async Task <IActionResult> SaveItem([FromBody] DP03A110 model) { if (ModelState.IsValid) { _context.DP03A110.Add(model); if (await _context.SaveChangesAsync() > 0) { return(Ok(model)); } else { return(BadRequest("Datos incorrectos")); } } else { return(BadRequest(ModelState)); } }