Пример #1
0
        public static void Initialize(SpotParkApiContext context)
        {
            if (context.ParkingSpot.Any())
            {
                return;   // DB has been seeded
            }

            var spots = new ParkingSpot[]
            {
                new ParkingSpot
                {
                    Title               = "Northgate",
                    Size                = "small",
                    Location            = "Northgate",
                    SpecialInstructions = "Creek",
                    Cost                = 1,

                    Email = "*****@*****.**",
                },
                new ParkingSpot
                {
                    Title    = "Ballard",
                    Size     = "small",
                    Location = "Ballard",

                    SpecialInstructions = "Creek",
                    Cost = 2,

                    Email = "*****@*****.**",
                },
                new ParkingSpot
                {
                    Title    = "Eastlake",
                    Size     = "small",
                    Location = "Eastlake",

                    SpecialInstructions = "Margaritas",
                    Cost = 3,

                    Email = "*****@*****.**",
                },
                new ParkingSpot
                {
                    Title    = "Capital Hill",
                    Size     = "small",
                    Location = "Capital Hill",

                    SpecialInstructions = "First Come First Serve",
                    Cost = 5,

                    Email = "*****@*****.**",
                },
                new ParkingSpot
                {
                    Title    = "Everette",
                    Size     = "small",
                    Location = "Everette",

                    SpecialInstructions = "YMCA",
                    Cost = 0,

                    Email = "*****@*****.**",
                }
            };

            foreach (ParkingSpot p in spots)
            {
                context.ParkingSpot.Add(p);
            }
            context.SaveChanges();
        }
Пример #2
0
 public ParkingSpotsController(SpotParkApiContext context)
 {
     _context = context;
 }