示例#1
0
 public static void Initialize(IServiceProvider serviceProvider)
 {
     using (var context = new WebApplication1Context(
                serviceProvider.GetRequiredService <DbContextOptions <WebApplication1Context> >()))
     {
         // Look for any scans
         if (context.Scan.Any())
         {
             return;   // DB has been seeded
         }
     }
 }
示例#2
0
        public int RefreshRejects(string userMail)
        {
            using (WebApplication1Context db = new WebApplication1Context())
            {
                var rejects = from r in db.Rejects
                              where r.Article.IndividualContributor.Mail == userMail
                              select r;
                var rejectsList = rejects.ToList();
                var result      = rejects.Count();

                return(result);
            }
        }
示例#3
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <DbContextOptions <WebApplication1Context> >()))
            {
                // Look for any movies.
                if (context.Movie.Any())
                {
                    return;   // DB has been seeded
                }

                context.Movie.AddRange(
                    new Movie
                {
                    Title       = "When Harry Met Sally",
                    ReleaseDate = DateTime.Parse("1989-2-12"),
                    Genre       = "Romantic Comedy",
                    Price       = 7.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Ghostbusters ",
                    ReleaseDate = DateTime.Parse("1984-3-13"),
                    Genre       = "Comedy",
                    Price       = 8.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Ghostbusters 2",
                    ReleaseDate = DateTime.Parse("1986-2-23"),
                    Genre       = "Comedy",
                    Price       = 9.99M,
                    Rating      = "R"
                },

                    new Movie
                {
                    Title       = "Rio Bravo",
                    ReleaseDate = DateTime.Parse("1959-4-15"),
                    Genre       = "Western",
                    Price       = 3.99M,
                    Rating      = "R"
                }
                    );
                context.SaveChanges();
            }
        }
示例#4
0
        public EditModel(WebApplication1.Models.WebApplication1Context context)
        {
            _context = context;
            IQueryable <string> matQuery = from m in _context.Material
                                           orderby m.MaterialType
                                           select m.MaterialType;

            IQueryable <string> delQuery = from d in _context.Delivery
                                           orderby d.RushOrderDay
                                           select d.RushOrderDay;

            MaterialList = new SelectList(matQuery.Distinct().ToList());
            DeliveryList = new SelectList(delQuery.Distinct().ToList());
        }
示例#5
0
        public int RefreshApproves()
        {
            using (WebApplication1Context db = new WebApplication1Context())
            {
                var rejects = db.Rejects.ToList();

                var approves = from a in db.Articles
                               where !a.State
                               select a;

                var result = approves.ToList().Count() - rejects.Count();

                return(result);
            }
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <WebApplication1Context> >()))
            {
                // Look for any job offers.
                if (context.JobOffer.Any())
                {
                    return;   // DB has been seeded
                }

                context.JobOffer.AddRange(
                    new JobOffer
                {
                    JobTitle = "Backend Developer",
                    Salary   = 6000
                },

                    new JobOffer
                {
                    JobTitle = "Frontend Developer",
                    Salary   = 5000
                },

                    new JobOffer
                {
                    JobTitle = "Teacher",
                    Salary   = 3000
                },

                    new JobOffer
                {
                    JobTitle = "Cook",
                    Salary   = 3500
                }
                    );
                context.SaveChanges();
            }
        }
示例#7
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <DbContextOptions <WebApplication1Context> >()))
            {
                // Look for any movies.
                if (context.Bikes.Any())
                {
                    return;   // DB has been seeded
                }

                context.Bikes.AddRange(
                    new Bikes
                {
                    Name  = "A bike",
                    Rides = 15
                },
                    new Bikes
                {
                    Name  = "Another bike",
                    Rides = 8
                },
                    new Bikes
                {
                    Name  = "A Third bike",
                    Rides = 5
                },
                    new Bikes
                {
                    Name  = "lAst bike",
                    Rides = 1
                }
                    );
                context.SaveChanges();
            }
        }
 public static ShoppingCart GetCart(WebApplication1Context db, string cartId)
 => new ShoppingCart(db, cartId);
 public static ShoppingCart GetCart(WebApplication1Context db, HttpContext context)
 => GetCart(db, GetCartId(context));
示例#10
0
 private ShoppingCart(WebApplication1Context dbContext, string id)
 {
     _dbContext      = dbContext;
     _shoppingCartId = id;
 }
示例#11
0
 public BeersController(WebApplication1Context context)
 {
     _context = context;
 }
