public void LoadLogansLoopLocations(CosmoContext context, List <Region> regionList) { unloadDB(context); List <Location> locations = new List <Location>(); List <Subscriber> subscribers = new List <Subscriber>(); locations.Add(new Location { address = "123 street", province = "Saskatchewan", postalCode = "A1A1A1", optoutLocationRouteList = new List <LocationRoute>(), regionID = regionList[0].regionID }); subscribers.Add(new Subscriber { email = "*****@*****.**", phoneNumber = "1234567890", firstName = "Cosmo", location = locations[0] }); locations.Add(new Location { address = "456 street", province = "Saskatchewan", postalCode = "A2A2A2", optoutLocationRouteList = new List <LocationRoute>(), regionID = regionList[0].regionID }); subscribers.Add(new Subscriber { email = "*****@*****.**", phoneNumber = "1234567890", firstName = "Nathan", location = locations[1] }); locations.Add(new Location { address = "123 street", province = "Saskatchewan", postalCode = "A2A2A2", optoutLocationRouteList = new List <LocationRoute>(), regionID = regionList[0].regionID }); subscribers.Add(new Subscriber { email = "*****@*****.**", phoneNumber = "1234567890", firstName = "Cosmo", location = locations[2] }); context.AddRange(locations); context.AddRange(subscribers); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, CosmoContext context) { //Checks if the environment the webApp is hosted in is a development environment if (env.IsDevelopment()) { dateCalculation = new DateCalculation(); app.UseDeveloperExceptionPage(); //Provides the Developer Exception Page. Page gives information on errors thrown, requests, queries, and others context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //Checks that the context's database is created. Returns true if it is, false if not unloadDB(context); //Helper method to unload items in the context database (ensures fresh dummy data) List <Region> regions = loadRegions(); //Helper method to load dummy Regions into Region table context.AddRange(regions); //Adds Regions list to context context.SaveChanges(); //Saves changes //List<Location> locations = loadLocations(regions); //Create locations with regions passed in //context.Location.AddRange(locations); //context.SaveChanges(); loadLocations(context, regions); List <Location> locations = context.Location.ToList(); List <Subscriber> subscribers = loadSubscribers(locations); //Create the subscribers with the locations passed in context.Subscriber.AddRange(subscribers); context.SaveChanges(); //Save changes to DB List <Route> routes = loadRoutes(regions); //Helper method to load dummy Routes into Route table context.AddRange(routes); //Adds routes list to context context.SaveChanges(); //Saves changes List <Admin> admins = loadAdmins(); //Create the admins context.Admin.AddRange(admins); context.SaveChanges(); //Save changes to DB List <LocationRoute> locationRoutes = loadLocationRoutes(locations, routes); //Create the locationRoutes with the locations and routes passed in context.LocationRoute.AddRange(locationRoutes); context.SaveChanges(); //Save changes to DB //Highly populate route 'S90 A Past Route' HighlyPopulateRoute(context, routes[0]); //Added for Enable CORS Tutorial https://docs.microsoft.com/en-us/aspnet/core/security/cors?view=aspnetcore-3.1 //Tells the application to run the given policy name app.UseCors(MyAllowSpecificOrigins); context.SaveChanges(); } app.UseAuthentication(); app.UseMvc(); //Adds MVC to the .Net Core REquest Execution Pipeline }
/// <summary> /// Calls GetHardCodedRoutes and adds the newly created routes into the Route table of TestCosmoDB /// This method will need to be modified once additional data fixtures are added /// </summary> /// <param name="context"></param> public static void Load(CosmoContext context) { LocationFixture.Reload(context); List <Location> locations = context.Location.ToList <Location>(); List <Subscriber> subscribers = GetDerivedSubscribers(); int count = 0; foreach (Location l in locations) { subscribers[count].location = l; subscribers[count].billingLocation = l; count++; } context.AddRange(subscribers); context.SaveChanges(); }
public static void Load(CosmoContext context) { context.AddRange(GetDerivedLocations(context)); context.SaveChanges(); }
private void loadLocations(CosmoContext context, List <Region> regions, bool bFlip) { List <Location> locations = new List <Location>() { //Location for the first hard coded subscribers //Do not change new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp", region = regions[3] }, //Location for the second hard coded subscribers //Do not change new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp", region = regions[4] }, //Location for the third hard coded subscribers //Do not change new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp" //, //region = regions[7] }, //Using this for testing due to it having a proper route that is active and not completed new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp", region = regions[0] }, //Location for the second hard coded subscribers new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp", region = regions[4] }, //Location for the third hard coded subscribers new Location { address = "123 Street", city = "Saskatoon", postalCode = "A1A1A1", province = "SK", locationType = "PickUp", region = regions[5] } }; //if(bFlip) //{ // locations.Reverse(); //} context.AddRange(locations); context.SaveChanges(); //S79 Locations Region s79Reg = regions.Where(reg => reg.regionName == "The New World").Single(); List <Location> S79LocAssigned = new List <Location>(); List <Location> S79LocUnassigned = new List <Location>(); string[] strAssignedLocs = { "Astera", "Ancient Forest", "Wildspire Wastes", "Coral Highlands", "Rotten Vale", "Elder's Recess", "Great Ravine", "Everstream", "Confluence of Fates", "Research Base" }; string[] strAssignedUnits = { "1A", "2B", "3C", "11A", "11B", "11C" }; for (int i = 0; i < strAssignedLocs.Length; i++) { if (i < 6) { S79LocAssigned.Add(new Location() { city = "World", region = s79Reg, regionID = s79Reg.regionID, address = "123 " + strAssignedLocs[i] + " Path", unit = strAssignedUnits[i], postalCode = "A1A 1A1", province = "SK", locationType = "Pickup", }); } else { S79LocAssigned.Add(new Location() { city = "World", region = s79Reg, regionID = s79Reg.regionID, address = "123 " + strAssignedLocs[i] + " Path", postalCode = "A1A 1A1", province = "SK", locationType = "Pickup", }); } } //if(bFlip) //{ // S79LocAssigned.Reverse(); //} context.AddRange(S79LocAssigned); context.SaveChanges(); string[] strUnassignedLocs = { "Seliana", "Hoarfrost Reach", "Guiding Lands", "Origin Isle", "Canteen", "Smithy", "The Gathering Hub", "Living Quarters", "Private Quarters", "Private Suite" }; string[] strUnassignedUnits = { "123", "456", "789", "001" }; for (int i = 0; i < strUnassignedLocs.Length; i++) { if (i < 4) { S79LocUnassigned.Add(new Location() { city = "Iceborne", address = "123 " + strUnassignedLocs[i] + " Way", unit = strUnassignedUnits[i], postalCode = "A1A 1A1", province = "SK", locationType = "Pickup", }); } else { S79LocUnassigned.Add(new Location() { city = "Iceborne", address = "123 " + strUnassignedLocs[i] + " Way", postalCode = "A1A 1A1", province = "SK", locationType = "Pickup", }); } } //if(bFlip) //{ // S79LocUnassigned.Reverse(); //} context.AddRange(S79LocUnassigned); context.SaveChanges(); }
/// <summary> /// Calls GetRoutesFixture and adds the newly created routes into the Route table of TestCosmoDB /// This method will need to be modified once additional data fixtures are added /// </summary> /// <param name="context"></param> public static void Load(CosmoContext context) { context.AddRange(GetRouteFixtures(context)); context.SaveChanges(); }
/// <summary> /// Calls GetAdminFixture to get a list of preset regions to load to context /// </summary> /// <param name="context"></param> public static void Load(CosmoContext context) { context.AddRange(GetAdminFixture()); context.SaveChanges(); }