Beispiel #1
0
        public static void Initialize(IServiceProvider serviceProvider)
        {
            using (var context = new CarLotContext(
                       serviceProvider.GetRequiredService <DbContextOptions <CarLotContext> >()))
            {
                // Look for any movies.
                if (context.car.Any())
                {
                    return;   // DB has been seeded
                }


                context.car.AddRange(
                    new car
                {
                    Name        = "Ford Mustang",
                    Type        = "Muscle",
                    ReleaseDate = DateTime.Parse("1968-1-1"),
                    Engine      = 4.7,
                    Doors       = 2,
                    Fuel        = "Petrol",
                    Gearbox     = "Automatic",
                    ImageUrl    = "https://www.erclassics.com/media/wysiwyg/history/68_Mustang.jpg",
                },

                    new car
                {
                    Name        = "Jaguar F-Type",
                    Type        = "Luxury",
                    ReleaseDate = DateTime.Parse("2018-1-1"),
                    Engine      = 3,
                    Doors       = 2,
                    Fuel        = "Petrol",
                    Gearbox     = "Automatic",
                    ImageUrl    = "https://m.atcdn.co.uk/a/media/w1024/10f5e2f5c599479aa9dbbccdb0cd949e.jpg",
                },

                    new car
                {
                    Name        = "Porsche Cayman Coupe",
                    Type        = "Sports",
                    ReleaseDate = DateTime.Parse("2013-1-1"),
                    Engine      = 2.7,
                    Doors       = 2,
                    Fuel        = "Petrol",
                    Gearbox     = "Automatic",
                    ImageUrl    = "https://img.vcars.co.uk/1/listers/bigimages/131667_1.jpg",
                }
                    );
                context.SaveChanges();
            }
        }
Beispiel #2
0
 public DeleteModel(CarLot.Models.CarLotContext context)
 {
     _context = context;
 }
Beispiel #3
0
 public EditModel(CarLot.Models.CarLotContext context)
 {
     _context = context;
 }
Beispiel #4
0
 public IndexModel(CarLot.Models.CarLotContext context)
 {
     _context = context;
 }
Beispiel #5
0
 public CreateModel(CarLot.Models.CarLotContext context)
 {
     _context = context;
 }
Beispiel #6
0
 public DetailsModel(CarLot.Models.CarLotContext context)
 {
     _context = context;
 }