Example #1
0
        public async Task <IActionResult> ConditionalDelete(string typeParameter, [FromQuery] bool hardDelete, [FromQuery(Name = KnownQueryParameterNames.Count)] int?maxDeleteCount)
        {
            IReadOnlyList <Tuple <string, string> > conditionalParameters = GetQueriesForSearch();

            DeleteResourceResponse response = await _mediator.Send(new ConditionalDeleteResourceRequest(typeParameter, conditionalParameters, hardDelete ? DeleteOperation.HardDelete : DeleteOperation.SoftDelete, maxDeleteCount.GetValueOrDefault(1)), HttpContext.RequestAborted);

            if (maxDeleteCount.HasValue)
            {
                Response.Headers.Add(KnownHeaders.ItemsDeleted, (response?.ResourcesDeleted ?? 0).ToString(CultureInfo.InvariantCulture));
            }

            return(FhirResult.NoContent().SetETagHeader(response?.WeakETag));
        }
Example #2
0
        public void GivenANoContentStatus_WhenReturningAResult_ThenTheStatusCodeIsSetCorrectly()
        {
            var result  = FhirResult.NoContent();
            var context = new ActionContext
            {
                HttpContext = new DefaultHttpContext(),
            };

            result.ExecuteResult(context);

            Assert.Null(result.Result);
            Assert.Equal(HttpStatusCode.NoContent, result.StatusCode.GetValueOrDefault());
        }
Example #3
0
        public async Task <IActionResult> Delete(string typeParameter, string idParameter, [FromQuery] bool hardDelete)
        {
            string policy = PolicyNames.WritePolicy;

            if (hardDelete)
            {
                policy = PolicyNames.HardDeletePolicy;
            }

            AuthorizationResult authorizationResult = await _authorizationService.AuthorizeAsync(User, policy);

            if (!authorizationResult.Succeeded)
            {
                return(Forbid());
            }

            DeleteResourceResponse response = await _mediator.DeleteResourceAsync(new ResourceKey(typeParameter, idParameter), hardDelete, HttpContext.RequestAborted);

            return(FhirResult.NoContent().SetETagHeader(response.WeakETag));
        }
Example #4
0
        public async Task <IActionResult> Delete(string typeParameter, string idParameter, [FromQuery] bool hardDelete)
        {
            DeleteResourceResponse response = await _mediator.DeleteResourceAsync(new ResourceKey(typeParameter, idParameter), hardDelete, HttpContext.RequestAborted);

            return(FhirResult.NoContent().SetETagHeader(response.WeakETag));
        }
Example #5
0
        public async Task <IActionResult> PurgeHistory(string typeParameter, string idParameter)
        {
            DeleteResourceResponse response = await _mediator.DeleteResourceAsync(new ResourceKey(typeParameter, idParameter), DeleteOperation.PurgeHistory, HttpContext.RequestAborted);

            return(FhirResult.NoContent().SetETagHeader(response.WeakETag));
        }