示例#1
0
 public static void InitChats(EFDBContext context)
 {
     if (!context.Chats.Any())
     {
         context.Chats.Add(new Chat {
             Id = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF")
         });
         context.SaveChanges();
     }
     if (!context.UserChats.Any())
     {
         var u1 = context.ApplicationsUsers.Where(u => u.Email == "1").FirstOrDefault();
         var u2 = context.ApplicationsUsers.Where(u => u.Email == "2").FirstOrDefault();
         context.UserChats.Add(new UserChat
         {
             ChatId = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
             UserId = u1.Id
         });
         context.UserChats.Add(new UserChat
         {
             ChatId = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
             UserId = u2.Id
         });
         context.SaveChanges();
     }
 }
示例#2
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directory.Any())
            {
                context.Directory.Add(new DbDirectory {
                    Title = "First Directory",
                    Html  = "Directory Content"
                });
                context.Directory.Add(new DbDirectory {
                    Title = "Second Directory",
                    Html  = "Directory Content"
                });
                context.SaveChanges();
            }

            if (context.Material.Any())
            {
                return;
            }
            context.Material.Add(new DbMaterial {
                Title       = "First Material",
                Html        = "Material Content",
                DirectoryId = context.Directory.ToList().First().Id
            });
            context.Material.Add(new DbMaterial {
                Title       = "Second Material",
                Html        = "Material Content",
                DirectoryId = context.Directory.ToList().Last().Id
            });
            context.SaveChanges();
        }
示例#3
0
 public static void InitData(EFDBContext context)
 {
     if (!context.Directories.Any())
     {
         context.Directories.Add(new Directory {
             Title = "First Directory", Html = "<b>Directory Content</b>"
         });
         context.Directories.Add(new Directory {
             Title = "Second Directory", Html = "<b>Directory Content</b>"
         });
         context.Directories.Add(new Directory {
             Title = "Third Directory", Html = "<b>Directory Content</b>"
         });
         context.SaveChanges();
     }
     if (!context.Materials.Any())
     {
         context.Materials.Add(new Material {
             Title = "First Material", Html = "<b>Material Content</b>", DirectoryId = context.Directories.First().Id
         });
         context.Materials.Add(new Material {
             Title = "Second Material", Html = "<b>Material Content</b>", DirectoryId = context.Directories.Last().Id
         });
         context.SaveChanges();
     }
 }
示例#4
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directory.Any())
            {
                context.Directory.Add(new Entityes.Directory()
                {
                    Title = "First Directory", Html = "<b>Directory Content</b>"
                });
                context.Directory.Add(new Entityes.Directory()
                {
                    Title = "Second Directory", Html = "<b>Directory Content</b>"
                });
                context.SaveChanges();

                context.Material.Add(new Entityes.Material()
                {
                    Title = "First Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.First().Id
                });
                context.Material.Add(new Entityes.Material()
                {
                    Title = "Second Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.First().Id
                });
                context.Material.Add(new Entityes.Material()
                {
                    Title = "Third Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.Last().Id
                });
                context.SaveChanges();
            }
        }
示例#5
0
        /// <summary>
        /// заполнение БД
        /// </summary>
        /// <param name="context"></param>
        public static void InitData(EFDBContext context)
        {
            if (!context.Directory.Any())
            {
                context.Directory.Add(new Directory()
                {
                    Title = "First Directory", Html = "<b>Directory content</b>"
                });
                context.Directory.Add(new Directory()
                {
                    Title = "Second Directory", Html = "<b>Directory content</b>"
                });
                context.Directory.Add(new Directory()
                {
                    Title = "Third Directory", Html = "<b>Directory content</b>"
                });

                context.SaveChanges(); //save all changes

                context.Material.Add(new Material()
                {
                    Title = "First Material", Html = "<i>Material content</i>", DirectoryID = context.Directory.First().Id
                });
                context.Material.Add(new Material()
                {
                    Title = "Second Material", Html = "<i>Material content</i>", DirectoryID = context.Directory.First().Id + 1
                });
                context.Material.Add(new Material()
                {
                    Title = "Third Material", Html = "<i>Material content</i>", DirectoryID = context.Directory.Last().Id
                });

                context.SaveChanges(); //save all changes
            }
        }
