public IHttpActionResult Patch([FromODataUri] string key, Delta <CODE_CAREEREntity> patch) { CODE_CAREERService service = new CODE_CAREERService(); object id; if (!ModelState.IsValid) { return(BadRequest(ModelState)); } else if (patch.GetChangedPropertyNames().Contains("CAREERID") && patch.TryGetPropertyValue("CAREERID", out id) && (string)id != key) { return(BadRequest("The key from the url must match the key of the entity in the body")); } try { var query = service.GetEntity(key); patch.Patch(query); service.UpdateEntity(query); return(Updated(query)); } catch (Exception) { return(NotFound()); } }
/// <summary> /// 更新数据,幂等 /// </summary> /// <param name="key"></param> /// <param name="model"></param> public void Put([FromODataUri] string key, CODE_CAREEREntity model) { CODE_CAREERService service = new CODE_CAREERService(); service.UpdateEntity(model); }