Exemple #1
0
        public void GenerateTaskContents()
        {
            var firstContent = new Content
            {
                ContentName   = "Yazi:OrnekYazi",
                ContentFields = new Dictionary <string, string>()
                {
                    { "Yazar", "Unal Ozyurt" },
                    { "Yazi", "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod" },
                    { "Puanlama", "4.8" },
                    { "Katagori", "Tarih" }
                }
            };

            var secondContent = new Content
            {
                ContentName   = "Katagori:Tarih",
                ContentFields = new Dictionary <string, string>()
                {
                    { "Toplam Yazi", "15903" },
                    { "Abone", "120" }
                }
            };

            if (!_contentService.ContentExistAsync(firstContent.ContentName).Result)
            {
                var contentMap = _mapper.Map <ContentCommand>(firstContent);
                _contentService.CreateContentAsync(contentMap).Wait();
            }

            if (!_contentService.ContentExistAsync(secondContent.ContentName).Result)
            {
                var contentMap = _mapper.Map <ContentCommand>(secondContent);
                _contentService.CreateContentAsync(contentMap).Wait();
            }
        }
Exemple #2
0
        public async Task <IActionResult> CreateContent([FromBody] ContentCommand command)
        {
            var existingContent = await _contentService.ContentExistAsync(command.ContentName);

            if (existingContent)
            {
                return(BadRequest("There is already a content with a same key"));
            }

            var createdContent = await _contentService.CreateContentAsync(command);

            if (createdContent)
            {
                return(BadRequest("Resource failed to create."));
            }

            var resourceUri = _uriService.GetContentUri(createdContent.ContentName);

            return(Created(resourceUri, createdContent));
        }