Beispiel #1
0
 public HttpResponseMessage ResourceUpdate(string type, string id, Resource resource, IFhirService service)
 {
     if (service != null && !string.IsNullOrEmpty(type) && resource != null && !string.IsNullOrEmpty(id))
     {
         var key    = Key.Create(type, id);
         var result = service.Update(key, resource);
         if (result != null)
         {
             return(result);
         }
     }
     throw new ArgumentException("Service is null, cannot update resource of type " + type);
 }
        public ServerFhirResponse Update(string type, Resource resource, string id = null)
        {
            string versionid = FhirHttpUtil.IfMatchVersionId(HttpContext.Request);
            Key    key       = Key.Create(type, id, versionid);

            if (key.HasResourceId())
            {
                return(fhirService.Update(key, resource));
            }
            else
            {
                SearchParams searchparams = SearchParams.FromUriParamList(HttpHeaderUtil.TupledParameters(HttpContext.Request));
                return(fhirService.ConditionalUpdate(key, resource, searchparams));
            }
        }
Beispiel #3
0
        public FhirResponse Update(string type, Resource resource, string id = null)
        {
            string versionid = Request.IfMatchVersionId();
            Key    key       = Key.Create(type, id, versionid);

            if (key.HasResourceId())
            {
                return(_fhirService.Update(key, resource));
            }
            else
            {
                return(_fhirService.ConditionalUpdate(key, resource,
                                                      SearchParams.FromUriParamList(Request.TupledParameters())));
            }
        }
Beispiel #4
0
        public HttpResponseMessage Update(string type, string id, ResourceEntry entry)
        {
            entry.Tags = Request.GetFhirTags(); // todo: move to model binder?

            // ballot: Update is a mix between name from CRUD (only update no create) and functionality from Rest PUT (Create or update)
            ResourceEntry newEntry = service.Update(type, id, entry, null);

            if (newEntry != null)
            {
                return(Request.StatusResponse(newEntry, HttpStatusCode.OK));
            }
            else
            {
                newEntry = service.Create(type, entry, id);
                return(Request.StatusResponse(newEntry, HttpStatusCode.Created));
            }
        }
Beispiel #5
0
        public ActionResult <FhirResponse> Update(string type, Resource resource, string id = null)
        {
            string versionId = Request.GetTypedHeaders().IfMatch?.FirstOrDefault()?.Tag.Buffer;
            Key    key       = Key.Create(type, id, versionId);

            if (key.HasResourceId())
            {
                Request.TransferResourceIdIfRawBinary(resource, id);

                return(new ActionResult <FhirResponse>(_fhirService.Update(key, resource)));
            }
            else
            {
                return(new ActionResult <FhirResponse>(_fhirService.ConditionalUpdate(key, resource,
                                                                                      SearchParams.FromUriParamList(Request.TupledParameters()))));
            }
        }