Example #1
0
        public virtual async Task <IActionResult> GetSampleAsync([FromRoute][Required] Guid id, CancellationToken cancellationToken = default)
        {
            var sample = await this.WebApi
                         .GetAsync <Sample>(id, cancellationToken);

            if (sample == null)
            {
                return(this.NotFound());
            }

            var response = new GetSampleResponse(sample);

            return(this.Ok(response));
        }
Example #2
0
        public virtual async Task <IActionResult> CreateSampleAsync([FromBody][Required] CreateSampleRequest request, CancellationToken cancellationToken = default)
        {
            var provider = await this.WebApi
                           .CreateAsync <Sample>(new CreateRequest
            {
                Entity = new Sample
                {
                    Name = request.Name
                }
            }, cancellationToken);

            var response = new GetSampleResponse(provider);

            return(this.Created("create", response));
        }