Ejemplo n.º 1
0
 public DetailsModel(Group22_ParkingApp.Data.ParkingAppContext context)
 {
     _context = context;
 }
Ejemplo n.º 2
0
 public CreateModel(Group22_ParkingApp.Data.ParkingAppContext context)
 {
     _context = context;
 }
Ejemplo n.º 3
0
 public EditModel(Group22_ParkingApp.Data.ParkingAppContext context)
 {
     _context = context;
 }
Ejemplo n.º 4
0
        public static void Initialize(ParkingAppContext context)
        {
            //context.Database.EnsureCreated();

            // Look for any students.
            if (context.Members.Any())
            {
                return;   // DB has been seeded
            }

            var members = new Member[]
            {
                new Member {
                    FirstName = "Carson", LastName = "Alexander", LicenseNo = "abc1234", Email = "*****@*****.**", CreditCard = "1234567891000000"
                },
                new Member {
                    FirstName = "Suhaib", LastName = "Shahaib", LicenseNo = "1234567", Email = "*****@*****.**", CreditCard = "1234567891000001"
                }
            };

            context.Members.AddRange(members);
            context.SaveChanges();

            var nonmembers = new NonMember[]
            {
                new NonMember {
                    FirstName = "Carson", LastName = "Alexander", LicenseNo = "abc1234", Email = "*****@*****.**",
                },
                new NonMember {
                    FirstName = "Suhaib", LastName = "Shahaib", LicenseNo = "1234567", Email = "*****@*****.**",
                }
            };

            context.Members.AddRange(members);
            context.SaveChanges();

            var parkingLots = new ParkingLot[]
            {
                new ParkingLot {
                    Name = "South 1", AvailableSpaces = 50, TotalSpaces = 150
                },
                new ParkingLot {
                    Name = "North 1", AvailableSpaces = 4, TotalSpaces = 50
                },
                new ParkingLot {
                    Name = "South 2", AvailableSpaces = 400, TotalSpaces = 500
                }
            };

            context.ParkingLots.AddRange(parkingLots);
            context.SaveChanges();

            var reservations = new Reservation[]
            {
                new Reservation {
                    MemberId = 1, ParkingLotId = 1
                },
                new Reservation {
                    MemberId = 1, ParkingLotId = 3
                },
                new Reservation {
                    MemberId = 2, ParkingLotId = 2
                }
            };

            context.Reservations.AddRange(reservations);
            context.SaveChanges();

            var parkingSpots = new ParkingSpot[]
            {
                new ParkingSpot {
                    isAvailable = true, ParkingLotId = 1, MemberId = 1
                },
                new ParkingSpot {
                    isAvailable = true, ParkingLotId = 3, MemberId = 1
                },
                new ParkingSpot {
                    isAvailable = true, ParkingLotId = 2, MemberId = 2
                }
            };

            context.ParkingSpots.AddRange(parkingSpots);
            context.SaveChanges();
        }