public IActionResult Post([FromBody] JsonMixedTypesModel newModel) { if (!ModelState.IsValid) { return(BadRequest()); } var newEntity = newModel.ToEntity(); _context.JsonMixedTypesEntities.Add(newEntity); _context.SaveChanges(); return(CreatedAtRoute(ROUTE_GetEntityById, new { id = newEntity.Id }, newEntity)); }
public IActionResult Put(int id, [FromBody] JsonMixedTypesModel updatedModel) { if (!ModelState.IsValid) { return(BadRequest()); } var found = GetEntityById(id); if (found == null) { return(NotFound()); } updatedModel.UpdateEntity(ref found); _context.SaveChanges(); return(NoContent()); }