public async Task <IActionResult> PutType(string id, Type @type) { if (id != @type.TypeName) { 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 <ActionResult <Type> > PostType(Type @type) { _context.Types.Add(@type); try { await _context.SaveChangesAsync(); } catch (DbUpdateException) { if (TypeExists(@type.TypeName)) { return(Conflict()); } else { throw; } } return(CreatedAtAction("GetType", new { id = @type.TypeName }, @type)); }