示例#12
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <WebApplication1Context> >()))
            {
                if (!context.League.Any())
                {
                    context.League.AddRange(
                        new League
                    {
                        Name    = "NHL",
                        Sport   = "Hockey",
                        Players = new System.Collections.Generic.List <Player>()
                        {
                            new Player
                            {
                                Name      = "Mark Scheifele",
                                BirthDate = DateTime.Parse("1993-3-15"),
                                Team      = "Winnipeg Jets",
                                Salary    = 7.99M,
                                Rating    = "A+"
                            },

                            new Player
                            {
                                Name      = "Blake Wheeler",
                                BirthDate = DateTime.Parse("1986-08-31"),
                                Team      = "Winnipeg Jets",
                                Salary    = 8.99M,
                                Rating    = "A"
                            },

                            new Player
                            {
                                Name      = "Nikolaj Ehlers",
                                BirthDate = DateTime.Parse("1996-02-14"),
                                Team      = "Winnipeg Jets",
                                Salary    = 9.99M,
                                Rating    = "A"
                            },

                            new Player
                            {
                                Name      = "Kyle Connor",
                                BirthDate = DateTime.Parse("1996-12-09"),
                                Team      = "Winnipeg Jets",
                                Salary    = 3.99M,
                                Rating    = "A"
                            }
                        }
                    },

                        new League
                    {
                        Name  = "MLB",
                        Sport = "Baseball"
                    },

                        new League
                    {
                        Name  = "NFL",
                        Sport = "Gridiron"
                    },

                        new League
                    {
                        Name  = "NBA",
                        Sport = "Basketball"
                    }


                        );
                }

                context.SaveChanges();
            }
        }
示例#13
0
 public CategoriasController(WebApplication1Context context)
 {
     _context = context;
 }
示例#14
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <WebApplication1Context> >()))
            {
                // Look for any movies.
                if (context.Cliente.Any())
                {
                    return;   // DB has been seeded
                }

                context.Cliente.AddRange(
                    new Cliente
                {
                    nombre       = "Sebastian",
                    correo       = "Algo",
                    telefono     = "123456",
                    necesidad    = "asdasd",
                    tipoDeEvento = "sadasd",
                    ubicacion    = "ssdf",
                    fecha        = "asdas",
                    invitados    = 10,
                    detalles     = "dsfsdf"
                },

                    new Cliente
                {
                    nombre       = "Sebastian",
                    correo       = "Algo",
                    telefono     = "123456",
                    necesidad    = "asdasd",
                    tipoDeEvento = "sadasd",
                    ubicacion    = "ssdf",
                    fecha        = "asdas",
                    invitados    = 10,
                    detalles     = "dsfsdf"
                },

                    new Cliente
                {
                    nombre       = "Sebastian",
                    correo       = "Algo",
                    telefono     = "123456",
                    necesidad    = "asdasd",
                    tipoDeEvento = "sadasd",
                    ubicacion    = "ssdf",
                    fecha        = "asdas",
                    invitados    = 10,
                    detalles     = "dsfsdf"
                },

                    new Cliente
                {
                    nombre       = "Sebastian",
                    correo       = "Algo",
                    telefono     = "123456",
                    necesidad    = "asdasd",
                    tipoDeEvento = "sadasd",
                    ubicacion    = "ssdf",
                    fecha        = "asdas",
                    invitados    = 10,
                    detalles     = "dsfsdf"
                }
                    );
                context.SaveChanges();
            }
        }
示例#15
0
 public DetailsModel(WebApplication1.Models.WebApplication1Context context)
 {
     _context = context;
 }
示例#16
0
 public DeleteModel(WebApplication1.Models.WebApplication1Context context)
 {
     _context = context;
 }
示例#17
0
 public IndexModel(WebApplication1.Models.WebApplication1Context context)
 {
     _context = context;
 }
示例#18
0
 public EditModel(WebApplication1.Models.WebApplication1Context context)
 {
     _context = context;
 }
示例#19
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new WebApplication1Context(
                       serviceProvider.GetRequiredService <
                           DbContextOptions <WebApplication1Context> >()))
            {
                // Look for any movies.
                if (context.Material.Any())
                {
                    return;   // DB has been seeded
                }

                context.Material.AddRange(
                    new Material
                {
                    MaterialType = "Oak",
                    Price        = 200
                },
                    new Material
                {
                    MaterialType = "Laminate",
                    Price        = 100
                },
                    new Material
                {
                    MaterialType = "Pine",
                    Price        = 50
                },
                    new Material
                {
                    MaterialType = "Veneer",
                    Price        = 125
                },
                    new Material
                {
                    MaterialType = "Oak",
                    Price        = 200
                }
                    );

                context.Delivery.AddRange(
                    new Delivery
                {
                    RushOrderDay = "3 Day",
                    Days         = 3
                },
                    new Delivery
                {
                    RushOrderDay = "5 Day",
                    Days         = 5
                },
                    new Delivery
                {
                    RushOrderDay = "7 Day",
                    Days         = 7
                },
                    new Delivery
                {
                    RushOrderDay = "14 Day (Normal Shipping)",
                    Days         = 14
                }
                    );


                context.SaveChanges();
            }
        }