public HttpResponseMessage Create(string name, string entity, object value, HttpRequestMessage request) { dynamic obj = JsonConvert.DeserializeObject <dynamic>(value.ToString()); DynModificationService modificationService = new DynModificationService(name, request.GetQueryNameValuePairs()); string mediaType = request.GetResponseMediaType(); switch (mediaType) { case "application/json": { modificationService.Create(obj, entity, out string json); return(CreateHttpResponseMessage(json, request)); } case "application/xml": { modificationService.Create(obj, entity, out XElement element); return(CreateHttpResponseMessage(element, request)); } default: throw new NotSupportedException(mediaType.ToString()); } }
public void Update(string name, string entity, object value, HttpRequestMessage request) { dynamic obj = JsonConvert.DeserializeObject <dynamic>(value.ToString()); dynamic original = GetOriginal(obj, out dynamic token); var service = new DynModificationService(name, request.GetQueryNameValuePairs()); if (original == null) { service.Update(token, entity); } else { service.Update(token, original, entity); } }