Example #1
0
        protected override void Seed(Photographers.Data.PhotographerContext context)
        {
            Photographer teo = new Photographer
            {
                Username     = "******",
                Password     = "******",
                Email        = "*****@*****.**",
                BirthDate    = DateTime.Now,
                RegisterDate = DateTime.Now.AddDays(-20)
            };

            context.Photographers
            .AddOrUpdate(p => p.Username, teo);
            context.SaveChanges();

            Picture demoPicture = new Picture()
            {
                Title          = "Demo",
                Caption        = "Demo",
                FileSystemPath = "/public/imags/demo.png"
            };

            context.Pictures.AddOrUpdate(i => i.Title, demoPicture);

            Album vitosha = new Album()
            {
                Name            = "Vitosha",
                BackgroundColor = "Blue",
                IsPublic        = true,
                //OwnerId = teo.Id
            };

            context.Albums.AddOrUpdate(a => a.Name, vitosha);
            vitosha.Pictures.Add(demoPicture);
            context.SaveChanges();

            PhotographerAlbum ph = new PhotographerAlbum()
            {
                Photographer_Id = teo.Id,
                Album_Id        = vitosha.Id,
                Role            = Role.Viewer
            };

            vitosha.Photographers.Add(ph);
            context.PhotographerAlbums.Add(ph);



            Tag mountainTag = new Tag()
            {
                Label = "mountain"
            };

            context.Tags.AddOrUpdate(t => t.Label, mountainTag);
            mountainTag.Albums.Add(vitosha);
            context.SaveChanges();
        }
Example #2
0
        protected override void Seed(Photographers.Context context)
        {
            Photographer a = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                Email        = "*****@*****.**",
                Birthdate    = new DateTime(2004, 9, 6),
                RegisterDate = new DateTime(2004, 9, 7)
            };

            context.Photographers.AddOrUpdate(p => p.Username, a);
            context.SaveChanges();

            Picture fdobai = new Picture()
            {
                Title            = "TukaSamFDobai",
                Caption          = "f Dobai",
                PathInFileSystem = "asdasd"
            };

            context.Pictures.AddOrUpdate(d => d.Title, fdobai);

            Album asd = new Album()
            {
                Name            = "Za Auschwitz",
                BackgroundColor = "#Ffff",
                IsPublic        = true,
            };


            context.Albums.AddOrUpdate(w => w.Name, asd);
            context.SaveChanges();

            asd.Pictures.Add(fdobai);
            context.SaveChanges();

            PhotographerAlbum ph = new PhotographerAlbum()
            {
                Photographer_Id = a.Id,
                Album_Id        = asd.Id,
                Role            = Role.Viewer
            };

            asd.Photographers.Add(ph);
            context.PhotographerAlbums.Add(ph);
            Tag ftag = new Tag()
            {
                Label = "#asd"
            };

            context.Tags.AddOrUpdate(e => e.Label, ftag);
            ftag.Albums.Add(asd);
            context.SaveChanges();
        }
