public Photocourse Create(PhotocourseTransitional entity)
        {
            Guard.WhenArgument(entity, GlobalConstants.PhotocourseTransitionalRequiredExceptionMessage)
            .IsNull()
            .Throw();

            entity.Description      = this.sanitizer.Sanitize(entity.Description);
            entity.DescriptionShort = this.sanitizer.Sanitize(entity.DescriptionShort);
            entity.OtherInfo        = this.sanitizer.Sanitize(entity.OtherInfo);

            var entityImages = entity.Images as ICollection <Image>;
            ////var entityStudents = entity.Students as ICollection<Student>;

            Photocourse entityDb = this.modelDbFactory.CreatePhotocourse(
                entity.Name,
                entity.DescriptionShort,
                entity.Description,
                entity.OtherInfo,
                entity.Teacher,
                entity.DurationHours,
                entity.MaxStudents,
                entity.StartDate,
                entity.EndDate,
                entity.ImageCoverId,
                entity.ImageCover,
                entityImages,
                null);

            this.photocourses.Create(entityDb);
            this.context.Save();

            return(entityDb);
        }
 public Image CreateImage(
     string fileName,
     string fileExtension,
     string urlPath,
     ImageFormatType format,
     Guid?photocourseId,
     Photocourse photocourse)
 {
     return(new Image
     {
         FileName = fileName,
         FileExtension = fileExtension,
         UrlPath = urlPath,
         Format = format,
         PhotocourseId = photocourseId,
         Photocourse = photocourse
     });
 }
Example #3
0
        public void Setters_ShouldSetExpectedProperties()
        {
            // Arrange
            Fixture fixture                   = new Fixture();
            var     expectedName              = fixture.Create <string>();
            var     expectedDescriptionShort  = fixture.Create <string>();
            var     expectedDescription       = fixture.Create <string>();
            var     expectedOtherInfo         = fixture.Create <string>();
            var     expectedDurationHours     = fixture.Create <ushort>();
            var     expectedStartDate         = fixture.Create <DateTime>();
            var     expectedEndDate           = fixture.Create <DateTime>();
            var     expectedTeacher           = fixture.Create <string>();
            var     expectedMaxStudents       = fixture.Create <int>();
            var     expectedPhotoArtServiceId = fixture.Create <int>();

            var photocourse = new Photocourse
            {
                Name             = expectedName,
                DescriptionShort = expectedDescriptionShort,
                Description      = expectedDescription,
                OtherInfo        = expectedOtherInfo,
                DurationHours    = expectedDurationHours,
                StartDate        = expectedStartDate,
                EndDate          = expectedEndDate,
                Teacher          = expectedTeacher,
                MaxStudents      = expectedMaxStudents
            };

            // Act & Assert
            Assert.AreEqual(expectedName, photocourse.Name);
            Assert.AreEqual(expectedDescriptionShort, photocourse.DescriptionShort);
            Assert.AreEqual(expectedDescription, photocourse.Description);
            Assert.AreEqual(expectedOtherInfo, photocourse.OtherInfo);
            Assert.AreEqual(expectedDurationHours, photocourse.DurationHours);
            Assert.AreEqual(expectedStartDate, photocourse.StartDate);
            Assert.AreEqual(expectedEndDate, photocourse.EndDate);
            Assert.AreEqual(expectedTeacher, photocourse.Teacher);
            Assert.AreEqual(expectedMaxStudents, photocourse.MaxStudents);
            Assert.IsInstanceOf <HashSet <Image> >(photocourse.Images);
            Assert.IsInstanceOf <HashSet <Student> >(photocourse.Students);
        }
Example #4
0
        public static void SeedPhotocourses(ApplicationDbContext context)
        {
            if (context.Photocourses.Any())
            {
                return;
            }

            var photocourses1 = new Photocourse()
            {
                Name             = "Photo courses 1",
                DescriptionShort = "Tincidunt integer eu augue augue nunc elit dolor.",
                Description      = "Tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel. \n\rTincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.",
                DurationHours    = 42,
                StartDate        = DateTime.UtcNow.AddDays(7),
                EndDate          = DateTime.UtcNow.AddDays(49),
                MaxStudents      = 10,
                ImageCoverId     = imageFirstId,
                Images           = imagesList1
            };

            context.Photocourses.Add(photocourses1);

            var photocourses2 = new Photocourse()
            {
                Name             = "Photo courses 2",
                DescriptionShort = "Vehicula ut laoreet ac, tincidunt integer.",
                Description      = "Vehicula ut laoreet ac, tincidunt integer eu augue augue nunc elit dolor, luctus placerat scelerisque euismod, iaculis eu lacus nunc mi elit, vehicula ut laoreet ac, aliquam sit amet justo nunc tempor, metus vel.",
                DurationHours    = 24,
                StartDate        = DateTime.UtcNow.AddDays(4),
                EndDate          = DateTime.UtcNow.AddDays(28),
                MaxStudents      = 7,
                ImageCoverId     = imageSecondId,
                Images           = imagesList2
            };

            context.Photocourses.Add(photocourses2);

            //// End add.
            context.SaveChanges();
        }