public async Task <IActionResult> PutLineCellphone([FromRoute] string id, [FromBody] LineCellphone lineCellphone) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != lineCellphone.Number) { return(BadRequest()); } _context.Entry(lineCellphone).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!LineCellphoneExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostLineCellphone([FromBody] LineCellphone lineCellphone) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.LineCellphone.Add(lineCellphone); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (LineCellphoneExists(lineCellphone.Number)) { return(new StatusCodeResult(StatusCodes.Status409Conflict)); } else { throw; } } return(CreatedAtAction("GetLineCellphone", new { id = lineCellphone.Number }, lineCellphone)); }