Example #3
0
        public static void Seed(PhotoContext db)
        {
            Photographer photographer = new Photographer()
            {
                Username       = "******",
                Email          = "*****@*****.**",
                Password       = "******",
                BirthDate      = new DateTime(1990, 10, 02),
                RegisteredDate = new DateTime(2017, 10, 10)
            };

            Photographer photographerTwo = new Photographer()
            {
                Username       = "******",
                Email          = "*****@*****.**",
                Password       = "******",
                BirthDate      = new DateTime(1989, 09, 02),
                RegisteredDate = new DateTime(2016, 10, 10)
            };

            Photographer photographerThree = new Photographer()
            {
                Username       = "******",
                Email          = "*****@*****.**",
                Password       = "******",
                BirthDate      = new DateTime(1977, 09, 02),
                RegisteredDate = new DateTime(2016, 01, 10)
            };

            Album album = new Album()
            {
                BackgroundColor = "Black",
                IsPublic        = true
            };

            Album albumTwo = new Album()
            {
                BackgroundColor = "White",
                IsPublic        = false
            };

            PhotographerAlbum photographerAlbum = new PhotographerAlbum()
            {
                Album        = album,
                Photographer = photographer
            };

            PhotographerAlbum photographerAlbumTwo = new PhotographerAlbum()
            {
                Album        = album,
                Photographer = photographerTwo
            };

            PhotographerAlbum photographerAlbumThree = new PhotographerAlbum()
            {
                Album        = albumTwo,
                Photographer = photographerTwo
            };

            PhotographerAlbum photographerAlbumFour = new PhotographerAlbum()
            {
                Album        = albumTwo,
                Photographer = photographerThree
            };

            Picture picture = new Picture()
            {
                Caption = "Nature",
                Path    = @"C:\Users\Admin\Desktop\Pictures",
                Title   = "SummerView"
            };

            Picture pictureOne = new Picture()
            {
                Caption = "Animals",
                Path    = @"C:\Users\Admin\Desktop\Pictures",
                Title   = "Zoo"
            };

            Picture pictureTwo = new Picture()
            {
                Caption = "Forest",
                Path    = @"C:\Users\Admin\Desktop\Pictures",
                Title   = "Tree"
            };

            db.PictureAlbums.Add(new PictureAlbum()
            {
                Album   = album,
                Picture = picture
            });

            db.PictureAlbums.Add(new PictureAlbum()
            {
                Album   = album,
                Picture = pictureOne
            });

            db.PictureAlbums.Add(new PictureAlbum()
            {
                Album   = albumTwo,
                Picture = pictureTwo
            });

            db.SaveChanges();
        }
Example #4
0
        protected override void Seed(_5.Photographers.Data.PhotographerContext context)
        {
            Photographer teo = new Photographer
            {
                Username      = "******",
                Password      = "******",
                Email         = "*****@*****.**",
                BirthDate     = DateTime.Now,
                RegistereDate = DateTime.Now.AddDays(-20)
            };

            Photographer jim = new Photographer
            {
                Username      = "******",
                Password      = "******",
                Email         = "*****@*****.**",
                BirthDate     = DateTime.Now,
                RegistereDate = DateTime.Now.AddDays(-20)
            };

            context.Photographers.AddOrUpdate(p => p.Username, teo, jim);

            var demoPicture = new Picture()
            {
                Title          = "Demo",
                Caption        = "Demo",
                FileSystemPath = "../images/demo.png"
            };

            context.Pictures.AddOrUpdate(p => p.Title, demoPicture);

            var vitosha = new Album()
            {
                Name            = "Vitosha",
                BackgroundColor = "Black",
                IsPublic        = true,
            };

            context.Albums.AddOrUpdate(a => a.Name, vitosha);
            vitosha.Pictures.Add(demoPicture);
            context.SaveChanges();

            PhotographerAlbum ph = new PhotographerAlbum()
            {
                Photographer_Id = teo.Id,
                Album_Id        = vitosha.Id,
                Role            = Role.Viewer
            };

            vitosha.Photographers.Add(ph);
            context.PhotographerAlbums.Add(ph);

            var mountainTag = new Tag()
            {
                Label = "#mountain"
            };

            context.Tags.AddOrUpdate(t => t.Label, mountainTag);
            mountainTag.Albums.Add(vitosha);
            context.SaveChanges();
        }
