コード例 #1
0
ファイル: ServiceHandler.cs プロジェクト: verzada/FhirStarter
 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);
 }
コード例 #2
0
        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));
            }
        }
コード例 #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())));
            }
        }
コード例 #4
0
ファイル: FhirController.cs プロジェクト: HowardEdidin/spark
        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));
            }
        }
コード例 #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()))));
            }
        }