示例#6
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Categories.Any())
            {
                context.Categories.Add(new Entityes.Category()
                {
                    Name = "Meat", Title = "Meat of wild animals, poultry meat"
                });
                context.Categories.Add(new Entityes.Category()
                {
                    Name = "Fish", Title = "Sea fish, freshwater fish"
                });
                context.Categories.Add(new Entityes.Category()
                {
                    Name = "Vegetables", Title = "Tuber vegetables, root vegetables, legumes"
                });
                context.SaveChanges();

                context.Products.Add(new Entityes.Product()
                {
                    Name = "Chicken", Title = "Chicken's description", Price = 250, CategoryId = context.Categories.First().Id
                });
                context.Products.Add(new Entityes.Product()
                {
                    Name = "Turkey", Title = "Turkey's description", Price = 350, CategoryId = context.Categories.First().Id
                });
                context.Products.Add(new Entityes.Product()
                {
                    Name = "Potatoes", Title = "Potatoes's description", Price = 28, CategoryId = context.Categories.Last().Id
                });
                context.SaveChanges();
            }
        }
示例#7
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directories.Any())
            {
                context.Directories.Add(new Directory()
                {
                    Title = "Первый раздел", Html = "<h4>Введение в технологию ASP.NET</h4>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Второй раздел",
                    Html  = "<h4>Особенности ASP.NET WebForms</h4>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Третий раздел",
                    Html  = "<h4>Преимущества ASP.NET Core</h4>"
                });

                context.SaveChanges();

                if (!context.Materials.Any())
                {
                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-1", Html = "Аннотация-1", DirectoryId = 1
                    });
                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-2", Html = "Аннотация-2", DirectoryId = 1
                    });

                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-3", Html = "Аннотация-3", DirectoryId = 2
                    });
                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-4", Html = "Аннотация-4", DirectoryId = 2
                    });

                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-5", Html = "Аннотация-5", DirectoryId = 3
                    });
                    context.Materials.Add(new Material()
                    {
                        Title = "Параграф-6", Html = "Аннотация-6", DirectoryId = 3
                    });

                    context.SaveChanges();
                }
            }
        }
示例#8
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directories.Any())
            {
                context.Directories.Add(new Entites.Directory()
                {
                    Title = "First Directory", Html = "<b>Directory 1 content</b>"
                });
                context.Directories.Add(new Entites.Directory()
                {
                    Title = "Second Directory", Html = "<b>Directory 2 content</b>"
                });
                context.Directories.Add(new Entites.Directory()
                {
                    Title = "Third Directory", Html = "<b>Directory 3 content</b>"
                });
                context.Directories.Add(new Entites.Directory()
                {
                    Title = "Four Directory", Html = "<b>Directory 4 content</b>"
                });
                context.Directories.Add(new Entites.Directory()
                {
                    Title = "Five Directory", Html = "<b>Directory 5 content</b>"
                });

                context.SaveChanges();

                context.Materials.Add(new Entites.Material()
                {
                    Title = "1 Material", Html = "<i>Material content 1</i>", DirectoryId = 1
                });
                context.Materials.Add(new Entites.Material()
                {
                    Title = "2 Material", Html = "<i>Material content 2</i>", DirectoryId = 2
                });
                context.Materials.Add(new Entites.Material()
                {
                    Title = "3 Material", Html = "<i>Material content 3</i>", DirectoryId = 3
                });
                context.Materials.Add(new Entites.Material()
                {
                    Title = "4 Material", Html = "<i>Material content 4</i>", DirectoryId = 5
                });
                context.Materials.Add(new Entites.Material()
                {
                    Title = "5 Material", Html = "<i>Material content 5</i>", DirectoryId = 2
                });

                context.SaveChanges();
            }
        }
示例#9
0
 public static void InitData(EFDBContext context)
 {
     if (!context.Players.Any() && !context.Teams.Any())
     {
         context.Teams.AddRange(new List <Team> {
             new Team {
                 Name = "Барселона"
             },
             new Team {
                 Name = "Реал Мадрид"
             },
             new Team {
                 Name = "Манчестер Юнайтед"
             }
         });
         context.SaveChanges();
         context.Players.AddRange(new List <Player> {
             new Player {
                 FirstName = "Татьяна", LastName = "Александрова", TeamId = 1, Gender = "Женский", BirthDay = "1997-03-03", Country = "Россия"
             },
             new Player {
                 FirstName = "Александр ", LastName = "Белозерцев", TeamId = 1, Gender = "Мужской", BirthDay = "1998-05-08", Country = "США"
             },
             new Player {
                 FirstName = "Елена", LastName = "Богородицкая", TeamId = 1, Gender = "Женский", BirthDay = "1997-12-07", Country = "Италия"
             },
             new Player {
                 FirstName = "Елена", LastName = "Великанова", TeamId = 2, Gender = "Женский", BirthDay = "1996-06-10", Country = "Италия"
             },
             new Player {
                 FirstName = "Алла", LastName = "Власова", TeamId = 2, Gender = "Женский", BirthDay = "1996-08-03", Country = "США"
             },
             new Player {
                 FirstName = "Павел", LastName = "Гребенников ", TeamId = 2, Gender = "Мужской", BirthDay = "1997-01-02", Country = "Россия"
             },
             new Player {
                 FirstName = "Вадим", LastName = "Гильмутдинов", TeamId = 3, Gender = "Мужской", BirthDay = "1995-02-13", Country = "Италия"
             },
             new Player {
                 FirstName = "Даниил", LastName = "Насыров", TeamId = 3, Gender = "Мужской", BirthDay = "1995-11-15", Country = "США"
             },
             new Player {
                 FirstName = "Николай", LastName = "Сергеев", TeamId = 3, Gender = "Мужской", BirthDay = "1997-09-20", Country = "США"
             },
             new Player {
                 FirstName = "Куперт", LastName = "Захаров", TeamId = 3, Gender = "Мужской", BirthDay = "2000-02-27", Country = "Россия"
             }
         });
         context.SaveChanges();
     }
 }