Example #5
0
        protected override void Seed(PhotographersDB.PhotographersDBContext context)
        {
            var ph1 = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                RegisterDate = new DateTime(2000, 3, 23),
                BirthDate    = new DateTime(1991, 12, 20),
                Email        = "*****@*****.**"
            };

            var ph2 = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                RegisterDate = new DateTime(2001, 1, 21),
                BirthDate    = new DateTime(1991, 12, 13),
                Email        = "*****@*****.**"
            };

            var ph3 = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                RegisterDate = new DateTime(1989, 11, 25),
                BirthDate    = new DateTime(1991, 12, 23),
                Email        = "*****@*****.**"
            };

            context.Photographers.AddOrUpdate(x => x.Username, ph1);
            context.SaveChanges();
            context.Photographers.AddOrUpdate(x => x.Username, ph2);
            context.SaveChanges();
            context.Photographers.AddOrUpdate(x => x.Username, ph3);
            context.SaveChanges();

            var album1 = new Album()
            {
                Name            = "Album1",
                BackgroundColor = "red",
                IsPublic        = true
            };

            var album2 = new Album()
            {
                Name            = "Album2",
                BackgroundColor = "blue",
                IsPublic        = true
            };

            var album3 = new Album()
            {
                Name            = "Album3",
                BackgroundColor = "orange",
                IsPublic        = true
            };

            var album4 = new Album()
            {
                Name            = "Album4",
                BackgroundColor = "green",
                IsPublic        = true
            };

            context.Albums.AddOrUpdate(x => x.Name, album1);
            context.SaveChanges();
            context.Albums.AddOrUpdate(x => x.Name, album2);
            context.SaveChanges();
            context.Albums.AddOrUpdate(x => x.Name, album3);
            context.SaveChanges();
            context.Albums.AddOrUpdate(x => x.Name, album4);
            context.SaveChanges();

            PhotographerAlbum pa1 = new PhotographerAlbum()
            {
                Photographer_Id = ph1.Id,
                Album_Id        = album1.Id,
                Role            = Role.Owner
            };

            album1.Photographers.Add(pa1);

            PhotographerAlbum pa2 = new PhotographerAlbum()
            {
                Photographer_Id = ph1.Id,
                Album_Id        = album2.Id,
                Role            = Role.Owner
            };

            album2.Photographers.Add(pa2);

            PhotographerAlbum pa3 = new PhotographerAlbum()
            {
                Photographer_Id = ph2.Id,
                Album_Id        = album3.Id,
                Role            = Role.Owner
            };

            album3.Photographers.Add(pa3);

            PhotographerAlbum pa4 = new PhotographerAlbum()
            {
                Photographer_Id = ph3.Id,
                Album_Id        = album4.Id,
                Role            = Role.Viewer
            };

            album4.Photographers.Add(pa4);

            var picture1 = new Picture()
            {
                Caption  = "someCaption1",
                FilePath = "c:\\Albums1",
                Title    = "BestTitle1"
            };

            var picture2 = new Picture()
            {
                Caption  = "someCaption2",
                FilePath = "c:\\Albums2",
                Title    = "BestTitle2"
            };

            var picture3 = new Picture()
            {
                Caption  = "someCaption3",
                FilePath = "c:\\Albums3",
                Title    = "BestTitle3"
            };

            context.PhotographerAlbums.Add(pa1);
            context.PhotographerAlbums.Add(pa2);
            context.PhotographerAlbums.Add(pa3);
            context.PhotographerAlbums.Add(pa4);

            context.Pictures.AddOrUpdate(x => x.Caption, picture1);
            context.SaveChanges();
            context.Pictures.AddOrUpdate(x => x.Caption, picture2);
            context.SaveChanges();
            context.Pictures.AddOrUpdate(x => x.Caption, picture3);
            context.SaveChanges();

            var tag1 = new Tag()
            {
                Label = "#blessed"
            };

            context.Tags.AddOrUpdate(x => x.Label, tag1);
            context.SaveChanges();

            var tag2 = new Tag()
            {
                Label = "#nofiler"
            };

            context.Tags.AddOrUpdate(x => x.Label, tag2);
            context.SaveChanges();

            var tag3 = new Tag()
            {
                Label = "#wokeuplikethis"
            };

            context.Tags.AddOrUpdate(x => x.Label, tag3);
            context.SaveChanges();

            album1.Tags.Add(tag1);
            album1.Tags.Add(tag2);
            album2.Tags.Add(tag3);
            album2.Tags.Add(tag2);
            album3.Tags.Add(tag1);
            album4.Tags.Add(tag3);

            album1.Pictures.Add(picture1);
            album1.Pictures.Add(picture2);
            album2.Pictures.Add(picture1);
            album2.Pictures.Add(picture3);
            album3.Pictures.Add(picture3);
            album3.Pictures.Add(picture2);
            album4.Pictures.Add(picture1);
            context.SaveChanges();
        }
