public async Task <IActionResult> PutType([FromRoute] long id, [FromBody] Type @type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != @type.TypeId) { return(BadRequest()); } _context.Entry(@type).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TypeExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> PostType([FromBody] Type @type) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } _context.Type.Add(@type); await _context.SaveChangesAsync(); return(CreatedAtAction("GetType", new { id = @type.TypeId }, @type)); }