Ejemplo n.º 1
0
        public static void AddVehicles(this VehifleetContext context, int vehicleCount = 50)
        {
            for (int i = 0; i < vehicleCount; i++)
            {
                context.Vehicles.Add(GenerateVehicle(context));
            }

            if (!context.Vehicles.Any())
            {
                context.SaveChanges();
            }

            foreach (var vehicle in context.Vehicles.Include(v => v.VehicleModel).ToList())
            {
                context.Insurances.AddRange(GenerateInsurances(vehicle));
                context.Bookings.AddRange(GenerateBookings(context, vehicle));
                if (vehicle.Mileage > 0)
                {
                    context.Maintenances.AddRange(GenerateMaintenances(vehicle));
                }
            }


            context.SaveChanges();
        }
Ejemplo n.º 2
0
        public static void AddLocations(this VehifleetContext context)
        {
            var locations = new List <Location>
            {
                new Location
                {
                    AddedBy      = "admin",
                    AddedOn      = DateTime.UtcNow,
                    Address      = "Brzozowa 45",
                    City         = "Wrocław",
                    LocationCode = "WRO-1",
                    LocationName = "Grey Towers"
                },
                new Location
                {
                    AddedBy      = "admin",
                    AddedOn      = DateTime.UtcNow,
                    Address      = "Świerkowa 21",
                    City         = "Wrocław",
                    LocationCode = "WRO-2",
                    LocationName = "GMD Building"
                },
                new Location
                {
                    AddedBy      = "admin",
                    AddedOn      = DateTime.UtcNow,
                    Address      = "Smogowa 96",
                    City         = "Kraków",
                    LocationCode = "KRK-1",
                    LocationName = "Smog Center"
                },
                new Location
                {
                    AddedBy      = "admin",
                    AddedOn      = DateTime.UtcNow,
                    Address      = "Lipowa 88",
                    City         = "Wrocław",
                    LocationCode = "WRO-3",
                    LocationName = "Exquisite Center"
                },
                new Location
                {
                    AddedBy      = "admin",
                    AddedOn      = DateTime.UtcNow,
                    Address      = "Garncarska 4",
                    City         = "Opole",
                    LocationCode = "OPO-1",
                    LocationName = "Golden Tower"
                }
            };

            context.Locations.AddRange(locations);
            context.SaveChanges();
        }
Ejemplo n.º 3
0
        public static void AdjustVehicleCanBeBookedUntil(this VehifleetContext context)
        {
            foreach (var vehicle in context.Vehicles.Include(v => v.Insurances).ToList())
            {
                if (vehicle.Insurances.Any())
                {
                    var mostRecentInsurance = vehicle.Insurances.OrderBy(i => i.EndDate).Last().EndDate;
                    vehicle.CanBeBookedUntil = mostRecentInsurance < vehicle.InspectionValidUntil
                                                   ? mostRecentInsurance
                                                   : vehicle.InspectionValidUntil;
                    context.Vehicles.Update(vehicle);
                }
            }

            context.SaveChanges();
        }
Ejemplo n.º 4
0
        public static void AddRoles(this VehifleetContext context)
        {
            var roles = new List <IdentityRole>
            {
                new IdentityRole
                {
                    Name           = "Employee",
                    NormalizedName = "EMPLOYEE"
                },
                new IdentityRole
                {
                    Name           = "Administrator",
                    NormalizedName = "ADMINISTRATOR"
                },
                new IdentityRole
                {
                    Name           = "Manager",
                    NormalizedName = "MANAGER"
                }
            };

            context.Roles.AddRange(roles);
            context.SaveChanges();
        }
Ejemplo n.º 5
0
        public static void AddVehicleModels(this VehifleetContext context)
        {
            var vehicleModels = new List <VehicleModel>
            {
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Ford",
                    Model             = "Focus",
                    ConfigurationCode = "FF2018184",
                    Horsepower        = 115,
                    Seats             = 4,
                    Weight            = 1200,
                    Engine            = "1.8 TDCi",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 70000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Ford",
                    Model             = "Focus",
                    ConfigurationCode = "FF2018154",
                    Horsepower        = 85,
                    Seats             = 4,
                    Weight            = 1150,
                    Engine            = "1.2 Eco",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 60000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Ford",
                    Model             = "Mondeo",
                    ConfigurationCode = "FM2018184",
                    Horsepower        = 155,
                    Seats             = 4,
                    Weight            = 1300,
                    Engine            = "1.8 EcoBoost",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 120000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Toyota",
                    Model             = "Auris",
                    ConfigurationCode = "TA2018174",
                    Horsepower        = 115,
                    Seats             = 4,
                    Weight            = 1300,
                    Engine            = "1.6 6A-GMD",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 64000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Toyota",
                    Model             = "Corolla",
                    ConfigurationCode = "TC2018144",
                    Horsepower        = 90,
                    Seats             = 4,
                    Weight            = 1270,
                    Engine            = "1.0 4A-GAE",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 55000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Ford",
                    Model             = "C-Max",
                    ConfigurationCode = "FC2014184",
                    Horsepower        = 105,
                    Seats             = 5,
                    Weight            = 1300,
                    Engine            = "1.6 TDDi",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 73000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Ford",
                    Model             = "S-Max",
                    ConfigurationCode = "FS2012184",
                    Horsepower        = 105,
                    Seats             = 6,
                    Weight            = 1400,
                    Engine            = "1.6 TDDi",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 79000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Skoda",
                    Model             = "Superb",
                    ConfigurationCode = "SS185184",
                    Horsepower        = 185,
                    Seats             = 4,
                    Weight            = 1200,
                    Engine            = "1.8 SKT-D3TT",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 112000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Skoda",
                    Model             = "Octavia",
                    ConfigurationCode = "SO14184",
                    Horsepower        = 140,
                    Seats             = 4,
                    Weight            = 1250,
                    Engine            = "1.8 SKT-D2",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 68000
                },
                new VehicleModel
                {
                    AddedBy           = "admin",
                    AddedOn           = DateTime.UtcNow,
                    Manufacturer      = "Skoda",
                    Model             = "Rapid",
                    ConfigurationCode = "SR14184",
                    Horsepower        = 90,
                    Seats             = 4,
                    Weight            = 1100,
                    Engine            = "1.4 SKT-D1",
                    Mileage           = 0,
                    FuelConsumed      = 0,
                    Cost         = 0,
                    PurchaseCost = 67000
                },
            };

            context.VehicleModels.AddRange(vehicleModels);
            context.SaveChanges();
        }