public async Task SeedAsync(ApplicationDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext.ProjectPictures.Any())
            {
                return;
            }

            var projectPictures = new List <ProjectPicture>();

            foreach (var project in dbContext.Projects)
            {
                var projectPicture1 = new ProjectPicture
                {
                    ProjectId  = project.Id,
                    PictureUrl = project.ImageUrl,
                };
                var projectPicture2 = new ProjectPicture
                {
                    ProjectId  = project.Id,
                    PictureUrl = "https://res.cloudinary.com/sharwinchester/image/upload/c_fill,h_600,w_1200/v1587604993/kelly-sikkema-NBkMT8duVSI-unsplash_py5fkm.jpg",
                };
                projectPictures.Add(projectPicture1);
                projectPictures.Add(projectPicture2);
            }

            foreach (var projectPicture in projectPictures)
            {
                await dbContext.ProjectPictures.AddAsync(projectPicture);

                await dbContext.SaveChangesAsync();
            }
        }
        public async Task <int> CreateAsync(int categoryId, string content, string title, string projectStatus, double progress, string userId, List <string> imageUrls)
        {
            var project = new Project
            {
                CategoryId    = categoryId,
                Content       = content,
                Title         = title,
                ProjectStatus = (ProjectStatus)Enum.Parse(typeof(ProjectStatus), projectStatus),
                Progress      = projectStatus == "Finished" ? 100 : progress,
                UserId        = userId,
                ImageUrl      = imageUrls.First().Insert(54, "c_fill,h_600,w_1200/"),
            };

            await this.projectsRepository.AddAsync(project);

            await this.projectsRepository.SaveChangesAsync();

            foreach (var url in imageUrls)
            {
                var projectPicture = new ProjectPicture
                {
                    PictureUrl = url.Insert(54, "c_fill,h_600,w_1200/"),
                    ProjectId  = project.Id,
                };

                await this.projectPicturesRepository.AddAsync(projectPicture);

                await this.projectPicturesRepository.SaveChangesAsync();
            }

            return(project.Id);
        }
        public async Task GetPictureUrls_ShouldReturnRightPictureUrls()
        {
            this.Initialize();
            var testPictureProjectEntity1 = new ProjectPicture {
                ProjectId = 1, PictureUrl = "SomePictureUrl"
            };
            var testPictureProjectEntity2 = new ProjectPicture {
                ProjectId = 1, PictureUrl = "SomeOtherPictureUrl"
            };
            var testPictureProjectEntity3 = new ProjectPicture {
                ProjectId = 2, PictureUrl = "YetAnotherPictureUrl"
            };

            await this.projectPicturesRepository.AddAsync(testPictureProjectEntity1);

            await this.projectPicturesRepository.AddAsync(testPictureProjectEntity2);

            await this.projectPicturesRepository.AddAsync(testPictureProjectEntity3);

            await this.projectPicturesRepository.SaveChangesAsync();

            var resultPictureUrls = this.service.GetPictureUrls(1);

            Assert.Equal(testPictureProjectEntity1.PictureUrl, resultPictureUrls.ElementAt(0));
            Assert.Equal(testPictureProjectEntity2.PictureUrl, resultPictureUrls.ElementAt(1));
            this.Dispose();
        }