Esempio n. 1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new WebAppContext(
                serviceProvider.GetRequiredService <
                    DbContextOptions <WebAppContext> >()))
     {
         SeedData.Populate(context);
     }
 }
Esempio n. 2
0
 internal static void Initialize(WebAppContext context)
 {
     context.Database.EnsureCreated();
     if (context.DbConfig.Any())
     {
         return;
     }
     else
     {
         context.DbConfig.Add(new DbConfig {
             ServerIP = "192.168.3.31"
         });
         context.SaveChanges();
     }
 }
Esempio n. 3
0
        private static void SeedUsers(WebAppContext context)
        {
            if (context.Users.Any())
            {
                return;
            }
            var fishers = new Fisher[]
            {
                new Fisher()
                {
                    Username = "******", Password = "******", Email = "*****@*****.**", Gender = 'M', SexPref = 'F', PicRef = "rasr2", Age = 12, IsActive = true
                },
            };

            foreach (Fisher fisher in fishers)
            {
                context.Add(fisher);
            }
            context.SaveChanges();
        }
Esempio n. 4
0
 public DetailsModel(WebApp.Data.WebAppContext context)
 {
     _context = context;
 }
Esempio n. 5
0
 public DbSeeder(WebAppContext context, UserManager <ApplicationUser> userManager, RoleManager <IdentityRole> roleManager)
 {
     _context     = context;
     _userManager = userManager;
     _roleManager = roleManager;
 }
Esempio n. 6
0
 public DeleteModel(WebApp.Data.WebAppContext context)
 {
     _context = context;
 }
Esempio n. 7
0
 public EditModel(WebApp.Data.WebAppContext context)
 {
     _context = context;
 }
Esempio n. 8
0
        public static void Populate(WebAppContext context)
        {
            if (context.User.Any())
            {
                return;   // DB has been seeded
            }

            List <User> users = new List <User>();

            users.Add(new User {
                Email = "admin", Password = "******", Role = "admin", Name = "admin"
            });
            users.Add(new User {
                Email = "test", Password = "******", Role = "client", Name = "test"
            });

            context.AddRange(users);
            context.SaveChanges();

            // load test user to create test store
            Store store = null;
            User  test  = users.FirstOrDefault(o => o.Email == "admin");

            if (test != null && test.Id != 0)
            {
                store = new Store {
                    Name = "test store", User = test
                };
                context.Add(store);
                context.SaveChanges();
            }


            List <Category> category = new List <Category>
            {
                new Category {
                    Name = "Alimentació"
                },
                new Category {
                    Name = "Llar"
                },
                new Category {
                    Name = "Floristeria"
                },
                new Category {
                    Name = "Cine"
                },
                new Category {
                    Name = "Informàtica"
                },
                new Category {
                    Name = "Immobiliaria"
                },
                new Category {
                    Name = "Electrodomestic"
                },
                new Category {
                    Name = "Tenda de regals"
                },
                new Category {
                    Name = "Joieria"
                },
                new Category {
                    Name = "Panaderia"
                },
                new Category {
                    Name = "Llibreria"
                },
                new Category {
                    Name = "Roba"
                },
                new Category {
                    Name = "Gelateria"
                },
                new Category {
                    Name = "Adm de loteria"
                },
                new Category {
                    Name = "Estancs"
                },
                new Category {
                    Name = "Farmàcia"
                },
                new Category {
                    Name = "test"
                }
            };

            context.AddRange(category);
            context.SaveChanges();
        }
Esempio n. 9
0
 public SeedingService(WebAppContext context)
 {
     _context = context;
 }
 public CreateModel(WebApp.Data.WebAppContext context)
 {
     _context = context;
 }
Esempio n. 11
0
 public IndexModel(WebAppContext context)
 {
     _context = context;
 }
Esempio n. 12
0
 public static void Initializer(WebAppContext context)
 {
     context.Database.EnsureCreated();
     SeedUsers(context);
 }
Esempio n. 13
0
 public EFDataRepository()
 {
     _dbc = new WebAppContext();
 }
Esempio n. 14
0
 public SqlWebAppRepo(WebAppContext context)
 {
     _context = context;
 }
