void GenerateNext() { if (myCity != null) { if (myCity.loadedSuburbIndex < myCity.suburbs.Count) { LotType suburbLotType = myCity.suburbs[myCity.loadedSuburbIndex].suburbType; // if we need to load a block if (myCity.suburbs[myCity.loadedSuburbIndex].loadedBlockIndex < myCity.suburbs[myCity.loadedSuburbIndex].myBlocks.Count) { //load block myCity.suburbs[myCity.loadedSuburbIndex].loadedBlockIndex++; myCity.suburbs[myCity.loadedSuburbIndex].myBlocks[myCity.suburbs[myCity.loadedSuburbIndex].loadedBlockIndex - 1].Initilize(suburbLotType); // if suburb has completed next frame lets load the next suburb if (myCity.suburbs[myCity.loadedSuburbIndex].loadedBlockIndex > myCity.suburbs[myCity.loadedSuburbIndex].myBlocks.Count - 1) { myCity.loadedSuburbIndex++; } } else// if we finished loading the block load the next suburb { myCity.suburbs[myCity.loadedSuburbIndex].GenerateBlocks(suburbLotType.blockSize, suburbLotType.blockDeviation, 0); } } } }
void BuildLots(ref LotType _lot) { //shrink poly List <Vector2> lotPoly = CityTest.Shrink(borders, footPathSize + roadSize); //for each edge in poly for (int currEdge = 0; currEdge < lotPoly.Count; currEdge++) { //find its width and height float depth = _lot.maxDepth; int nextEdge = currEdge + 1 == lotPoly.Count ? 0 : currEdge + 1; int nextNextEdge = nextEdge + 1 == lotPoly.Count ? 0 : nextEdge + 1; int prevEdge = currEdge - 1 < 0 ? lotPoly.Count - 1 : currEdge - 1; //get cross point in from the edge direction Vector2 cross = GK.Geom.RotateRightAngle(lotPoly[nextEdge] - lotPoly[currEdge]).normalized *depth; Vector2 nextEdgeDirection = (lotPoly[nextEdge] - lotPoly[currEdge]).normalized; Vector2 prevEdgeDirection = lotPoly[prevEdge] - lotPoly[currEdge]; Vector2 nextNextEdgeDirection = lotPoly[nextEdge] - lotPoly[nextNextEdge]; float angleBetweenPrevNext = Vector2.Angle(nextEdgeDirection, prevEdgeDirection); float angleBetweenNextNextNext = Vector2.Angle(nextEdgeDirection, nextNextEdgeDirection); //find starting lenght (sin tan) along the original edge float startLenght = Mathf.Tan((90 - angleBetweenPrevNext) * Mathf.Deg2Rad) * depth; //find the hypotinues of the previous end lenght startLenght += depth / Mathf.Sin(angleBetweenPrevNext * Mathf.Deg2Rad); //hypot //find ending lenght (sin tan) along the original edge starting from the back normal edge float endLenght = Vector3.Distance(lotPoly[currEdge], lotPoly[nextEdge]) + (Mathf.Tan((90 - angleBetweenPrevNext) * Mathf.Deg2Rad) * depth); for (float currentLenght = startLenght; currentLenght < endLenght;) { //randomly get a building int buildingIndex = Random.Range(0, _lot.buildings.Count); GameObject building = _lot.buildings[buildingIndex]; float width = _lot.buildingSizes[buildingIndex].x; if (currentLenght + width < endLenght)// check if pointing can fit { //add building between points; Vector2 bottomLeft = lotPoly[currEdge] + nextEdgeDirection * currentLenght; Vector2 bottomRight = bottomLeft + nextEdgeDirection * width; Vector2 topRight = bottomRight + cross; Vector2 topLeft = bottomLeft + cross; currentLenght += width; Vector2 centerLot = (bottomLeft + bottomRight + topRight + topLeft) / 4; //crete the building in the lot GameObject newBuilding = GameObject.Instantiate(building, new Vector3(centerLot.x, 0, centerLot.y), Quaternion.LookRotation(Vector3.Cross(new Vector3(nextEdgeDirection.x, 0, nextEdgeDirection.y), -Vector3.up), Vector3.up), thisBlock.transform); newBuilding.name = "Building: " + currentLenght.ToString(); } else { break; } } } }
public Lot(double creationTime, Sequence sequence) : base(creationTime) { CurrentStepCount = -1; Type = sequence.Type; Sequence = sequence; }
public ChangeLotTypeDialogEx(LotType currentLotType, CommercialLotSubType currentCommercialSubType, ResidentialLotSubType currentResidentialSubType, Vector2 position, ModalDialog.PauseMode pauseMode, bool isHouseboatLot) : base(currentLotType, currentCommercialSubType, currentResidentialSubType, position, pauseMode, isHouseboatLot) { PopulateComboBox(currentLotType == LotType.Residential, isHouseboatLot); Button childByID = mModalDialogWindow.GetChildByID(3, true) as Button; childByID.Click -= OnLotTypeClick; childByID.Click += OnLotTypeClickEx; childByID = mModalDialogWindow.GetChildByID(2, true) as Button; childByID.Click -= OnLotTypeClick; childByID.Click += OnLotTypeClickEx; }
public List <LotType> CreateMockLotTypeData() { List <LotType> mockLotTypeData = new List <LotType>(); LotType lotType = new LotType("TestLotTypeName1"); lotType.LotTypeID = 1; mockLotTypeData.Add(lotType); new LotType("TestLotTypeName2"); lotType.LotTypeID = 2; mockLotTypeData.Add(lotType); return(mockLotTypeData); }
public static new bool Show(ref LotType currentType, ref CommercialLotSubType currentCommercialSubType, ref ResidentialLotSubType currentResidentialSubType, ref string lotTypeName, Vector2 position, ModalDialog.PauseMode pauseMode, bool isHouseboatLot) { if (ModalDialog.EnableModalDialogs) { using (ChangeLotTypeDialogEx dialog = new ChangeLotTypeDialogEx(currentType, currentCommercialSubType, currentResidentialSubType, position, pauseMode, isHouseboatLot)) { dialog.StartModal(); currentType = dialog.mCurrentLotType; currentCommercialSubType = dialog.mCurrentCommercialSubType; currentResidentialSubType = dialog.mCurrentResidentialSubType; lotTypeName = dialog.mLotTypeName; return(dialog.Result); } } return(false); }
public static bool ChangeLotType(ulong lotId, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { EditTownModel ths = EditTownController.Instance.mModel as EditTownModel; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return(false); } if (newType == LotType.Residential) { commercialSubType = CommercialLotSubType.kCommercialUndefined; } else { residentialSubType = ResidentialLotSubType.kResidentialUndefined; } if ((newType != LotType.Residential) && (commercialSubType == CommercialLotSubType.kCommercialUndefined)) { return(false); } if (!ChangeLotTypeHelper(lot, deleteInvalidObjects, newType, commercialSubType, residentialSubType)) { return(false); } ths.GetInWorldCommunityLotBinInfoList(); ths.GetInWorldLotBinInfoList(); lot.LotType = newType; lot.CommercialLotSubType = commercialSubType; lot.ResidentialLotSubType = residentialSubType; if (lot.IsCommunityLot) { UIBinInfo item = ths.FindLotBinInfo(lotId); bool flag2 = true; if (item == null) { flag2 = false; item = ths.FindCommunityLotBinInfo(lotId); } if (item != null) { item.LotTypeFilter = 0x8; item.LotType = newType; item.CommercialLotSubType = commercialSubType; item.ResidentialLotSubType = residentialSubType; if (flag2) { ths.mInWorldLotBin.Remove(item); ths.mInWorldCommunityLotBin.Add(item); } } } else { UIBinInfo info2 = ths.FindCommunityLotBinInfo(lotId); bool flag3 = true; if (info2 == null) { flag3 = false; info2 = ths.FindLotBinInfo(lotId); } if (info2 != null) { if (World.LotIsEmpty(lotId) && lot.IsLotEmptyFromObjects()) { info2.LotTypeFilter = 0x2; } else { info2.LotTypeFilter = 0x4; } info2.LotType = newType; info2.CommercialLotSubType = commercialSubType; info2.ResidentialLotSubType = residentialSubType; if (flag3) { ths.mInWorldCommunityLotBin.Remove(info2); ths.mInWorldLotBin.Add(info2); } } } SpeedTrap.Sleep(); lot.EnsureLotObjects(); try { Sims3.Gameplay.Services.Services.ClearServicesForLot(lot); } catch (Exception e) { Common.Exception(lot, e); } Occupation.ValidateJobConsistencyWithLotType(lot); lot.UpdateCachedValues(); return(true); }
/// <summary> /// Unserializes a BinaryStream into the Attributes of this Instance /// </summary> /// <param name="reader">The Stream that contains the FileData</param> protected override void Unserialize(System.IO.BinaryReader reader) { ver = reader.ReadUInt16(); subver = reader.ReadUInt16(); sz.Width = reader.ReadInt32(); sz.Height = reader.ReadInt32(); type = (LotType)reader.ReadByte(); roads = reader.ReadByte(); rotation = (Rotation)reader.ReadByte(); unknown_0 = reader.ReadUInt32(); lotname = StreamHelper.ReadString(reader); description = StreamHelper.ReadString(reader); unknown_1 = new List <float>(); int len = reader.ReadInt32(); for (int i = 0; i < len; i++) { this.unknown_1.Add(reader.ReadSingle()); } if (subver >= (UInt16)LtxtSubVersion.Voyage) { unknown_3 = reader.ReadSingle(); } else { unknown_3 = 0; } if (subver >= (UInt16)LtxtSubVersion.Freetime) { unknown_4 = reader.ReadUInt32(); } else { unknown_4 = 0; } if (ver >= (UInt16)LtxtVersion.Apartment || subver >= (UInt16)LtxtSubVersion.Apartment) { unknown_5 = reader.ReadBytes(14); } else { unknown_5 = new byte[0]; } int y = reader.ReadInt32(); int x = reader.ReadInt32(); loc = new Point(x, y); elevation = reader.ReadSingle(); lotInstance = reader.ReadUInt32(); orient = (LotOrientation)reader.ReadByte(); texture = StreamHelper.ReadString(reader); unknown_2 = reader.ReadByte(); if (ver >= (int)LtxtVersion.Business) { owner = reader.ReadUInt32(); } else { owner = 0; } if (ver >= (UInt16)LtxtVersion.Apartment || subver >= (UInt16)LtxtSubVersion.Apartment) { int count; apartmentBase = reader.ReadUInt32(); unknown_6 = reader.ReadBytes(9); subLots = new List <SubLot>(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { subLots.Add(new SubLot(reader)); } unknown_7 = new List <uint>(); count = reader.ReadInt32(); for (int i = 0; i < count; i++) { unknown_7.Add(reader.ReadUInt32()); } } else { apartmentBase = 0; unknown_6 = new byte[0]; subLots = new List <SubLot>(); unknown_7 = new List <uint>(); } followup = reader.ReadBytes((int)(reader.BaseStream.Length - reader.BaseStream.Position)); }
public Sequence(LotType type) { Type = type; lotSteps = new List <LotStep>(); }
public static new bool Show(ref LotType currentType, ref CommercialLotSubType currentCommercialSubType, ref ResidentialLotSubType currentResidentialSubType, ref string lotTypeName, Vector2 position, ModalDialog.PauseMode pauseMode, bool isHouseboatLot) { if (ModalDialog.EnableModalDialogs) { using (ChangeLotTypeDialogEx dialog = new ChangeLotTypeDialogEx(currentType, currentCommercialSubType, currentResidentialSubType, position, pauseMode, isHouseboatLot)) { dialog.StartModal(); currentType = dialog.mCurrentLotType; currentCommercialSubType = dialog.mCurrentCommercialSubType; currentResidentialSubType = dialog.mCurrentResidentialSubType; lotTypeName = dialog.mLotTypeName; return dialog.Result; } } return false; }
public static new bool Show(ref LotType currentType, ref CommercialLotSubType currentCommercialSubType, ref ResidentialLotSubType currentResidentialSubType, ref string lotTypeName, bool isHouseboatLot) { return Show(ref currentType, ref currentCommercialSubType, ref currentResidentialSubType, ref lotTypeName, new Vector2(-1f, -1f), ModalDialog.PauseMode.PauseSimulator, isHouseboatLot); }
//generate our block public void Initilize(LotType lotType) { //set the bolock seed Random.State currentRNGState = Random.state; Random.InitState(seed); _lotType = lotType; MeshRenderer renderer = thisBlock.AddComponent <MeshRenderer>(); renderer.material = Resources.Load <Material>("CityMat"); renderer.material.color = lotType.groundColour; MeshFilter filter = thisBlock.AddComponent <MeshFilter>(); filter.mesh = new Mesh(); List <Vector2> blockGroundPoly; //generate our block ground and foot paths if (_lotType.footPath) { blockGroundPoly = CityTest.Shrink(borders, roadSize + footPathSize); BuildFootPath(_lotType.footPath); } else { blockGroundPoly = CityTest.Shrink(borders, roadSize); } //generate our buildings BuildLots(ref lotType); //generate our roads BuildRoads(); Vector3[] verticies = new Vector3[blockGroundPoly.Count]; int[] triangles = new int[blockGroundPoly.Count * 3]; Color[] vertColours = new Color[verticies.Length]; for (int i = 0; i < blockGroundPoly.Count; i++) // create our ground mesh { verticies[i] = new Vector3(blockGroundPoly[i].x, 0, blockGroundPoly[i].y) - thisBlock.transform.position; triangles[i * 3] = 0; if (i + 1 > verticies.Length - 1) { triangles[i * 3 + 1] = 0; } else { triangles[i * 3 + 1] = i + 1; } triangles[i * 3 + 2] = i; } filter.mesh.vertices = verticies; filter.mesh.triangles = triangles; Random.state = currentRNGState; }
public void AddLotStart(LotType lotType, int quantity) { LotStarts.Add(lotType, quantity); }
public static void ChangeLotTypeTask(object obj) { try { EditTownController ths = EditTownController.Instance; UIBinInfo info = obj as UIBinInfo; if ((info != null) && (info.LotId != ulong.MaxValue)) { ths.mModel.SetCurrentSelection(null, InfoSource.Unknown); ILocalizationModel localizationModel = Sims3.UI.Responder.Instance.LocalizationModel; LotType lotType = info.LotType; CommercialLotSubType commercialLotSubType = info.CommercialLotSubType; ResidentialLotSubType residentialLotSubType = info.ResidentialLotSubType; string lotTypeName = ""; if (ChangeLotTypeDialogEx.Show(ref lotType, ref commercialLotSubType, ref residentialLotSubType, ref lotTypeName, info.IsHouseboatLot)) { if (((lotType == LotType.Commercial) && (commercialLotSubType == CommercialLotSubType.kEP1_BaseCamp)) && ths.mModel.IsAnyLotBaseCamp()) { string titleText = Common.LocalizeEAString("Ui/Caption/Global:Failed"); string messageText = Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown/EP01:BaseCampExists"); SimpleMessageDialog.Show(titleText, messageText, ModalDialog.PauseMode.PauseSimulator, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close"); } else if (((lotType == LotType.Commercial) && (commercialLotSubType == CommercialLotSubType.kEP11_BaseCampFuture)) && ths.mModel.IsAnyLotBaseCamp()) { string str4 = localizationModel.LocalizeString("Ui/Caption/Global:Failed", new object[0]); string str5 = localizationModel.LocalizeString("Ui/Caption/GameEntry/EditTown/EP11:BaseCampFutureExists", new object[0]); SimpleMessageDialog.Show(str4, str5, ModalDialog.PauseMode.PauseSimulator, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close"); } else if (EditTownModelEx.ChangeLotType(info.LotId, false, lotType, commercialLotSubType, residentialLotSubType)) { EditTownController.AlertLotTypeChangeSuccess(info, localizationModel, lotType, lotTypeName); } else { string promptText = string.Empty; if (commercialLotSubType == CommercialLotSubType.kEP10_Resort) { promptText = localizationModel.LocalizeString("Ui/Caption/GameEntry/EditTown:LotTypeResortFailed", new object[] { info.LotAddress }); } else { promptText = localizationModel.LocalizeString((lotType == LotType.Commercial) ? "Ui/Caption/GameEntry/EditTown:LotTypeCommunityFailed" : "Ui/Caption/GameEntry/EditTown:LotTypeResidentialFailed", new object[] { info.LotAddress }); } if (AcceptCancelDialog.Show(promptText)) { if (EditTownModelEx.ChangeLotType(info.LotId, true, lotType, commercialLotSubType, residentialLotSubType)) { EditTownController.AlertLotTypeChangeSuccess(info, localizationModel, lotType, lotTypeName); EditTownMaptagController.Instance.ResetMaptags(); } else { string str5 = Common.LocalizeEAString("Ui/Caption/Global:Failed"); promptText = Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:LotTypeChangeFailed"); SimpleMessageDialog.Show(str5, promptText, ModalDialog.PauseMode.PauseSimulator, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close"); } } } } } } catch (Exception e) { Common.Exception("ChangeLotTypeTask", e); } }
private static bool ChangeLotTypeHelper(Lot lot, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { List <GameObject> objects = null; if (newType == LotType.Commercial) { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidCommunityLotObject)); if (commercialSubType == CommercialLotSubType.kEP10_Resort) { foreach (RabbitHole hole in lot.GetObjects <RabbitHole>(new Predicate <RabbitHole>(EditTownModel.IsInvestable))) { objects.Add(hole); } if (lot.ResortManager == null) { lot.ResortManager = new ResortManager(lot); } } } else { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidResidentialLotObject)); } if ((objects != null) && (objects.Count > 0)) { if (!deleteInvalidObjects) { return(false); } foreach (GameObject obj2 in objects) { int num = 0; bool flag = false; while (obj2.ActorsUsingMe.Count > num) { Sim sim = obj2.ActorsUsingMe[num]; if (sim != null) { sim.SetObjectToReset(); sim.InteractionQueue.PurgeInteractions(obj2); flag = true; } num++; } if (flag) { SpeedTrap.Sleep(0); } lot.RemoveObjectFromLot(obj2.ObjectId, true); obj2.Destroy(); } ThumbnailKey key = new ThumbnailKey(new ResourceKey(lot.LotId, 0x436fee4c, 0), ThumbnailSize.Large); ThumbnailManager.InvalidateThumbnail(key); EditTownModel.UpdateDirtyLotThumbnailsTask(true); } if (lot.CommercialLotSubType == CommercialLotSubType.kEP10_Resort) { foreach (IResortBuffetTable table in lot.GetObjects <IResortBuffetTable>()) { table.ClearTable(); } } if (GameStates.IsEditTownState) { BinCommon.KickSimsOffLot(lot, true); } return(true); }
public static new bool Show(ref LotType currentType, ref CommercialLotSubType currentCommercialSubType, ref ResidentialLotSubType currentResidentialSubType, ref string lotTypeName, bool isHouseboatLot) { return(Show(ref currentType, ref currentCommercialSubType, ref currentResidentialSubType, ref lotTypeName, new Vector2(-1f, -1f), ModalDialog.PauseMode.PauseSimulator, isHouseboatLot)); }
public static bool ChangeLotType(ulong lotId, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { EditTownModel ths = EditTownController.Instance.mModel as EditTownModel; Lot lot = LotManager.GetLot(lotId); if (lot == null) { return false; } if (newType == LotType.Residential) { commercialSubType = CommercialLotSubType.kCommercialUndefined; } else { residentialSubType = ResidentialLotSubType.kResidentialUndefined; } if ((newType != LotType.Residential) && (commercialSubType == CommercialLotSubType.kCommercialUndefined)) { return false; } if (!ChangeLotTypeHelper(lot, deleteInvalidObjects, newType, commercialSubType, residentialSubType)) { return false; } ths.GetInWorldCommunityLotBinInfoList(); ths.GetInWorldLotBinInfoList(); lot.LotType = newType; lot.CommercialLotSubType = commercialSubType; lot.ResidentialLotSubType = residentialSubType; if (lot.IsCommunityLot) { UIBinInfo item = ths.FindLotBinInfo(lotId); bool flag2 = true; if (item == null) { flag2 = false; item = ths.FindCommunityLotBinInfo(lotId); } if (item != null) { item.LotTypeFilter = 0x8; item.LotType = newType; item.CommercialLotSubType = commercialSubType; item.ResidentialLotSubType = residentialSubType; if (flag2) { ths.mInWorldLotBin.Remove(item); ths.mInWorldCommunityLotBin.Add(item); } } } else { UIBinInfo info2 = ths.FindCommunityLotBinInfo(lotId); bool flag3 = true; if (info2 == null) { flag3 = false; info2 = ths.FindLotBinInfo(lotId); } if (info2 != null) { if (World.LotIsEmpty(lotId) && lot.IsLotEmptyFromObjects()) { info2.LotTypeFilter = 0x2; } else { info2.LotTypeFilter = 0x4; } info2.LotType = newType; info2.CommercialLotSubType = commercialSubType; info2.ResidentialLotSubType = residentialSubType; if (flag3) { ths.mInWorldCommunityLotBin.Remove(info2); ths.mInWorldLotBin.Add(info2); } } } SpeedTrap.Sleep(); lot.EnsureLotObjects(); try { Sims3.Gameplay.Services.Services.ClearServicesForLot(lot); } catch (Exception e) { Common.Exception(lot, e); } Occupation.ValidateJobConsistencyWithLotType(lot); lot.UpdateCachedValues(); return true; }
private static bool ChangeLotTypeHelper(Lot lot, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType) { List<GameObject> objects = null; if (newType == LotType.Commercial) { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidCommunityLotObject)); if (commercialSubType == CommercialLotSubType.kEP10_Resort) { foreach (RabbitHole hole in lot.GetObjects<RabbitHole>(new Predicate<RabbitHole>(EditTownModel.IsInvestable))) { objects.Add(hole); } if (lot.ResortManager == null) { lot.ResortManager = new ResortManager(lot); } } } else { // Custom //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidResidentialLotObject)); } if ((objects != null) && (objects.Count > 0)) { if (!deleteInvalidObjects) { return false; } foreach (GameObject obj2 in objects) { int num = 0; bool flag = false; while (obj2.ActorsUsingMe.Count > num) { Sim sim = obj2.ActorsUsingMe[num]; if (sim != null) { sim.SetObjectToReset(); sim.InteractionQueue.PurgeInteractions(obj2); flag = true; } num++; } if (flag) { SpeedTrap.Sleep(0); } lot.RemoveObjectFromLot(obj2.ObjectId, true); obj2.Destroy(); } ThumbnailKey key = new ThumbnailKey(new ResourceKey(lot.LotId, 0x436fee4c, 0), ThumbnailSize.Large); ThumbnailManager.InvalidateThumbnail(key); EditTownModel.UpdateDirtyLotThumbnailsTask(true); } if (lot.CommercialLotSubType == CommercialLotSubType.kEP10_Resort) { foreach (IResortBuffetTable table in lot.GetObjects<IResortBuffetTable>()) { table.ClearTable(); } } if (GameStates.IsEditTownState) { BinCommon.KickSimsOffLot(lot, true); } return true; }
public static async Task InitializeAsync(IServiceProvider services) { ApplicationDbContext database = services.GetRequiredService <ApplicationDbContext>(); //To add roles we need to create a RoleManager RoleManager <IdentityRole> roleManager = services.GetRequiredService <RoleManager <IdentityRole> >(); //To add app users, we need to create a UserManager object UserManager <ApplicationUser> userManager = services.GetRequiredService <UserManager <ApplicationUser> >(); if (!database.Roles.Any()) { IdentityRole role = new IdentityRole("WVUEmployee"); await roleManager.CreateAsync(role); role = new IdentityRole("ParkingEmployee"); await roleManager.CreateAsync(role); role = new IdentityRole("Visitor"); await roleManager.CreateAsync(role); } if (!database.Departments.Any()) { Department department = new Department("MIS", "1601 University Ave, Morgantown, WV 26506"); database.Departments.Add(department); database.SaveChanges(); department = new Department("Mechanical Engineering", "1306 Evansdale Dr, Morgantown, WV 26506"); database.Departments.Add(department); database.SaveChanges(); department = new Department("Pediatrics", "1 Medical Center Dr, Morgantown, WV 26506"); database.Departments.Add(department); database.SaveChanges(); department = new Department("WVU Parking Office", "Maiden Ln, Morgantown, WV 26506"); database.Departments.Add(department); database.SaveChanges(); } //Populate all the appusers together if (!database.ApplicationUsers.Any()) { Visitor visitor = new Visitor("Test", "Visitor1", "*****@*****.**", "3040000001", "TestVisitor1", "Mylan"); visitor.EmailConfirmed = true; await userManager.CreateAsync(visitor); await userManager.AddToRoleAsync(visitor, "Visitor"); WVUEmployee employee = new WVUEmployee("Test", "WVUEmployee1", "*****@*****.**", "3040000002", "TestWVUEmployee1", 1); employee.EmailConfirmed = true; await userManager.CreateAsync(employee); await userManager.AddToRoleAsync(employee, "WVUEmployee"); employee = new WVUEmployee("Test", "WVUEmployee2", "*****@*****.**", "3040000003", "TestWVUEmployee2", 2); employee.EmailConfirmed = true; await userManager.CreateAsync(employee); await userManager.AddToRoleAsync(employee, "WVUEmployee"); employee = new WVUEmployee("Test", "WVUEmployee3", "*****@*****.**", "3040000004", "TestWVUEmployee3", 3); employee.EmailConfirmed = true; await userManager.CreateAsync(employee); await userManager.AddToRoleAsync(employee, "WVUEmployee"); WVUEmployee parkingEmployee = new WVUEmployee("Test", "ParkingEmployee1", "*****@*****.**", "3040000003", "TestParkingEmployee1", 4); employee.EmailConfirmed = true; await userManager.CreateAsync(parkingEmployee); await userManager.AddToRoleAsync(parkingEmployee, "WVUEmployee"); await userManager.AddToRoleAsync(parkingEmployee, "ParkingEmployee"); } //If you are populating each AppUser sub class seperately if (database.WVUEmployees.Any()) { } if (!database.Lots.Any()) // only if no data or rows are in lots table { Lot lot = new Lot("1", "Art Museum Education Center", "2 Fine Arts Dr, Morgantown, WV 26506", 140); lot.CurrentOccupancy = 140; database.Lots.Add(lot); database.SaveChanges(); lot = new Lot("4", "Student Rec Center", "2001 Rec Center Dr, Morgantown, WV 26506", 225); database.Lots.Add(lot); database.SaveChanges(); lot = new Lot("7", "College of B&E", "600 University Ave, Morgantown, WV 26506", 150); database.Lots.Add(lot); database.SaveChanges(); lot = new Lot("10", "WVU Hospital", "1 Medical Center Dr, Morgantown, WV 26506", 300); database.Lots.Add(lot); database.SaveChanges(); lot = new Lot("12", "WVU Urgent Care", "301 Suncrest Towne Centre Drive, Morgantown, WV 26505", 200); database.Lots.Add(lot); database.SaveChanges(); lot = new Lot("15", "WVU Medicine", "6040 University Town Centre Dr, Morgantown, WV 26501", 300); lot.CurrentOccupancy = 250; database.Lots.Add(lot); database.SaveChanges(); } if (!database.LotTypes.Any()) { LotType lotType = new LotType("Short Term Paid Lot"); database.LotTypes.Add(lotType); database.SaveChanges(); lotType = new LotType("Free"); database.LotTypes.Add(lotType); database.SaveChanges(); lotType = new LotType("Permit"); database.LotTypes.Add(lotType); database.SaveChanges(); } if (!database.LotStatuses.Any()) { CultureInfo cultureInfo = new CultureInfo("en-US"); DateTime startTime = DateTime.Parse("8:00 AM", cultureInfo, DateTimeStyles.NoCurrentDateDefault); DateTime endTime = DateTime.Parse("4:00 PM", cultureInfo, DateTimeStyles.NoCurrentDateDefault); //First object/row (weekday short term) LotStatus lotStatus = new LotStatus("Weekday", startTime, endTime, 0.50, 1, 1); database.LotStatuses.Add(lotStatus); database.SaveChanges(); lotStatus = new LotStatus("Weekday", startTime, endTime, 0.50, 2, 1); database.LotStatuses.Add(lotStatus); database.SaveChanges(); lotStatus = new LotStatus("Weekend", startTime, endTime, 0.00, 2, 2); database.LotStatuses.Add(lotStatus); database.SaveChanges(); lotStatus = new LotStatus("Weekday", startTime, endTime, 0.00, 3, 3); database.LotStatuses.Add(lotStatus); database.SaveChanges(); startTime = DateTime.Parse("4:01 PM", cultureInfo, DateTimeStyles.NoCurrentDateDefault); endTime = DateTime.Parse("7:59 AM", cultureInfo, DateTimeStyles.NoCurrentDateDefault); //Second object/row (weekday free) lotStatus = new LotStatus("Weekday", startTime, endTime, 0.00, 1, 2); database.LotStatuses.Add(lotStatus); database.SaveChanges(); lotStatus = new LotStatus("Weekday", startTime, endTime, 0.00, 2, 2); database.LotStatuses.Add(lotStatus); database.SaveChanges(); lotStatus = new LotStatus("Weekday", startTime, endTime, 0.00, 3, 2); database.LotStatuses.Add(lotStatus); database.SaveChanges(); } if (!database.Permits.Any()) { DateTime permitStartDate = new DateTime(2020, 1, 1); DateTime permitEndDate = new DateTime(2020, 12, 31); WVUEmployee parkingEmployee = database.WVUEmployees.Where(e => e.Email == "*****@*****.**").FirstOrDefault(); string parkingEmployeeID = parkingEmployee.Id; WVUEmployee user = database.WVUEmployees.Where(e => e.Email == "*****@*****.**").FirstOrDefault(); string userID = user.Id; Permit permit = new Permit(500.00, permitStartDate, permitEndDate, userID, parkingEmployeeID); database.Permits.Add(permit); database.SaveChanges(); user.PermitID = permit.PermitID; database.WVUEmployees.Update(user); database.SaveChanges(); //user = database.WVUEmployees.Where(e => e.Email == "*****@*****.**").FirstOrDefault(); //userID = user.Id; //permit = new Permit(500.00, permitStartDate, permitEndDate, userID); //database.Permits.Add(permit); //database.SaveChanges(); //user.PermitID = permit.PermitID; //database.WVUEmployees.Update(user); //database.SaveChanges(); user = database.WVUEmployees.Where(e => e.Email == "*****@*****.**").FirstOrDefault(); userID = user.Id; permit = new Permit(500.00, permitStartDate, permitEndDate, userID, parkingEmployeeID); database.Permits.Add(permit); database.SaveChanges(); user.PermitID = permit.PermitID; database.WVUEmployees.Update(user); database.SaveChanges(); //user = database.WVUEmployees.Where(e => e.Email == "*****@*****.**").FirstOrDefault(); //userID = user.Id; //permit = new Permit(500.00, permitStartDate, permitEndDate, userID); //database.Permits.Add(permit); //database.SaveChanges(); //user.PermitID = permit.PermitID; //database.WVUEmployees.Update(user); //database.SaveChanges(); } } //end method
public void AddSequence(LotType lotType, Sequence sequence) { Sequences.Add(lotType, sequence); }