Exemplo n.º 1
0
        public async Task <IActionResult> CreateAsync([FromBody] Client.Maraphone.Task.ContentBuildInfo contentBuildInfo,
                                                      CancellationToken cancellationToken)
        {
            if (contentBuildInfo == null)
            {
                var error = ServiceErrorResponses.BodyIsMissing("ContentBuildInfo");
                return(this.BadRequest(error));
            }

            var contentType = HttpContext.Request.Headers["Skima-Data-Type"].FirstOrDefault();

            if (contentType == null)
            {
                return(this.BadRequest("Content not specified"));
            }

            var contentCreationInfo = new ContentCreationInfo(contentType, contentBuildInfo.Data);
            var document            = await contentRepository.CreateAsync(contentCreationInfo, cancellationToken);

            var result = new ContentResult
            {
                Id = document.Id
            };

            return(CreatedAtRoute(
                       "GetContent",
                       new { id = result.Id },
                       result));
        }