public VehicleMaintenanceDesignData(VehiclesDesignData vehiclesDesignData)
        {
            InitializeVehicleMaintenance();

            DesignVehicleMaintenance.Vehicle = vehiclesDesignData.DesignVehicle;
            DesignVehicleMaintenanceTwo.Vehicle = vehiclesDesignData.DesignVehicleTwo;
            DesignVehicleMaintenanceThree.Vehicle = vehiclesDesignData.DesignVehicleThree;
        }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the <see cref="RoutesDesignData"/> class.
        /// </summary>
        /// <param name="ownerBusinessAccount">The owner business account.</param>
        /// <param name="clientsDesignData">The clients design data.</param>
        /// <param name="vehiclesDesignData">The vehicles design data.</param>
        /// <param name="employeesDesignData">The employees design data.</param>
        public RoutesDesignData(BusinessAccount ownerBusinessAccount, ClientsDesignData clientsDesignData, VehiclesDesignData vehiclesDesignData,
            EmployeesDesignData employeesDesignData)
        {
            _ownerBusinessAccount = ownerBusinessAccount;
            _clientsDesignData = clientsDesignData;
            _vehiclesDesignData = vehiclesDesignData;
            _employeesDesignData = employeesDesignData;

            InitializeRoutes(ownerBusinessAccount);
        }
        /// <summary>
        /// Clear and create the database. Then populate it with design data.
        /// </summary>
        public static void ClearCreateCoreEntitiesDatabaseAndPopulateDesignData()
        {
            ClearCreateCoreEntitiesDatabase();

            var container = new CoreEntitiesContainer(ServerConstants.ContainerConnectionString);

            //Setup blocks
            PopulateBlocks(container);

            //Setup Business Accounts (and ServiceTemplates)
            var businessAccountsDesignData = new BusinessAccountsDesignData();

            //Setup User Accounts
            var userAccountsDesignData = new UserAccountsDesignData
                                             {
                                                 //Set Passwords
                                                 Andrew = { PasswordHash = EncryptionTools.Hash("f00sballchamp", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 Jon = { PasswordHash = EncryptionTools.Hash("seltzer", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 Oren = { PasswordHash = EncryptionTools.Hash("nachoman", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 Zach = { PasswordHash = EncryptionTools.Hash("curlyhair", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 David = { PasswordHash = EncryptionTools.Hash("starofdavid", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 Linda = { PasswordHash = EncryptionTools.Hash("auntie", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 Terri = { PasswordHash = EncryptionTools.Hash("iam1randompassword", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" },
                                                 AlanMcClure = { PasswordHash = EncryptionTools.Hash("youngster", new byte[] { 65, 0, 65 }), TimeZone = "Eastern Standard Time" }
                                             };

            //Setup roles
            new RolesDesignData(businessAccountsDesignData, userAccountsDesignData);

            //var changes = container.ObjectStateManager.GetObjectStateEntries(EntityState.Added).Select(o => o.Entity).OfType<ServiceTemplate>().Where(st => st.CreatedDate < DateTime.UtcNow.AddDays(-1) || st.LastModified < DateTime.UtcNow.AddDays(-1));

            //container.SaveChanges();

            //Populate ServiceProvider Design Data
            foreach (var serviceProvider in businessAccountsDesignData.DesignServiceProviders)
            {
                var employeesDesignData = new EmployeesDesignData(serviceProvider);
                foreach (var employee in employeesDesignData.DesignEmployees)
                    serviceProvider.Employees.Add(employee);

                //container.SaveChanges();

                //Add Vehicles (and Vehicle Maintenance, and VehicleTypes)
                var vehiclesDesignData = new VehiclesDesignData(serviceProvider);
                foreach (var vehicle in vehiclesDesignData.DesignVehicles)
                    serviceProvider.Vehicles.Add(vehicle);

                //container.SaveChanges();

                //Add Regions
                var regionsDesignData = new RegionsDesignData();
                foreach (var region in regionsDesignData.DesignRegions)
                    serviceProvider.Regions.Add(region);

                //container.SaveChanges();

                //Add Clients (and ContactInfo, Locations, and RecurringServices)
                var clientsDesignData = new ClientsDesignData(serviceProvider, regionsDesignData);
                foreach (var client in clientsDesignData.DesignClients)
                    serviceProvider.Clients.Add(client);

                //container.SaveChanges();

                //Add Routes (with RouteTasks, Vehicles, Technicians)
                var routesDesignData = new RoutesDesignData(serviceProvider, clientsDesignData, vehiclesDesignData, employeesDesignData);
                foreach (var route in routesDesignData.DesignRoutes)
                    serviceProvider.Routes.Add(route);

                //container.SaveChanges();

                //Add Services
                var servicesDesignData = new ServicesDesignData(serviceProvider, clientsDesignData.DesignClients.ElementAt(0), serviceProvider.ServiceTemplates);
                foreach (var service in servicesDesignData.DesignServices)
                    serviceProvider.ServicesToProvide.Add(service);

                //container.SaveChanges();
            }

            container.SaveChanges();
        }