示例#10
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directory.Any())
            {
                context.Directory.Add(new Entityes.Directory()
                {
                    Title = "First Directory", Html = "<b>Directory Content</b>"
                });
                context.Directory.Add(new Entityes.Directory()
                {
                    Title = "Second Directory", Html = "<b>Directory Content</b>"
                });
                context.SaveChanges();

                context.Material.Add(new Entityes.Material()
                {
                    Title = "First Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.First().Id
                });
                context.Material.Add(new Entityes.Material()
                {
                    Title = "Second Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.First().Id
                });
                context.Material.Add(new Entityes.Material()
                {
                    Title = "Third Material", Html = "<i>Material Content</i>", DirectoryId = context.Directory.Last().Id
                });
                context.SaveChanges();
            }

            if (!context.Message.Any())
            {
                context.Message.Add(new Entityes.Message()
                {
                    Text = "Hi John", Author = "Greg", Time = DateTime.Now.ToString("HH:mm:ss")
                });
                context.Message.Add(new Entityes.Message()
                {
                    Text = "F**k you Greg", Author = "John", Time = DateTime.Now.ToString("HH:mm:ss")
                });
                context.SaveChanges();
            }
        }
示例#11
0
 public static void InitData(EFDBContext context)
 {
     if (!context.Products.Any())
     {
         context.Products.Add(new Product()
         {
             Title = "First product"
         });
         context.SaveChanges();
     }
 }
示例#12
0
        public static void InitData(EFDBContext context)
        {
            if (!EnumerableExtensions.Any(context.Directories))
            {
                context.Directories.Add(new Directory()
                {
                    Title = "First directory", Html = "<b>Directory content 1</b>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Second directory", Html = "<b>Directory content 2</b>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Third directory", Html = "<b>Directory content 3</b>"
                });
                context.SaveChanges();

                context.Materials.Add(new Material()
                {
                    Title       = "First material",
                    Html        = "<i>Material content 1</i>",
                    DirectoryId = context.Directories.First().Id
                });
                context.Materials.Add(new Material()
                {
                    Title       = "Second material",
                    Html        = "<i>Material content 2</i>",
                    DirectoryId = context.Directories.First().Id
                });
                context.Materials.Add(new Material()
                {
                    Title       = "Third material",
                    Html        = "<i>Material content 3</i>",
                    DirectoryId = context.Directories.Last().Id
                });

                context.SaveChanges();
            }
        }
示例#13
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directories.Any())
            {
                context.Directories.Add(new Directory()
                {
                    Title = "First Directory", Html = "<b>Directory Content1</b>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Second Directory", Html = "<b>Directory Content2</b>"
                });
                context.Directories.Add(new Directory()
                {
                    Title = "Third Directory", Html = "<b>Directory Content3</b>"
                });
                context.SaveChanges();
            }

            if (!context.Materials.Any())
            {
                var dirs = context.Directories.AsEnumerable();

                context.Materials.Add(new Material()
                {
                    Title = "First Material", Html = "<b>Material Content1</b>", DirectoryId = dirs.First().Id
                });
                context.Materials.Add(new Material()
                {
                    Title = "Second Material", Html = "<b>Material Content2</b>", DirectoryId = dirs.ElementAt(1).Id
                });
                context.Materials.Add(new Material()
                {
                    Title = "Third Material", Html = "<b>Material Content3</b>", DirectoryId = dirs.Last().Id
                });
                context.SaveChanges();
            }
        }