Esempio n. 15
0
        // Lisa 3 üritust ja kõigile üritustele lisa 3 osalejat.
        //
        // 1. Aenan Commodo:
        //   Mati Nurk
        //   Supersam OÜ
        //   Uku OÜ
        //
        // 2. Nunc lobortis
        // Lelle Mari
        // Mullam OÜ
        // Supersale OÜ
        //
        // 3. Integer nec null viate
        //  Tubli Malle
        //  Vegman klubi
        //  Supersale OÜ

        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebAppContext(
                       serviceProvider.GetRequiredService <DbContextOptions <WebAppContext> >()))
            {
                // look for any events
                if (context.Events.Any())
                {
                    return;
                }

                var events = new Event[]
                {
                    new Event
                    {
                        EventName        = "Integer nec nulla vitae",
                        EventStartDate   = new DateTime(2019, 6, 14),
                        EventLocation    = "Regione equidem usu",
                        EventInformation = "Ad sit regione malorum, vel mucius eloquentiam an. Vix utinam animal appareat at. Cum eros mazim tibique et, intellegam assueverit duo no, mei ne velit incorrupte. Eum noster verear eu, ius diceret accommodare ea. Sed accusam nominavi id.",
                    },
                    new Event
                    {
                        EventName        = "Aenean commodo",
                        EventStartDate   = new DateTime(2018, 3, 18),
                        EventLocation    = "Animal equidem usu",
                        EventInformation = "Ad sit regione malorum, vel mucius eloquentiam an. Vix utinam animal appareat at. Cum eros mazim tibique et, intellegam assueverit duo no, mei ne velit incorrupte. Eum noster verear eu, ius diceret accommodare ea. Sed accusam nominavi id.",
                    },
                    new Event
                    {
                        EventName        = "Nunc lobortis metus eu massa viverra ultri iplacerat nibh",
                        EventStartDate   = new DateTime(2016, 3, 3),
                        EventLocation    = "Regione equidem usu",
                        EventInformation = "Ad sit regione malorum, vel mucius eloquentiam an. Vix utinam animal appareat at. Cum eros mazim tibique et, intellegam assueverit duo no, mei ne velit incorrupte. Eum noster verear eu, ius diceret accommodare ea. Sed accusam nominavi id.",
                    },
                };



                var people = new Person[]
                {
                    new Person {
                        FirstName = "Mati", LastName = "Nurk", PersonalCode = Convert.ToInt32(3345432), PersonPaymentMethod = PaymentMethod.CreditCard, PersonRequests = "Exerci graeco necessitatibus te has, debet copiosae qualisque in vix, docendi nominavi pro ei. Id dictas euismod detraxit est, doming labore meliore per id. Ex meis audire ius, in quot."
                    },
                    new Person {
                        FirstName = "Lelle", LastName = "Mari", PersonalCode = Convert.ToInt32(275443), PersonPaymentMethod = PaymentMethod.Cash, PersonRequests = "Corpora probatus consequat in pro, mea tantas quodsi mollis ut. Ponderum intellegebat voluptatibus"
                    },
                    new Person {
                        FirstName = "Tubli", LastName = "Kalle", PersonalCode = Convert.ToInt32(3875434), PersonPaymentMethod = PaymentMethod.CreditCard, PersonRequests = "Corpora probatus consequat in pro, mea tantas quodsi mollis ut. Ponderum intellegebat voluptatibus"
                    }
                };



                var companies = new Company[]
                {
                    new Company {
                        CompanyName = "Supersam OÜ", NumberOfParticipants = 5, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(335432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    },
                    new Company {
                        CompanyName = "Uku OÜ", NumberOfParticipants = 8, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(334432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    },
                    new Company {
                        CompanyName = "Nullam OÜ", NumberOfParticipants = 5, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(35432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    },
                    new Company {
                        CompanyName = "Supersale OÜ", NumberOfParticipants = 5, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(3432432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    },
                    new Company {
                        CompanyName = "Vegman klubi", NumberOfParticipants = 2, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(3134432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    },
                    new Company {
                        CompanyName = "DoubleCash AS", NumberOfParticipants = 6, CompanyPaymentMehtod = PaymentMethod.CreditCard, CompanyRegistrationNr = Convert.ToInt32(3321432), CompanyRequests = "Loren Ipsur Lorem Ipur Lorem Ipsur"
                    }
                };



                var participants = new Participant[]
                {
                    new Participant {
                        EventId = 1, PersonId = 1, CompanyId = null, Type = ParticipantType.Person
                    },
                    new Participant {
                        EventId = 1, PersonId = null, CompanyId = 1, Type = ParticipantType.Company
                    },
                    new Participant {
                        EventId = 1, PersonId = null, CompanyId = 2, Type = ParticipantType.Company
                    },
                    new Participant {
                        EventId = 2, PersonId = 2, CompanyId = null, Type = ParticipantType.Person
                    },
                    new Participant {
                        EventId = 2, PersonId = null, CompanyId = 3, Type = ParticipantType.Company
                    },
                    new Participant {
                        EventId = 2, PersonId = null, CompanyId = 4, Type = ParticipantType.Company
                    },
                    new Participant {
                        EventId = 3, PersonId = 3, CompanyId = null, Type = ParticipantType.Person
                    },
                    new Participant {
                        EventId = 3, PersonId = null, CompanyId = 5, Type = ParticipantType.Company
                    },
                    new Participant {
                        EventId = 3, PersonId = null, CompanyId = 6, Type = ParticipantType.Company
                    }
                };



                foreach (Event e in events)
                {
                    context.Events.Add(e);
                }

                context.SaveChanges();

                foreach (Person p in people)
                {
                    context.People.Add(p);
                }

                context.SaveChanges();

                foreach (Participant p in participants)
                {
                    context.Participants.Add(p);
                }
                //context.SaveChanges();

                foreach (Company c in companies)
                {
                    context.Companies.Add(c);
                }

                context.SaveChanges();
            }
        }