示例#1
0
        public static void GenerateMemberData(IServiceProvider serviceProvider)
        {
            using (var context = new Garage3Context(serviceProvider.GetRequiredService <DbContextOptions <Garage3Context> >()))
            {
                if (!context.Member.Any())
                {
                    var standard = context.MembershipType.FirstOrDefault(x => x.Type == "Standard");
                    var pro      = context.MembershipType.FirstOrDefault(x => x.Type == "Pro");

                    context.Member.AddRange(
                        new Member {
                        PersonalIdentityNumber = "198002149876", FirstName = "Conny", LastName = "Andersson", Joined = DateTime.Parse("2020-03-01"), ExtendedMemberShipEndDate = DateTime.Parse("2021-02-01"), MembershipType = standard
                    },
                        new Member {
                        PersonalIdentityNumber = "198102149876", FirstName = "Berta", LastName = "Svennson", Joined = DateTime.Parse("2021-01-01"), ExtendedMemberShipEndDate = DateTime.Parse("2021-05-06"), MembershipType = pro
                    },
                        new Member {
                        PersonalIdentityNumber = "198202149876", FirstName = "David", LastName = "Nokto", Joined = DateTime.Parse("2018-11-01"), ExtendedMemberShipEndDate = DateTime.Parse("2021-03-12"), MembershipType = standard
                    },
                        new Member {
                        PersonalIdentityNumber = "198302149876", FirstName = "Anita", LastName = "Berg", Joined = DateTime.Parse("2019-06-01"), ExtendedMemberShipEndDate = DateTime.Parse("2021-03-24"), MembershipType = standard
                    },
                        new Member {
                        PersonalIdentityNumber = "193002149876", FirstName = "Stefan", LastName = "Karlsson", Joined = DateTime.Parse("2021-03-01"), ExtendedMemberShipEndDate = DateTime.Parse("2021-04-01"), MembershipType = pro
                    }
                        );
                    context.SaveChanges();
                }
            }
        }
示例#2
0
        public static void GenerateTypes(IServiceProvider serviceProvider)
        {
            using (var context = new Garage3Context(serviceProvider.GetRequiredService <DbContextOptions <Garage3Context> >()))
            {
                if (context.MembershipType.Any())
                {
                    goto vehicleTypeGen;
                }
                context.MembershipType.AddRange(
                    new MembershipType {
                    Type = "Pro", Discount = 10
                },
                    new MembershipType {
                    Type = "Standard", Discount = 0
                }
                    );

vehicleTypeGen:

                if (context.VehicleType.Any())
                {
                    goto parkingSpaceGen;
                }

                context.VehicleType.AddRange(
                    new VehicleType {
                    Type = "Car", Size = 1, imgSrc = "/images/VehicleTypeIcons/car icon.png"
                },
                    new VehicleType {
                    Type = "Motorcycle", Size = 0.33F, imgSrc = "/images/VehicleTypeIcons/motorcycle icon.png"
                },
                    new VehicleType {
                    Type = "Pickup", Size = 2, imgSrc = "/images/VehicleTypeIcons/pickup icon.png"
                },
                    new VehicleType {
                    Type = "Truck", Size = 3, imgSrc = "/images/VehicleTypeIcons/truck icon.png"
                }
                    );

parkingSpaceGen:

                if (context.ParkingSpace.Any())
                {
                    goto savechanges;
                }

                for (int i = 1; i < 10; i++)
                {
                    context.ParkingSpace.AddRange(
                        new ParkingSpace {
                        Number = i, Name = "Ruta" + i, Size = 1
                    });
                }

savechanges:
                context.SaveChanges();
            }
        }
示例#3
0
        public static void GenerateVehicleData(IServiceProvider serviceProvider)
        {
            using (var context = new Garage3Context(serviceProvider.GetRequiredService <DbContextOptions <Garage3Context> >()))
            {
                if (!context.Vehicle.Any())
                {
                    var car        = context.VehicleType.FirstOrDefault(x => x.Type == "Car");
                    var motorcycle = context.VehicleType.FirstOrDefault(x => x.Type == "Motorcycle");
                    var pickup     = context.VehicleType.FirstOrDefault(x => x.Type == "Pickup");
                    var truck      = context.VehicleType.FirstOrDefault(x => x.Type == "Truck");

                    var owner1 = context.Member.Where(m => m.MemberID == 1).FirstOrDefault();
                    var owner2 = context.Member.Where(m => m.MemberID == 2).FirstOrDefault();
                    var owner3 = context.Member.Where(m => m.MemberID == 3).FirstOrDefault();
                    var owner4 = context.Member.Where(m => m.MemberID == 4).FirstOrDefault();
                    var owner5 = context.Member.Where(m => m.MemberID == 5).FirstOrDefault();

                    context.Vehicle.AddRange(
                        new Vehicle {
                        Owner = owner1, Brand = "Volvo", NumberOfWheels = 4, LicenseNumber = "ABC123", Color = "Black", Model = "E4", VehicleType = car
                    },
                        new Vehicle {
                        Owner = owner2, Brand = "Yamaha", NumberOfWheels = 2, LicenseNumber = "VBA234", Color = "Brown", Model = "E5", VehicleType = motorcycle
                    },
                        new Vehicle {
                        Owner = owner3, Brand = "Toyota", NumberOfWheels = 4, LicenseNumber = "DHI137", Color = "Orangie", Model = "E0", VehicleType = pickup
                    },
                        new Vehicle {
                        Owner = owner4, Brand = "Mercedes", NumberOfWheels = 6, LicenseNumber = "BCA354", Color = "DowerBlue", Model = "E9", VehicleType = truck
                    },
                        new Vehicle {
                        Owner = owner5, Brand = "Harley", NumberOfWheels = 2, LicenseNumber = "DCI298", Color = "MaybeYw", Model = "EU", VehicleType = motorcycle
                    }
                        );

                    context.SaveChanges();
                }
            }
        }
示例#4
0
 public ParkedVehiclesController(Garage3Context context)
 {
     _context = context;
 }
示例#5
0
 public VehiclesController(Garage3Context context)
 {
     db = context;
 }
示例#6
0
 public VehiclesController(Garage3Context context, IMapper mapper)
 {
     _context    = context;
     this.mapper = mapper;
 }
示例#7
0
 public ParkingSpaceCalculations(Garage3Context context)
 {
     db = context;
 }
示例#8
0
 public MembersController(Garage3Context context)
 {
     db = context;
 }
示例#9
0
 public StatisticsController(Garage3Context context)
 {
     db = context;
 }
示例#10
0
 public VehicleTypeService(Garage3Context context)
 {
     db = context;
 }
示例#11
0
 public RetrieveVehicleService(Garage3Context context)
 {
     db = context;
 }
示例#12
0
 public OwnerSelectService(Garage3Context context)
 {
     db = context;
 }
示例#13
0
 public ParkingSlotsTakenViewComponent(Garage3Context context)
 {
     db = context;
 }
示例#14
0
 public MembersController(Garage3Context context, IMapper mapper)
 {
     _context    = context;
     this.mapper = mapper;
 }
示例#15
0
 public AdministrationController(Garage3Context context)
 {
     db = context;
 }
示例#16
0
 public SelectService(Garage3Context _context)
 {
     this._context = _context;
 }