Exemplo n.º 1
0
        public IHttpActionResult Patch([FromODataUri] string key, Delta <InformedConsentContentEntity> patch)
        {
            InformedConsentContentService service = new InformedConsentContentService();
            object id;

            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }
            else if (patch.GetChangedPropertyNames().Contains("ID") && patch.TryGetPropertyValue("ID", 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.ToString());
                patch.Patch(query);
                service.UpdateEntity(query);
                return(Updated(query));
            }
            catch (Exception)
            {
                return(NotFound());
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新数据,幂等
        /// </summary>
        /// <param name="key"></param>
        /// <param name="model"></param>
        public void Put([FromODataUri] string key, InformedConsentContentEntity model)
        {
            InformedConsentContentService service = new InformedConsentContentService();

            service.UpdateEntity(model);
        }