示例#14
0
        public static void InitFlights(EFDBContext context)
        {
            Random rand = new Random();

            if (!context.Flights.Any())
            {
                context.Flights.Add(new Flight {
                    From = "City1", To = "place1", Length = rand.Next() % 2500, PlacesCount = 10, PlacesReserved = 0, Price = rand.Next() % 1000, Start = DateTime.Now.AddDays(5)
                });
                context.Flights.Add(new Flight {
                    From = "City2", To = "place2", Length = rand.Next() % 2500, PlacesCount = 10, PlacesReserved = 0, Price = rand.Next() % 1000, Start = new DateTime()
                });
                context.SaveChanges();
            }
        }
示例#15
0
 public static void InitData(EFDBContext context)
 {
     if (!context.Codes.Any())
     {
         context.Codes.Add(new Entityes.Code()
         {
             Value = 145, Name = "Код"
         });
         context.Codes.Add(new Entityes.Code()
         {
             Value = 783, Name = "Водафон"
         });
         context.SaveChanges();
     }
 }
示例#16
0
        public static void InitMessages(EFDBContext context)
        {
            var u1 = context.ApplicationsUsers.Where(u => u.Email == "1").FirstOrDefault();
            var u2 = context.ApplicationsUsers.Where(u => u.Email == "2").FirstOrDefault();

            if (!context.Messages.Any())
            {
                var firstMessage = context.Messages.Add(new Message
                {
                    AuthorId        = u2.Id,
                    ChatId          = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
                    DeletedForOwner = false,
                    Text            = "Hello friend!",
                    TimeStamp       = DateTime.Now
                });

                context.Messages.Add(new Message
                {
                    AuthorId        = u2.Id,
                    ChatId          = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
                    DeletedForOwner = false,
                    Text            = "Hello hello!",
                    TimeStamp       = DateTime.Now
                });

                context.Messages.Add(new Message
                {
                    AuthorId        = u2.Id,
                    ChatId          = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
                    DeletedForOwner = true,
                    Text            = "Deleted for owner message",
                    TimeStamp       = DateTime.Now,
                });

                context.Messages.Add(new Message
                {
                    AuthorId        = u1.Id,
                    ChatId          = new Guid("6F9619FF-8B86-D011-B42D-00CF4FC964FF"),
                    DeletedForOwner = false,
                    Text            = "How do you do?",
                    TimeStamp       = DateTime.Now,
                    IsAnswerForId   = firstMessage.Entity.Id
                });
                context.SaveChanges();
            }
        }
示例#17
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Users.Any())
            {
                //ADD USEERS

                context.Users.Add(new Entities.Users()
                {
                    Fio = "Vasya Pupkin"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Seva Dvijkov"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Seka Aubakirov"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Mishanaya Malinin"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Sanya Krasnov"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Emin Eminemovich"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Karim Asterkin"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Siden Snouden"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Water Price Cooper"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Serjan Marjan"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Ivan Ivanov"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Dedushka Kalinin"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Masya Zakin"
                });
                context.Users.Add(new Entities.Users()
                {
                    Fio = "Ivan Poddubniy"
                });
                context.SaveChanges();

                ///ADD GOODS

                context.Goods.Add(new Entities.Goods()
                {
                    Name = "IMAC", Price = 950000, UsersId = context.Users.First().Id
                });
                context.Goods.Add(new Entities.Goods()
                {
                    Name = "LENOVO NoTebook G500", Price = 275000, UsersId = context.Users.First().Id
                });
                context.Goods.Add(new Entities.Goods()
                {
                    Name = "Iphone X", Price = 265000, UsersId = context.Users.Last().Id
                });
                context.Goods.Add(new Entities.Goods()
                {
                    Name = "Macintosh Lel", Price = 330000, UsersId = context.Users.Last().Id
                });
                context.Goods.Add(new Entities.Goods()
                {
                    Name = "Rowenta shower", Price = 220000, UsersId = context.Users.Last().Id
                });
                context.SaveChanges();
            }
        }