Example #6
0
        protected override void Seed(PhotographyContext context)
        {
            Photographer dragan = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                Email        = "*****@*****.**",
                BirthDate    = new DateTime(1992, 01, 08),
                RegisterDate = new DateTime(2010, 10, 10)
            };

            Photographer stamen = new Photographer()
            {
                Username     = "******",
                Password     = "******",
                Email        = "*****@*****.**",
                BirthDate    = new DateTime(1992, 01, 08),
                RegisterDate = new DateTime(2010, 10, 10)
            };

            context.Photographers.AddOrUpdate(p => p.Username, dragan, stamen);
            context.SaveChanges();

            Picture picture = new Picture()
            {
                Title            = "Mountain",
                Caption          = "Peak",
                PathOnFileSystem = "../pictures/mountains"
            };

            Picture picture2 = new Picture()
            {
                Title            = "River",
                Caption          = "Water",
                PathOnFileSystem = "../pictures/rivers"
            };

            context.Pictures.AddOrUpdate(pic => pic.Title, picture, picture2);
            context.SaveChanges();

            Tag tag = new Tag()
            {
                Name = "rocks"
                       // Tag name doesn't start with '#' but it's transformed to valid tag with the 'TagTansformer' class;
            };

            Tag tag2 = new Tag()
            {
                Name = "#   fishes"
                       //Tag name contains white spaces but it's transformed to valid tag with the 'TagTansformer' class;
            };

            List <Tag> tags = new List <Tag>();

            tags.Add(tag);
            tags.Add(tag2);

            foreach (var currentTag in tags)
            {
                currentTag.Name = TagTansformer.Transform(currentTag.Name);
            }

            foreach (var currentTag in tags)
            {
                context.Tags.AddOrUpdate(t => t.Name, currentTag);
            }

            context.SaveChanges();

            Album album = new Album()
            {
                Name            = "Mountains",
                BackgroundColor = "Green and Brown",
                IsPublic        = true
            };

            Album album2 = new Album()
            {
                Name            = "Rivers",
                BackgroundColor = "Green and Blue",
                IsPublic        = true
            };

            context.Albums.AddOrUpdate(a => a.Name, album, album2);

            context.SaveChanges();

            PhotographerAlbum photographerAlbumDragan = new PhotographerAlbum()
            {
                Album_Id        = album.Id,
                Photographer_Id = dragan.Id,
                Role            = Role.Owner
            };

            PhotographerAlbum photographerAlbumStamen = new PhotographerAlbum()
            {
                Album_Id        = album2.Id,
                Photographer_Id = stamen.Id,
                Role            = Role.Owner
            };

            PhotographerAlbum photographerAlbumDragan2 = new PhotographerAlbum()
            {
                Album_Id        = album2.Id,
                Photographer_Id = dragan.Id,
                Role            = Role.Viewer
            };

            PhotographerAlbum photographerAlbumStamen2 = new PhotographerAlbum()
            {
                Album_Id        = album.Id,
                Photographer_Id = stamen.Id,
                Role            = Role.Viewer
            };

            // After executing the Seed method:
            // In the first album Dragan is an owner and Stamen is a viewer;
            // In the second album Stamen is an owner and Dragan is a viewer;
            context.PhotographerAlbums.AddOrUpdate(pa => new { pa.Photographer_Id, pa.Album_Id },
                                                   photographerAlbumDragan, photographerAlbumStamen,
                                                   photographerAlbumDragan2, photographerAlbumStamen2);

            // Album-Pictures many-to-many relationship it's working - table [dbo].[PictureAlbums] it's filling with data;
            album.Pictures.Add(picture);
            album2.Pictures.Add(picture2);

            // Album-Tags many-to-many relationship it's working - table [dbo].[TagAlbums] it's filling with data;
            album.Tags.Add(tag);
            album2.Tags.Add(tag2);

            context.SaveChanges();
        }