Ejemplo n.º 1
0
        TrendGetAllDto ITrendBusinessLogic.Create(TrendCreateDto trend)
        {
            Trend createdTrend = mapper.Map <Trend>(trend);

            ImageGetDto image = imageService.Create(new ImageCreateDto()
            {
                Image  = trend.Image,
                Prefix = "trends"
            });

            CreateContentScanTaskDto createContentScanTaskDto = new CreateContentScanTaskDto()
            {
                ImageUrl                                     = image != null?imageService.GetFullImageUrl(image.Url) : null,
                                                 Text        = trend.Description,
                                                 CallbackUrl = $"/api/v1/trends/{createdTrend.Id}/content-scan-result"
            };

            contentScanTaskService.CreateTask(createContentScanTaskDto);

            createdTrend.ImageUrl = image != null ? image.Url : imageService.GetDefaultImageUrl();
            trendRepository.Insert(createdTrend);
            trendRepository.SaveChanges();

            return(mapper.Map <TrendGetAllDto>(createdTrend));
        }
Ejemplo n.º 2
0
        public void Create_InsertsTheTrendGiven()
        {
            //Arrange
            TrendCreateDto trendCreateDto = new TrendCreateDto
            {
                CreatorId = Guid.Parse("3fa85f64-5717-4562-b3fc-2c963f66afa6")
            };

            //Act
            TrendGetAllDto trendGetAllDto = systemUnderTest.Create(trendCreateDto);

            //Assert
            Assert.NotNull(trendGetAllDto);
            Assert.True(trendGetAllDto.CreatorId.Equals(trendCreateDto.CreatorId));
        }