示例#18
0
        public static void InitData(EFDBContext context)
        {
            Random rand = new Random();

            if (!context.author.Any())
            {
                context.author.Add(new Author {
                    Name = "Стивен", Surname = "Кинг"
                });
                context.author.Add(new Author {
                    Name = "Роберт", Surname = "Гэлбрейт"
                });
                context.author.Add(new Author {
                    Name = "Коллин", Surname = "Маккалоу"
                });
                context.author.Add(new Author {
                    Name = "Джеймс", Surname = "Боуэн"
                });
                context.author.Add(new Author {
                    Name = "Джордж", Surname = "Оруэлл"
                });
                context.author.Add(new Author {
                    Name = "Джордан", Surname = "Белфорт"
                });
                context.author.Add(new Author {
                    Name = "Кассанда", Surname = "Клэр"
                });
                context.SaveChanges();
            }
            if (!context.book.Any())
            {
                context.book.Add(new Book {
                    Name = "Город потеряных душ", Price = 200, Author = context.author.Find(7)
                });
                context.book.Add(new Book {
                    Name = "Волк с Уолл-стритт", Price = 150, Author = context.author.Find(6)
                });
                context.book.Add(new Book {
                    Name = "Страна радости", Price = 400, Author = context.author.Find(1)
                });
                context.book.Add(new Book {
                    Name = "Мир глазами кота Боба", Price = 200, Author = context.author.Find(4)
                });
                context.book.Add(new Book {
                    Name = "Зов кукушки", Price = 150, Author = context.author.Find(2)
                });
                context.book.Add(new Book {
                    Name = "Поющие в терновнике", Price = 100, Author = context.author.Find(3)
                });
                context.book.Add(new Book {
                    Name = "1984", Price = 200, Author = context.author.Find(5)
                });
                context.book.Add(new Book {
                    Name = "Оно", Price = 300, Author = context.author.Find(1)
                });
                context.SaveChanges();
            }
            if (!context.reader.Any())
            {
                context.reader.Add(new Reader {
                    Name = "Валентина", Surname = "Кравчук", Patronymic = "Анатолійович", Region = "Львівська", District = "Львів", Telephone = "0502019324", TicketNumber = 33146
                });
                context.reader.Add(new Reader {
                    Name = "Алла", Surname = "Мірошниченко", Patronymic = "Янович", Region = "Донецька", District = "Донецьк", Telephone = "0938543557", TicketNumber = 29275
                });
                context.reader.Add(new Reader {
                    Name = "Олег", Surname = "Пономаренко", Patronymic = "Миколайович", Region = "Київська", District = "Київ", Telephone = "0503099380", TicketNumber = 64181
                });
                context.reader.Add(new Reader {
                    Name = "Олексій", Surname = "Іванченко", Patronymic = "Олександрович", Region = "Луганська", District = "Луганськ", Telephone = "0505083359", TicketNumber = 76851
                });
                context.reader.Add(new Reader {
                    Name = "Олексій", Surname = "Таращук", Patronymic = "Іванович", Region = "Миколаївська", District = "Миколаїв", Telephone = "0506489765", TicketNumber = 75678
                });
                context.reader.Add(new Reader {
                    Name = "Іван", Surname = "Кравчук", Patronymic = "Валентинович", Region = "Дніпропетровська", District = "Дніпропетровськ", Telephone = "0637827497", TicketNumber = 48074
                });
                context.reader.Add(new Reader {
                    Name = "Василь", Surname = "Шинкаренко", Patronymic = "Євгенович", Region = "Закарпатська", District = "Ужгород", Telephone = "0671756456", TicketNumber = 76558
                });
                context.SaveChanges();
            }
            if (!context.log.Any())
            {
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.log.Add(new Log {
                    Reader = context.reader.Find(rand.Next(1, 8)), Book = context.book.Find(rand.Next(1, 8)), DateOfIssue = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30)), DateOfReturn = new DateTime(rand.Next(2011, 2020), rand.Next(1, 12), rand.Next(1, 30))
                });
                context.SaveChanges();
            }
        }
示例#19
0
        public static void InitData(EFDBContext context)
        {
            if (!context.Directories.Any())
            {
                context.Directories.Add(new Directory()
                {
                    Title = "First chapter",
                    Html  = "<h4>Placeholder1<h4>"
                });

                context.Directories.Add(new Directory()
                {
                    Title = "Second chapter",
                    Html  = "<h4>Placeholder2<h4>"
                });

                context.Directories.Add(new Directory()
                {
                    Title = "Third chapter",
                    Html  = "<h4>Placeholder3<h4>"
                });

                context.SaveChanges();

                if (!context.Materials.Any())
                {
                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph11",
                        Html        = "About11",
                        DirectoryId = 1
                    });
                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph12",
                        Html        = "About12",
                        DirectoryId = 1
                    });

                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph21",
                        Html        = "About21",
                        DirectoryId = 2
                    });
                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph22",
                        Html        = "About22",
                        DirectoryId = 2
                    });

                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph31",
                        Html        = "About31",
                        DirectoryId = 3
                    });
                    context.Materials.Add(new Material()
                    {
                        Title       = "Paragraph32",
                        Html        = "About32",
                        DirectoryId = 3
                    });

                    context.SaveChanges();
                }
            }
        }