Beispiel #1
0
        public ActionResult CreateContent(CreateContentRequest req)
        {
            CreateContentResponse response = new CreateContentResponse();
            ContentModel          model    = new ContentModel()
            {
                Link         = req.Link,
                IsActive     = true,
                CreatedDate  = DateTime.Now,
                ModifiedDate = DateTime.Now
            };
            var res = model.CreateContent(model, req.UserId, dbFactory);

            response.link      = req.Link;
            response.id        = res;
            response.userid    = req.UserId;
            response.IsSuccess = true;
            return(Json(response));
        }
        public async Task <IActionResult> Create(CreateContentRequest request)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var createContentModel = mapper.Map <CreateContentModel>(request);
                    var clientId           = await contentService.CreateAsync(createContentModel);

                    return(Ok(new CreateContentResponse {
                        Id = clientId
                    }));
                }

                return(BadRequest());
            }
            catch (Exception e)
            {
                return(ExceptionResult(e));
            }
        }
Beispiel #3
0
        public async Task WhenIRequestThatTheContentIsCreated(string contentItem)
        {
            Cms.Content          item = this.scenarioContext.Get <Cms.Content>(contentItem);
            CreateContentRequest createContentRequest = ContentSpecHelpers.ContentAsCreateContentRequest(item);

            ContentClient client = this.featureContext.Get <ContentClient>();

            try
            {
                SwaggerResponse <ContentResponse> response = await client.CreateContentAsync(
                    this.featureContext.GetCurrentTenantId(),
                    item.Slug,
                    createContentRequest).ConfigureAwait(false);

                this.scenarioContext.StoreLastApiResponse(response);
            }
            catch (SwaggerException ex)
            {
                this.scenarioContext.StoreLastApiException(ex);
            }
        }
        public async Task <OpenApiResult> CreateContent(string tenantId, string slug, CreateContentRequest body)
        {
            IContentStore contentStore = await this.contentStoreFactory.GetContentStoreForTenantAsync(tenantId).ConfigureAwait(false);

            Content request = body.AsContent(slug);

            Content result = await contentStore.StoreContentAsync(request).ConfigureAwait(false);

            string etag = EtagHelper.BuildEtag(nameof(Content), result.ETag);

            HalDocument resultDocument = this.contentMapper.Map(result, new ResponseMappingContext {
                TenantId = tenantId
            });

            WebLink location = resultDocument.GetLinksForRelation("self").First();

            OpenApiResult response = this.CreatedResult(location.Href, resultDocument);

            response.Results.Add(HeaderNames.ETag, etag);

            return(response);
        }