private IEnumerable<SelectListItem> BuildOccupationList(Occupation occupation) { return Enum.GetValues(typeof(Occupation)) .Cast<Occupation>() .Select(x => new SelectListItem() { Text = x.ToString(), Selected = x == occupation, Value = HomeModel.OccupationId(x) }); }
public void SetOccupation(Occupation occupation){ if (((Adult)Age).Occupation is Businessman) { dbManager.BuildingDB.BusinessOffice.Workers.Remove(this); } else if (((Adult)Age).Occupation is Recruiter) { dbManager.BuildingDB.RecruitmentCenter.Workers.Remove(this); } else if (((Adult)Age).Occupation is Researcher) { dbManager.BuildingDB.ResearchFacility.Workers.Remove(this); } else if (((Adult)Age).Occupation is Teacher) { dbManager.BuildingDB.GradeSchool.Workers.Remove(this); } else if (((Adult)Age).Occupation is WorldDomination) { //can't take supervillain out of world domination } ((Adult)Age).Occupation = occupation; if (occupation is Businessman) { dbManager.BuildingDB.BusinessOffice.Workers.Add(this); } else if (occupation is Recruiter) { dbManager.BuildingDB.RecruitmentCenter.Workers.Add(this); } else if (occupation is Researcher) { dbManager.BuildingDB.ResearchFacility.Workers.Add(this); } else if (occupation is Teacher) { dbManager.BuildingDB.GradeSchool.Workers.Add(this); } else if (occupation is WorldDomination) { dbManager.BuildingDB.World.Workers.Add(this); } }
protected bool IsCoworker(Occupation career, SimDescription me) { if (career == null) return false; if (career.Coworkers == null) return false; if (career.Coworkers.Contains(me)) return true; return (career.Boss == me); }
public Node(Vector3 geoLocation) { this.geoLocation = geoLocation; neighbors = new List<Node> (3); roads = new List<Edge> (3); adjTiles = new List<Tile> (3); occupied = Occupation.none; owner = null; visual = null; }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifyer for this person</param> /// <param name="age">The age of this person</param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="female">Is this person female</param> /// <param name="licence">Does this person have a driver's licence</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { this.Household = household; this.Id = id; this.Age = age; this.Occupation = occupation; this.EmploymentStatus = employmentStatus; this.StudentStatus = studentStatus; this.Licence = license; this.Female = female; }
/// <summary> /// Creates a new person /// </summary> /// <param name="household">The household that this person belongs to, may not be null!</param> /// <param name="id">The identifyer for this person</param> /// <param name="age">The age of this person</param> /// <param name="employmentStatus">How this person is employed, if at all</param> /// <param name="studentStatus">If this person is a student, and if so what type of student</param> /// <param name="female">Is this person female</param> /// <param name="licence">Does this person have a driver's licence</param> public Person(ITashaHousehold household, int id, int age, Occupation occupation, TTSEmploymentStatus employmentStatus, StudentStatus studentStatus, bool license, bool female) : this() { Household = household; Id = id; Age = age; Occupation = occupation; EmploymentStatus = employmentStatus; StudentStatus = studentStatus; Licence = license; Female = female; }
public Person(string currZone) { ZoneID = currZone; Age = Age.EighteenToTwentyFive; Sex = Sex.Male; EducationLevel = EducationLevel.primary; household = new Household(); Occupation = Occupation.TradesProfessional; PublicTransitPass = PublicTransitPass.MetroPass; EmploymentStatus = EmploymentStatus.PartTime; DrivingLicense = DrivingLicense.No; Type = AgentType.Person; myID = idCounter++; }
private Person(Person original) { Type = AgentType.Person; //copy the values ZoneID = original.ZoneID; Age = original.Age; Sex = original.Sex; EducationLevel = original.EducationLevel; Occupation = original.Occupation; PublicTransitPass = original.PublicTransitPass; EmploymentStatus = original.EmploymentStatus; DrivingLicense = original.DrivingLicense; household = original.household; myID = idCounter++; }
public ActionResult Edit(int id, int OccupationType) { var Occupation = new Occupation(); TryUpdateModel(Occupation); var constituentId = Convert.ToInt32(Session["constituentId"]); Occupation.Type = new OccupationType {Id = OccupationType}; Occupation.Address = new Address() {Id = 1}; Occupation.Constituent = new Constituent {Id = constituentId}; mapper = new AutoDataContractMapper(); var OccupationData = new OccupationData(); mapper.Map(Occupation, OccupationData); HttpHelper.Put(string.Format(serviceBaseUri+"/Occupations/{0}",id), OccupationData); return PartialView(new GridModel(GetOccupations())); }
public SafeStore(SimDescription sim, Flag flags) { mSim = sim; mNeverSelectable = mSim.IsNeverSelectable; mSim.IsNeverSelectable = false; mFlags = flags; if ((mFlags & Flag.StoreOpportunities) == Flag.StoreOpportunities) { mOpportunities = new OpportunityStore(mSim, false); } mRole = mSim.AssignedRole; if ((flags & Flag.OnlyAcademic) == Flag.OnlyAcademic) { if (!GameUtils.IsUniversityWorld()) { // Bypass for a removal during OnBecameSelectable() mCareer = mSim.OccupationAsAcademicCareer; } } else { mCareer = mSim.Occupation; } if (mCareer != null) { mSim.CareerManager.mJob = null; } if ((mSim.CareerManager != null) && ((flags & Flag.School) == Flag.School)) { mSchool = mSim.CareerManager.School; if (mSchool != null) { mSim.CareerManager.mSchool = null; } } mSim.AssignedRole = null; }
// From Career public static int CalculateBoostedStartingLevel(Occupation career) { int result = -1; int careerLevelBonusFromDegree = -1; if (career.OwnerDescription.CareerManager.DegreeManager != null) { AcademicDegree degreeForOccupation = career.OwnerDescription.CareerManager.DegreeManager.GetDegreeForOccupation(career.Guid); if ((degreeForOccupation != null) && degreeForOccupation.IsDegreeCompleted) { switch (degreeForOccupation.CurrentGpaAsLetterGrade) { case AcademicsUtility.AcademicGrade.D: careerLevelBonusFromDegree = Career.kCareerBonusesForDegreeWithGradeOfD.kCareerLevelBonusFromDegree; break; case AcademicsUtility.AcademicGrade.C: careerLevelBonusFromDegree = Career.kCareerBonusesForDegreeWithGradeOfC.kCareerLevelBonusFromDegree; break; case AcademicsUtility.AcademicGrade.B: careerLevelBonusFromDegree = Career.kCareerBonusesForDegreeWithGradeOfB.kCareerLevelBonusFromDegree; break; case AcademicsUtility.AcademicGrade.A: careerLevelBonusFromDegree = Career.kCareerBonusesForDegreeWithGradeOfA.kCareerLevelBonusFromDegree; break; } } } result = Math.Max(careerLevelBonusFromDegree, result); SocialNetworkingSkill element = career.OwnerDescription.SkillManager.GetElement(SkillNames.SocialNetworking) as SocialNetworkingSkill; if (element != null) { careerLevelBonusFromDegree = element.GetCurrentCareerBoost(); } return Math.Max(careerLevelBonusFromDegree, result); }
partial void Occupations_Updating(Occupation entity) { entity.UpdateDate = DateTime.Now; entity.UpdateUser = Application.User.Name; }
public static List <KnownInfo> GetKnownInfoList(HudModel ths, SimDescription otherSimDesc, InformationLearnedAboutSim learnedInfo) { List <KnownInfo> list = new List <KnownInfo>(); Common.StringBuilder msg = new Common.StringBuilder("GetKnownInfoList" + Common.NewLine); try { if (otherSimDesc != null) { bool isHuman = otherSimDesc.IsHuman; bool isTeen = (otherSimDesc.Age & CASAgeGenderFlags.Teen) != CASAgeGenderFlags.None; bool isChild = (otherSimDesc.Age & CASAgeGenderFlags.Child) != CASAgeGenderFlags.None; string str = Localization.LocalizeString("Ui/Caption/HUD/RelationshipsPanel:UnknownTrait", new object[0x0]); msg += "A"; foreach (Trait trait in otherSimDesc.TraitManager.List) { if (!trait.IsVisible || !Localization.HasLocalizationString(trait.TraitNameInfo)) { continue; } bool flag4 = false; foreach (TraitNames names in learnedInfo.Traits) { if (trait.Guid == names) { list.Add(new KnownInfo(trait.TraitName(otherSimDesc.IsFemale), trait.IconKey, KnownInfoType.Trait)); flag4 = true; break; } } if (!flag4) { list.Add(new KnownInfo(str, ResourceKey.CreatePNGKey("trait_unknown", 0x0), KnownInfoType.TraitUnknown)); } } msg += "B"; if ((isHuman && learnedInfo.CareerKnown) && !isChild) { bool flag5 = false; WorldName currentWorld = GameUtils.GetCurrentWorld(); if ((otherSimDesc.HomeWorld != currentWorld) && (GameUtils.GetWorldType(currentWorld) == WorldType.Vacation)) { MiniSimDescription description = MiniSimDescription.Find(otherSimDesc.SimDescriptionId); if (description != null) { ResourceKey iconKey = string.IsNullOrEmpty(description.JobIcon) ? ResourceKey.kInvalidResourceKey : ResourceKey.CreatePNGKey(description.JobIcon, 0x0); list.Add(new KnownInfo(Localization.LocalizeString(description.IsFemale, description.JobOrServiceName, new object[0x0]), iconKey, KnownInfoType.Career)); flag5 = true; } } msg += "C"; if (!flag5) { CareerManager careerManager = otherSimDesc.CareerManager; if ((careerManager != null) && (careerManager.Occupation != null)) { msg += "C1"; Occupation occupation = careerManager.Occupation; string careerIcon = occupation.CareerIcon; ResourceKey key2 = string.IsNullOrEmpty(careerIcon) ? ResourceKey.kInvalidResourceKey : ResourceKey.CreatePNGKey(careerIcon, 0x0); KnownInfoType type = occupation.IsAcademicCareer ? KnownInfoType.AcademicCareer : KnownInfoType.Career; list.Add(new KnownInfo(occupation.CurLevelJobTitle, key2, type)); } else if ((otherSimDesc.CreatedByService != null) && Sims3.Gameplay.Services.Services.IsSimDescriptionInAnyServicePool(otherSimDesc)) { string str4 = Localization.LocalizeString(otherSimDesc.IsFemale, "Gameplay/Services/Title:" + otherSimDesc.CreatedByService.ServiceType.ToString(), new object[0x0]); list.Add(new KnownInfo(str4, ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } else if ((otherSimDesc.AssignedRole != null) && !string.IsNullOrEmpty(otherSimDesc.AssignedRole.CareerTitleKey)) { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, otherSimDesc.AssignedRole.CareerTitleKey, new object[0x0]), ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } else if (((careerManager != null) && (careerManager.Occupation == null)) && (careerManager.RetiredCareer != null)) { list.Add(new KnownInfo(Localization.LocalizeString("Ui/Caption/HUD/Career:Retired", new object[0x0]), ResourceKey.CreatePNGKey(careerManager.RetiredCareer.CareerIcon, 0x0), KnownInfoType.Career)); } else { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:Unemployed", new object[0x0]), ResourceKey.kInvalidResourceKey, KnownInfoType.Career)); } } } msg += "D"; if (learnedInfo.PartnerKnown) { string firstName = null; ResourceKey relationshipImageKey = ResourceKey.kInvalidResourceKey; if (otherSimDesc.Partner != null) { msg += "D1"; firstName = otherSimDesc.Partner.FirstName; // Custom : false -> true Relationship relationship = otherSimDesc.GetRelationship(otherSimDesc.Partner, true); if (relationship != null) { relationshipImageKey = RelationshipFunctions.GetLTRRelationshipImageKey(relationship.LTR.CurrentLTR, relationship.IsPetToPetRelationship); } } else { msg += "D2"; if (otherSimDesc.HomeWorld != GameUtils.GetCurrentWorld()) { MiniSimDescription description2 = MiniSimDescription.Find(otherSimDesc.SimDescriptionId); if ((description2 != null) && (description2.PartnerId != 0x0L)) { MiniSimDescription otherSim = MiniSimDescription.Find(description2.PartnerId); if (otherSim != null) { firstName = otherSim.FirstName; MiniRelationship miniRelationship = description2.GetMiniRelationship(otherSim) as MiniRelationship; if (miniRelationship != null) { relationshipImageKey = RelationshipFunctions.GetLTRRelationshipImageKey(miniRelationship.CurrentLTR, miniRelationship.IsPetToPetRelationship); } } } } if (string.IsNullOrEmpty(firstName)) { firstName = Localization.LocalizeString("Ui/Caption/HUD/KnownInfoDialog:None", new object[0x0]); } } list.Add(new KnownInfo(firstName, relationshipImageKey, KnownInfoType.Partner)); } msg += "E"; if ((isHuman && (isTeen || isChild)) && ((otherSimDesc.CareerManager != null) && (otherSimDesc.CareerManager.School != null))) { list.Add(new KnownInfo(otherSimDesc.CareerManager.School.Name, ResourceKey.CreatePNGKey(otherSimDesc.CareerManager.School.CareerIcon, 0x0), KnownInfoType.School)); } if (learnedInfo.IsRichAndKnownToBeRich) { list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:IsRich", new object[0x0]), ResourceKey.CreatePNGKey("w_simoleon_32", 0x0), KnownInfoType.Rich)); } if (isHuman && learnedInfo.SignKnown) { Zodiac zodiac = otherSimDesc.Zodiac; list.Add(new KnownInfo(Localization.LocalizeString(otherSimDesc.IsFemale, "Ui/Caption/HUD/KnownInfoDialog:" + zodiac.ToString(), new object[0x0]), ResourceKey.CreatePNGKey("sign_" + zodiac.ToString() + "_sm", 0x0), KnownInfoType.Zodiac)); } if (isHuman && learnedInfo.AlmaMaterKnown) { if (otherSimDesc.AlmaMater != AlmaMater.None) { list.Add(new KnownInfo(otherSimDesc.AlmaMaterName, ResourceKey.CreatePNGKey("w_simple_school_career_s", 0), KnownInfoType.AlmaMater)); } if (((otherSimDesc.CareerManager != null) && (otherSimDesc.CareerManager.DegreeManager != null)) && (otherSimDesc.CareerManager.DegreeManager.GetDegreeEntries().Count > 0)) { list.Add(new KnownInfo(Localization.LocalizeString("Ui/Caption/HUD/KnownInfoTooltip:UniversityAlmaMater", new object[0]), ResourceKey.CreatePNGKey("moodlet_just_graduated", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.AlmaMater)); } } msg += "G"; uint celebrityLevel = otherSimDesc.CelebrityLevel; if (celebrityLevel > 0x0) { KnownInfo item = new KnownInfo(otherSimDesc.CelebrityManager.LevelName, ResourceKey.CreatePNGKey("hud_i_celebrity_page", 0x0), KnownInfoType.CelebrityLevel); item.mCelebrityLevel = celebrityLevel; list.Add(item); } msg += "H"; if (learnedInfo.IsSocialGroupsKnown) { TraitManager traitManager = otherSimDesc.TraitManager; SkillManager skillManager = otherSimDesc.SkillManager; if ((traitManager != null) && (skillManager != null)) { if (traitManager.HasElement(TraitNames.InfluenceNerd)) { InfluenceSkill skill = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceNerd); if ((skill != null) && (skill.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Nerd", new object[0]), "(", skill.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup01_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } if (traitManager.HasElement(TraitNames.InfluenceSocialite)) { InfluenceSkill skill2 = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceSocialite); if ((skill2 != null) && (skill2.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Jock", new object[0]), "(", skill2.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup03_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } if (traitManager.HasElement(TraitNames.InfluenceRebel)) { InfluenceSkill skill3 = skillManager.GetSkill <InfluenceSkill>(SkillNames.InfluenceRebel); if ((skill3 != null) && (skill3.SkillLevel > 0)) { list.Add(new KnownInfo(string.Concat(new object[] { Localization.LocalizeString("Ui/Tooltips/SocialGroup:Rebel", new object[0]), "(", skill3.SkillLevel, ")" }), ResourceKey.CreatePNGKey("trait_SocialGroup02_s", ResourceUtils.ProductVersionToGroupId(ProductVersion.EP9)), KnownInfoType.SocialGroup)); } } } } msg += "I"; if (learnedInfo.NumDegreesKnown() > 0) { KnownInfo info2 = new KnownInfo("", ResourceKey.kInvalidResourceKey, KnownInfoType.Degree); otherSimDesc.CareerManager.DegreeManager.GetCompletedDegreeEntries(); foreach (AcademicDegreeNames names2 in learnedInfo.Degrees) { AcademicDegree element = otherSimDesc.CareerManager.DegreeManager.GetElement(names2); if ((element != null) && element.IsDegreeCompleted) { if (info2.mDegreeIcons.Count == 5) { list.Add(info2); info2 = new KnownInfo("", ResourceKey.kInvalidResourceKey, KnownInfoType.Degree); } ResourceKey key4 = ResourceKey.CreatePNGKey(element.DegreeIcon, 0); info2.mDegreeIcons.Add(key4); info2.mIconKey = key4; info2.mInfo = element.DegreeName; } } list.Add(info2); } } } catch (Exception e) { Common.Exception(otherSimDesc, null, msg, e); } return(list); }
/// <summary> /// Creating new maze /// </summary> /// <param name="width">Matrix width in places</param> /// <param name="height">Matrix height in places</param> /// <returns>Maze matrix</returns> public Occupation[,] Create(int width, int height) { if (width < 10 || height < 10) { return(null); } width = Round(width); height = Round(height); int x; int y; bool finish = false; List <string> dir = new List <string>(); Node[,] field = new Node[width, height]; var random = new Random(); int j = Round(random.Next(0, height - 1)); field[1, j].Path = true; // fork field[1, j].Check = true; // passable place while (true) { finish = true; for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (field[x, y].Path) // search fork flag { finish = false; // If the path is clear, add direction if (x - 2 >= 0) { if (!field[x - 2, y].Check) { dir.Add("Left"); } } if (y - 2 >= 0) { if (!field[x, y - 2].Check) { dir.Add("Down"); } } if (x + 2 < width) { if (!field[x + 2, y].Check) { dir.Add("Right"); } } if (y + 2 < height) { if (!field[x, y + 2].Check) { dir.Add("Up"); } } if (dir.Count > 0) { switch (dir[random.Next(0, dir.Count)]) // Choice a random direction { case "Left": field[x - 1, y].Check = true; field[x - 2, y].Check = true; field[x - 2, y].Path = true; break; case "Down": field[x, y - 1].Check = true; field[x, y - 2].Check = true; field[x, y - 2].Path = true; break; case "Right": field[x + 1, y].Check = true; field[x + 2, y].Check = true; field[x + 2, y].Path = true; break; case "Up": field[x, y + 1].Check = true; field[x, y + 2].Check = true; field[x, y + 2].Path = true; break; } } else { field[x, y].Path = false; // direction can not be added, remove the checkbox } dir.Clear(); // Clearing list } } } if (finish) { break; // There was not a single fork } } Occupation[,] matrix = new Occupation[width, height]; // Filling a matrix (1 is passable place, and -1 is wall) for (y = 0; y < height; y++) { for (x = 0; x < width; x++) { if (field[x, y].Check) { matrix[x, y] = Occupation.Wall; } else { matrix[x, y] = Occupation.Empty; } } } MakePassagesWall(matrix); return(matrix); }
public async Task PostPatientAsync(PatientDto patientdto) { var patient = new Patient(); patient.PatientId = patientdto.PatientDtoId; patient.Name = patientdto.Name; patient.Age = patientdto.Age; patient.Gender = patientdto.Gender; patient.Phone = patientdto.Phone; patient.AadharId = patientdto.AadharId; patient.IsAffected = patientdto.IsAffected; patient.Address = new List <Address>(); foreach (var item in patientdto.Addresses) { var address = new Address(); address.AddressType = item.AddressType; address.Hno = item.Hno; address.Street = item.Street; address.City = item.City; address.State = item.State; address.Country = item.Country; address.Pincode = item.Pincode; patient.Address.Add(address); } patient.Occupation = new List <Occupation>(); foreach (var item in patientdto.Occupations) { var occupation = new Occupation(); occupation.Name = item.Name; occupation.Phone = item.Phone; occupation.StreetNo = item.StreetNo; occupation.Area = item.Area; occupation.City = item.City; occupation.State = item.State; occupation.Country = item.Country; occupation.Pincode = item.Pincode; patient.Occupation.Add(occupation); } patient.Treatment = new List <Treatment>(); foreach (var item in patientdto.Treatments) { var treatment = new Treatment(); treatment.AdmittedDate = item.AdmittedDate; treatment.PercentageCure = item.PercentageCure; treatment.RelievingDate = item.RelievingDate; treatment.Isfatility = item.Isfatility; treatment.Disease = new Disease() { DiseaseId = item.DiseaseDto.DiseaseDtoId, Name = item.DiseaseDto.Name }; treatment.Hospital = new Hospital() { HospitalId = item.HospitalDto.HospitalDtoId, Name = item.HospitalDto.Name, }; patient.Treatment.Add(treatment); } _context.Patient.Add(patient); await _context.SaveChangesAsync(); }
public static void RemoveInvalidCoworkers(Occupation ths) { if (ths.Coworkers != null) { // Custom for (int i = ths.Coworkers.Count - 1; i >= 0; i--) { if ((ths.Coworkers[i] == null) || (ths.Coworkers[i] == ths.OwnerDescription)) { ths.Coworkers.RemoveAt(i); } } List<SimDescription> list = new List<SimDescription>(ths.Coworkers); foreach (SimDescription description in list) { if ((!description.IsValidDescription || ((description.DeathStyle != SimDescription.DeathType.None) && !description.IsPlayableGhost)) || !description.IsHuman) { ths.RemoveCoworker(description); } } } }
public static Sim Perform(Sim sim, bool fadeOut) { if (sim == null) { return(null); } try { SimDescription simDesc = sim.SimDescription; if (Simulator.GetProxy(sim.ObjectId) == null) { if (simDesc != null) { sim.Destroy(); } //sim.mSimDescription = null; return(null); } if (simDesc == null) { sim.mSimDescription = new SimDescription(); sim.Destroy(); return(null); } if (sim.LotHome != null) { simDesc.IsZombie = false; if (simDesc.CreatedSim != sim) { sim.Destroy(); simDesc.CreatedSim = null; return(null); } else { Bed myBed = null; BedData myBedData = null; foreach (Bed bed in sim.LotHome.GetObjects <Bed>()) { myBedData = bed.GetPartOwnedBy(sim); if (myBedData != null) { myBed = bed; break; } } ResetPosture(sim); if (simDesc.TraitManager == null) { simDesc.mTraitManager = new TraitManager(); } try { simDesc.Fixup(); Corrections.CleanupBrokenSkills(simDesc, null); ResetCareer(simDesc); simDesc.ClearSpecialFlags(); if (simDesc.Pregnancy == null) { try { if (simDesc.mMaternityOutfits == null) { simDesc.mMaternityOutfits = new OutfitCategoryMap(); } simDesc.SetPregnancy(0, false); simDesc.ClearMaternityOutfits(); } catch (Exception e) { Common.Exception(sim, null, "Pregnancy", e); } } if (sim.CurrentCommodityInteractionMap == null) { try { LotManager.PlaceObjectOnLot(sim, sim.ObjectId); if (sim.CurrentCommodityInteractionMap == null) { sim.ChangeCommodityInteractionMap(sim.LotHome.Map); } } catch (Exception e) { Common.Exception(sim, null, "ChangeCommodityInteractionMap", e); } } } catch (Exception e) { Common.Exception(sim, null, "Fixup", e); } ResetSituations(sim); CleanupSlots(sim); ResetInventory(sim); if (fadeOut) { bool active = (Sim.ActiveActor == sim); if (sSimReset.Valid) { sSimReset.Invoke <bool>(new object[] { simDesc.SimDescriptionId }); } ResetRouting(sim); using (CreationProtection protection = new CreationProtection(simDesc, sim, false, true, false)) { sim.Destroy(); Common.Sleep(); sim = FixInvisibleTask.InstantiateAtHome(simDesc, null); } if (sim != null) { if (active) { try { foreach (Sim member in Households.AllSims(sim.Household)) { if (member.CareerManager == null) { continue; } Occupation occupation = member.CareerManager.Occupation; if (occupation == null) { continue; } occupation.FormerBoss = null; } using (DreamCatcher.HouseholdStore store = new DreamCatcher.HouseholdStore(sim.Household, true)) { PlumbBob.DoSelectActor(sim, true); } } catch (Exception e) { Common.Exception(sim, null, "DoSelectActor", e); } } if ((myBed != null) && (myBedData != null)) { if (!(myBed is BedMultiPart) || (myBed is BedMultiPart && ((sim.Partner != null) && (sim.Partner.CreatedSim != null)))) { myBed.ClaimOwnership(sim, myBedData); } else { HandleDoubleBed(sim, myBed, myBedData); } } } } else { if (sim.Inventory == null) { sim.AddComponent <InventoryComponent>(new object[0x0]); } if (Instantiation.AttemptToPutInSafeLocation(sim, false)) { ResetRouting(sim); sim.SetObjectToReset(); // This is necessary to clear certain types of interactions // (it is also called in SetObjectToReset(), though doesn't always work there) if (sim.InteractionQueue != null) { sim.InteractionQueue.OnReset(); } } } ResetSkillModifiers(simDesc); ResetRole(sim); if (simDesc.IsEnrolledInBoardingSchool()) { simDesc.BoardingSchool.OnRemovedFromSchool(); } MiniSimDescription miniSim = MiniSimDescription.Find(simDesc.SimDescriptionId); if (miniSim != null) { miniSim.Instantiated = true; } UpdateInterface(sim); return(sim); } } else if (simDesc.Service is Butler) { if (Instantiation.AttemptToPutInSafeLocation(sim, true)) { sim.Motives.RecreateMotives(sim); sim.SetObjectToReset(); } return(sim); } else if (simDesc.IsImaginaryFriend) { OccultImaginaryFriend friend; if (OccultImaginaryFriend.TryGetOccultFromSim(sim, out friend)) { if (Simulator.GetProxy(friend.mDollId) != null) { friend.TurnBackIntoDoll(OccultImaginaryFriend.Destination.Owner); return(null); } } } else if (simDesc.IsBonehilda) { foreach (BonehildaCoffin coffin in Sims3.Gameplay.Queries.GetObjects <BonehildaCoffin>()) { if (coffin.mBonehilda == simDesc) { coffin.mBonehildaSim = null; break; } } } if (fadeOut) { sim.Destroy(); } return(null); } catch (Exception exception) { Common.Exception(sim, exception); return(sim); } }
public void ChangeAssignment(Occupation occupationToSet) { console.TargetCard.ServerChangeOccupation(occupationToSet); UpdateAssignment(); }
private void btnSubmit_Click(object sender, EventArgs e) { // Converting to enums try { Countries nationality = (Countries)Enum.Parse(typeof(Countries), comboNationality.SelectedItem.ToString()); Countries issuingCountry = (Countries)Enum.Parse(typeof(Countries), comboIssuingCountry.SelectedItem.ToString()); Occupation occupation = (Occupation)Enum.Parse(typeof(Occupation), comboOccupation.SelectedItem.ToString()); DocumentType documentType = (DocumentType)Enum.Parse(typeof(DocumentType), comboDocumentType.SelectedItem.ToString()); IssuingBody issuingBody = (IssuingBody)Enum.Parse(typeof(IssuingBody), comboIssuingBody.SelectedItem.ToString()); string gender; if (radioMale.Checked) { gender = "Male"; } else { gender = "Female"; } //Check whether it is a national or international guest if (comboNationality.SelectedItem.ToString() == Globals.hotelCountry) { NationalGuest guest = new NationalGuest( txtFirstName.Text, txtLastName.Text, txtEmail.Text, occupation, dtpBirth.Value, nationality, Convert.ToInt64(txtPhone.Text), Convert.ToInt64(txtDocument.Text), documentType, issuingBody ); MySqlConnection con = new MySqlConnection(Globals.connString); con.Open(); try { MySqlCommand cmd = new MySqlCommand("SaveNewGuest", con); cmd.Parameters.Add("_first_name", MySqlDbType.VarChar, 55).Value = guest.FirstName; cmd.Parameters.Add("_last_name", MySqlDbType.VarChar, 55).Value = guest.LastName; cmd.Parameters.Add("_email", MySqlDbType.VarChar, 60).Value = guest.Email; cmd.Parameters.Add("_occupation", MySqlDbType.VarChar, 45).Value = guest.Occupation; cmd.Parameters.Add("_birth_date", MySqlDbType.Date).Value = guest.Birthdate; cmd.Parameters.Add("_nationality", MySqlDbType.VarChar, 60).Value = Globals.hotelCountry; cmd.Parameters.Add("_gender", MySqlDbType.VarChar, 6).Value = gender; cmd.Parameters.Add("_phone", MySqlDbType.VarChar, 50).Value = guest.Phone; cmd.Parameters.Add("_document", MySqlDbType.VarChar, 50).Value = guest.Document; cmd.Parameters.Add("_document_type", MySqlDbType.VarChar, 25).Value = guest.DocumentType; cmd.Parameters.Add("_issuing_body", MySqlDbType.VarChar, 45).Value = guest.IssuingBody; cmd.Parameters.Add("_issuing_country", MySqlDbType.VarChar, 60).Value = Globals.hotelCountry; cmd.Parameters.Add("_is_international", MySqlDbType.Int16).Value = 0; cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); MessageBox.Show("Guest saved successfully!"); this.Close(); var form = new GuestListFrm(); form.Show(); } catch (Exception ex) { throw ex; } con.Close(); } else { InternationalGuest guest = new InternationalGuest( txtFirstName.Text, txtLastName.Text, txtEmail.Text, occupation, dtpBirth.Value, nationality, Convert.ToInt64(txtPhone.Text), txtDocument.Text, issuingCountry ); MySqlConnection con = new MySqlConnection(Globals.connString); con.Open(); try { MySqlCommand cmd = new MySqlCommand("SaveNewGuest", con); cmd.Parameters.Add("_first_name", MySqlDbType.VarChar, 55).Value = guest.FirstName; cmd.Parameters.Add("_last_name", MySqlDbType.VarChar, 55).Value = guest.LastName; cmd.Parameters.Add("_email", MySqlDbType.VarChar, 60).Value = guest.Email; cmd.Parameters.Add("_occupation", MySqlDbType.VarChar, 45).Value = guest.Occupation; cmd.Parameters.Add("_birth_date", MySqlDbType.Date).Value = guest.Birthdate; cmd.Parameters.Add("_nationality", MySqlDbType.VarChar, 60).Value = guest.Nationality; cmd.Parameters.Add("_gender", MySqlDbType.VarChar, 6).Value = gender; cmd.Parameters.Add("_phone", MySqlDbType.VarChar, 50).Value = guest.Phone; cmd.Parameters.Add("_document", MySqlDbType.VarChar, 50).Value = guest.Passport; cmd.Parameters.Add("_document_type", MySqlDbType.VarChar, 25).Value = Globals.foreignDocument; cmd.Parameters.Add("_issuing_body", MySqlDbType.VarChar, 45).Value = null; cmd.Parameters.Add("_issuing_country", MySqlDbType.VarChar, 60).Value = issuingCountry; cmd.Parameters.Add("_is_international", MySqlDbType.Int16).Value = 1; cmd.CommandType = CommandType.StoredProcedure; cmd.ExecuteNonQuery(); MessageBox.Show("Guest saved successfully!"); this.Close(); var form = new GuestListFrm(); form.Show(); } catch (Exception ex) { throw ex; } con.Close(); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public static void FixCareer(Occupation job, bool allowDrop, Logger log) { if (job == null) { return; } if (job.Coworkers != null) { for (int i = job.Coworkers.Count - 1; i >= 0; i--) { SimDescription coworker = job.Coworkers[i]; if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription)) { job.Coworkers.RemoveAt(i); if (coworker == null) { if (log != null) { log(" Bad Coworker " + job.CareerName + " - <Invalid>"); } } else { if (log != null) { log(" Bad Coworker " + job.CareerName + " - " + coworker.FullName); } } } } } if ((allowDrop) && (job is Career)) { bool replace = false; if (job.CareerLoc == null) { if (log != null) { log(" Bad Location " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole hole = job.CareerLoc.Owner; if (hole == null) { if (log != null) { log(" Missing Rabbithole " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole proxy = hole.RabbitHoleProxy; if (proxy == null) { if (log != null) { log(" Missing Proxy " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) || (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0)) { if (log != null) { log(" Missing Slots " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } } } } if (replace) { SimDescription me = job.OwnerDescription; Occupation retiredJob = me.CareerManager.mRetiredCareer; try { CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid); if (location != null) { if (log != null) { log(" Location Replaced " + me.FullName); } if (job.CareerLoc != null) { job.CareerLoc.Workers.Remove(me); } job.CareerLoc = location; location.Workers.Add(me); } else { if (log != null) { log(" Career Dropped " + me.FullName); } job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } } finally { me.CareerManager.mRetiredCareer = retiredJob; } } } }
/// <summary> /// Spawns a new player character and transfers the connection's control into the new body. /// If existingMind is null, creates the new mind and assigns it to the new body. /// /// Fires server and client side player spawn hooks. /// </summary> /// <param name="connection">connection to give control to the new player character</param> /// <param name="occupation">occupation of the new player character</param> /// <param name="characterSettings">settings of the new player character</param> /// <param name="existingMind">existing mind to transfer to the new player, if null new mind will be created /// and assigned to the new player character</param> /// <param name="spawnPos">world position to spawn at</param> /// <param name="naked">If spawning a player, should the player spawn without the defined initial equipment for their occupation?</param> /// <param name="willDestroyOldBody">if true, indicates the old body is going to be destroyed rather than pooled, /// thus we shouldn't send any network message which reference's the old body's ID since it won't exist.</param> /// /// <returns>the spawned object</returns> private static GameObject ServerSpawnInternal(NetworkConnection connection, Occupation occupation, CharacterSettings characterSettings, Mind existingMind, Vector3Int?spawnPos = null, bool naked = false, bool willDestroyOldBody = false) { //determine where to spawn them if (spawnPos == null) { Transform spawnTransform; //Spawn normal location for special jobs or if less than 2 minutes passed if (GameManager.Instance.stationTime < ARRIVALS_SPAWN_TIME || NEVER_SPAWN_ARRIVALS_JOBS.Contains(occupation.JobType)) { spawnTransform = GetSpawnForJob(occupation.JobType); } else { spawnTransform = GetSpawnForLateJoin(occupation.JobType); //Fallback to assistant spawn location if none found for late join if (spawnTransform == null && occupation.JobType != JobType.NULL) { spawnTransform = GetSpawnForJob(JobType.ASSISTANT); } } if (spawnTransform == null) { Logger.LogErrorFormat( "Unable to determine spawn position for connection {0} occupation {1}. Cannot spawn player.", Category.ItemSpawn, connection.address, occupation.DisplayName); return(null); } spawnPos = spawnTransform.transform.position.CutToInt(); } //create the player object var newPlayer = ServerCreatePlayer(spawnPos.GetValueOrDefault()); var newPlayerScript = newPlayer.GetComponent <PlayerScript>(); //get the old body if they have one. var oldBody = existingMind?.GetCurrentMob(); //transfer control to the player object ServerTransferPlayer(connection, newPlayer, oldBody, EVENT.PlayerSpawned, characterSettings, willDestroyOldBody); if (existingMind == null) { //create the mind of the player Mind.Create(newPlayer, occupation); } else { //transfer the mind to the new body existingMind.SetNewBody(newPlayerScript); } var ps = newPlayer.GetComponent <PlayerScript>(); var connectedPlayer = PlayerList.Instance.Get(connection); connectedPlayer.Name = ps.playerName; connectedPlayer.Job = ps.mind.occupation.JobType; UpdateConnectedPlayersMessage.Send(); //fire all hooks var info = SpawnInfo.Player(occupation, characterSettings, CustomNetworkManager.Instance.humanPlayerPrefab, SpawnDestination.At(spawnPos), naked: naked); Spawn._ServerFireClientServerSpawnHooks(SpawnResult.Single(info, newPlayer)); return(newPlayer); }
/// <summary> /// Create a new player spawn info indicating a request to spawn with the /// selected occupation and settings. /// </summary> /// <returns></returns> public static PlayerSpawnRequest RequestOccupation(JoinedViewer requestedBy, Occupation requestedOccupation, CharacterSettings characterSettings) { return(new PlayerSpawnRequest(requestedOccupation, requestedBy, characterSettings)); }
public static PlayerSpawnRequest RequestOccupation(ConnectedPlayer requestedBy, Occupation requestedOccupation) { return(new PlayerSpawnRequest(requestedOccupation, requestedBy.ViewerScript, requestedBy.CharacterSettings)); }
/// <summary> /// This method will return a full list of intialized and linked items of each category. For test purposes. /// </summary> /// <param name="itemLinkFactory">The factory that creates linked items</param> /// <returns>A list of all item types.</returns> public static List <MemoryItem> CreateItemsAndLinkThem(IItemLinkFactory itemLinkFactory) { //Organizations var witchers = new Organization("The Order of Witchers", OrganizationType.Trade, Guid.NewGuid(), WitcherDesc) { Started = new CustomDateTime(1031) }; var governmentOfNilfgaard = new Organization("The Kingdom of Nilfgaard", OrganizationType.Government, Guid.NewGuid()); var EmperorOfNilfgaard = new Occupation("Imperator", OccupationType.Political, Guid.NewGuid(), "A shadowy figure"); var governmentOfCintra = new Organization("The Kingdom of Cintra", OrganizationType.Government, Guid.NewGuid()); var organizations = new List <Organization> { witchers, governmentOfNilfgaard, governmentOfCintra }; //Occupations //Geralt of Rivia, witcher. var GeraltOfRivia = new Person("Geralt of Rivia", Gender.Male, Sex.Male, Orientation.Straight, Guid.NewGuid(), GeraltDesc); var witcherGeralt = new Occupation("Witcher", GeraltOfRivia, OccupationType.Independant, Guid.NewGuid(), WitcherDesc) { Started = new CustomDateTime(1031) }; GeraltOfRivia.AddOccupation(witcherGeralt); List <MemoryItem> linkObjects = new List <MemoryItem>(); List <MemoryItemLink> intermediateObjects = new List <MemoryItemLink>(); var association1 = itemLinkFactory.CreateAssociationBetweenPersonAndOrganization(GeraltOfRivia, witchers, AssociationType.Member); linkObjects.Add(association1); //Foltest, king of Temeria var Foltest = new Person("Foltest", Guid.NewGuid(), FoltestDesc) { Gender = Gender.Male, Sex = Sex.Male }; Occupation kingOfTemeria = new Occupation("King of Temeria", Foltest, OccupationType.Political, Guid.NewGuid()); Foltest.AddOccupation(kingOfTemeria); Person Meve = new Person("Meve", Guid.NewGuid()); Occupation queen = new Occupation("Queen", OccupationType.Political, Guid.NewGuid()); Meve.AddOccupation(queen); var relationship1 = itemLinkFactory.CreateRelationshipBetweenTwoPersons(Meve, Foltest, PersonalRelationshipTypeName.Wife, PersonalRelationshipTypeName.Husband); linkObjects.AddRange(relationship1); //Calanthe, The Lion Queen of Cintra var Calanthe = new Person("Calanthe", Gender.Female, Sex.Female, Orientation.Bisexual, Guid.NewGuid(), new CustomDateTime(1218), CalantheDesc) { DateOfDeath = new CustomDateTime(1265) }; Occupation queenOfCintra = new Occupation("Queen of Cintra", Calanthe, OccupationType.Political, Guid.NewGuid(), new CustomDateTime(1232), new CustomDateTime(1263)); Calanthe.AddOccupation(queenOfCintra); var association2 = itemLinkFactory.CreateAssociationBetweenPersonAndOrganization(Calanthe, governmentOfCintra, AssociationType.Leader, new CustomDateTime(1232), new CustomDateTime(1263)); linkObjects.Add(association2); //Princess Pavetta of Cintra var Pavetta = new Person("Princess Pavetta", Gender.Female, Sex.Female, Orientation.Straight, Guid.NewGuid(), new CustomDateTime(1237), PavettaDesc) { DateOfDeath = new CustomDateTime(1257) }; //Ciri, princess of Cintra. No, not the Apple thing. var Ciri = new Person("Princess Cirilla Fiona Elen Riannon", Gender.Female, Sex.Female, Orientation.Straight, Guid.NewGuid(), new CustomDateTime(1253, 5, 1), CiriDesc); var relationships1 = itemLinkFactory.CreateRelationshipBetweenTwoPersons(Calanthe, Pavetta, PersonalRelationshipTypeName.Mother, PersonalRelationshipTypeName.Daughter); var relationships2 = itemLinkFactory.CreateRelationshipBetweenTwoPersons(Pavetta, Ciri, PersonalRelationshipTypeName.Mother, PersonalRelationshipTypeName.Daughter, new CustomDateTime(1253, 5, 1)); linkObjects.AddRange(relationships1); linkObjects.AddRange(relationships2); var persons = new List <Person> { GeraltOfRivia, Foltest, Calanthe, Pavetta, Ciri, Meve }; //Events PastEvent ageOfMigration = new PastEvent("the Age of Migration", Guid.NewGuid(), MigrationDesc) { Type = PastEventType.Social, Started = new CustomDateTime(-2230), Ended = new CustomDateTime(-2230) }; PastEvent theConjunction = new PastEvent("The Conjunction of the Spheres", Guid.NewGuid(), ConjunctionDesc, new CustomDateTime(-230), new CustomDateTime(-230)) { Type = PastEventType.Magical }; PastEvent theResurrection = new PastEvent("The Resurrection", Guid.NewGuid(), "", new CustomDateTime(1)) { Type = PastEventType.Magical, Ended = new CustomDateTime(1), }; var link1 = itemLinkFactory.CreateLinkBetweenTwoEvents(theResurrection, theConjunction, EventRelationshipType.Preceded); linkObjects.AddRange(link1); PastEvent NilfgaardInvasion = new PastEvent("The Northern Wars", Guid.NewGuid(), NorthernWarsDesc, new CustomDateTime(1239)); PastEvent conquestOfRedania = new PastEvent("Conquest of Redania", Guid.NewGuid()); PastEvent battleOfBrenna = new PastEvent("The Battle Of Brenna", Guid.NewGuid(), BattleOfBrennaDesc, new CustomDateTime(1268, 03, 01)); PastEvent conquestOfCintra = new PastEvent("Conquest of Cintra", Guid.NewGuid()); var link2 = itemLinkFactory.CreateLinkBetweenTwoEvents(NilfgaardInvasion, battleOfBrenna, EventRelationshipType.Included); linkObjects.AddRange(link2); var involvement1 = itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(Foltest, NilfgaardInvasion, PersonalInvolvementType.WasCaughtIn); var involvement2 = itemLinkFactory.CreateInvolvementBetweenOccupationAndEvent(queenOfCintra, NilfgaardInvasion, OccupationalInvolvementType.DiedDuring); var involvement = itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(GeraltOfRivia, NilfgaardInvasion, PersonalInvolvementType.FoughtIn); intermediateObjects.Add(involvement); intermediateObjects.Add(involvement1); intermediateObjects.Add(involvement2); PastEvent theRivianPogrom = new PastEvent("Rivian Pogrom", Guid.NewGuid(), TheRivianPogromDesc, new CustomDateTime(1268, 6, 6)); itemLinkFactory.CreateInvolvementBetweenPersonAndEvent(GeraltOfRivia, theRivianPogrom, PersonalInvolvementType.DiedDuring, new CustomDateTime(1268, 6, 6)); PastEvent independenceOfKovir = new PastEvent("Independence of Kovir", Guid.NewGuid(), IndependanceOfKovirDesc, new CustomDateTime(1140)); Occupation kingOfRedania = new Occupation("King of Redania", OccupationType.Political, Guid.NewGuid(), "The King of Redania was known to wage war against Kovir when they declared their independance."); var involvement4 = itemLinkFactory.CreateInvolvementBetweenOccupationAndEvent(kingOfRedania, independenceOfKovir, OccupationalInvolvementType.WasCaughtIn, new CustomDateTime(1140)); intermediateObjects.Add(involvement4); var events = new List <PastEvent> { ageOfMigration, theConjunction, theResurrection, NilfgaardInvasion, battleOfBrenna, theRivianPogrom, independenceOfKovir, conquestOfRedania, conquestOfCintra }; //Places Place theContinent = new Place("The Continent", Guid.NewGuid(), ContinentDesc) { Coordinates = new Coordinates { X = 1, Y = 1, Z = 1 }, Type = PlaceType.Continent }; var conjunctionOccurence = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(theConjunction, theContinent, OccurenceType.HappenedIn); intermediateObjects.Add(conjunctionOccurence); var occurence2 = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(NilfgaardInvasion, theContinent, OccurenceType.HappenedIn); intermediateObjects.Add(occurence2); Place Temeria = new Place("Temeria", Guid.NewGuid(), new Coordinates { X = -700, Y = 333, Z = -2 }, TemeriaDesc) { Type = PlaceType.Kingdom }; var link3 = itemLinkFactory.CreateLinkBetweenTwoPlaces(theContinent, Temeria, GeographicRelationshipType.Includes); var tie1 = itemLinkFactory.CreateTieBetweenPersonAndPlace(Foltest, Temeria, PersonalTieType.Led); linkObjects.AddRange(link3); linkObjects.Add(tie1); Place kingdomOfRedania = new Place("Redania", Guid.NewGuid()) { Type = PlaceType.Kingdom }; var redaniaLink = itemLinkFactory.CreateTieBetweenOccupationAndPlace(kingOfRedania, kingdomOfRedania, OccupationalTieType.Led); intermediateObjects.Add(redaniaLink); var conquest = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(conquestOfRedania, kingdomOfRedania, OccurenceType.Conquest); intermediateObjects.Add(conquest); itemLinkFactory.CreateInvolvementBetweenOccupationAndEvent(EmperorOfNilfgaard, conquestOfRedania, OccupationalInvolvementType.Led); Place Sodden = new Place("Sodden", Guid.NewGuid(), SoddenDesc) { Type = PlaceType.State, Coordinates = new Coordinates { X = -1023, Y = 566, Z = 50 } }; var link4 = itemLinkFactory.CreateLinkBetweenTwoPlaces(Temeria, Sodden, GeographicRelationshipType.Includes); linkObjects.AddRange(link4); Place Vizima = new Place("Vizima", Guid.NewGuid(), new Coordinates { X = -746, Y = 656, Z = 142 }, VizimaDesc, new CustomDateTime(849)) { Type = PlaceType.City }; var link5 = itemLinkFactory.CreateLinkBetweenTwoPlaces(Temeria, Vizima, GeographicRelationshipType.Includes, new CustomDateTime(849)); linkObjects.AddRange(link5); Place theNecropolis = new Place("The necropolis", Guid.NewGuid(), FenCaernDesc) { Type = PlaceType.Cemetary, Creation = new CustomDateTime(760) }; Place Cintra = new Place("Cintra", Guid.NewGuid()) { Type = PlaceType.Kingdom, }; var tie2 = itemLinkFactory.CreateTieBetweenPersonAndPlace(Calanthe, Cintra, PersonalTieType.Led, new CustomDateTime(1232), new CustomDateTime(1263)); var tie3 = itemLinkFactory.CreateTieBetweenOccupationAndPlace(queenOfCintra, Cintra, OccupationalTieType.DiedIn); var occurence3 = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(conquestOfCintra, Cintra, OccurenceType.Conquest); var tie5 = itemLinkFactory.CreateTieBetweenOccupationAndPlace(EmperorOfNilfgaard, Cintra, OccupationalTieType.Conquered); linkObjects.Add(tie2); linkObjects.Add(tie3); intermediateObjects.Add(occurence3); intermediateObjects.Add(tie5); Place Nilfgaard = new Place("Nilfgaard", Guid.NewGuid()) { Type = PlaceType.Kingdom, }; //TODO var link6 = itemLinkFactory.CreateLinkBetweenTwoPlaces(Cintra, Nilfgaard, GeographicRelationshipType.PartOf); var link7 = itemLinkFactory.CreateLinkBetweenTwoPlaces(Nilfgaard, Temeria, GeographicRelationshipType.SouthOf); var tie4 = itemLinkFactory.CreateTieBetweenOccupationAndPlace(EmperorOfNilfgaard, Nilfgaard, OccupationalTieType.Led); linkObjects.AddRange(link6); linkObjects.AddRange(link7); intermediateObjects.Add(tie4); Place Skellige = new Place("The Isles of Skellige", Guid.NewGuid()); Occupation Vikings = new Occupation("Vikings", OccupationType.Independant, Guid.NewGuid(), "Brutal warriors"); var link8 = itemLinkFactory.CreateTieBetweenOccupationAndPlace(Vikings, Skellige, OccupationalTieType.OriginatedFrom); linkObjects.Add(link8); var Aedirn = new Place("Aedirn", Guid.NewGuid()) { Type = PlaceType.Kingdom, Creation = new CustomDateTime(813) }; var foundationOfAedirn = new PastEvent("The Foundation of Aedirn", Guid.NewGuid(), "", new CustomDateTime(813), new CustomDateTime(813)) { Type = PastEventType.Political }; events.Add(foundationOfAedirn); var link9 = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(foundationOfAedirn, Aedirn, OccurenceType.Creation); linkObjects.Add(link9); Place kingdomOfKovir = new Place("Kovir", Guid.NewGuid(), new Coordinates(), KingdomOfKovirDesc, new CustomDateTime(1140)) { Type = PlaceType.Kingdom }; var involvement3 = itemLinkFactory.CreateTieBetweenOccupationAndPlace(kingOfRedania, kingdomOfKovir, OccupationalTieType.FoughtAgainst, new CustomDateTime(1140)); intermediateObjects.Add(involvement3); var occurence1 = itemLinkFactory.CreateOccurenceBetweenEventAndPlace(independenceOfKovir, kingdomOfKovir, OccurenceType.Creation, new CustomDateTime(1140)); intermediateObjects.Add(occurence1); var places = new List <Place> { theContinent, Temeria, Sodden, Vizima, theNecropolis, Cintra, Nilfgaard, kingdomOfKovir, Skellige, Aedirn, kingdomOfRedania }; var occupations = new List <Occupation> { EmperorOfNilfgaard, queenOfCintra, kingOfRedania, kingOfTemeria, witcherGeralt, Vikings, queen }; var items = new List <MemoryItem>(); items.AddRange(persons); items.AddRange(events); items.AddRange(places); items.AddRange(organizations); items.AddRange(occupations); items.AddRange(linkObjects); items.AddRange(intermediateObjects); return(items); }
protected static string GetText(Occupation occupation) { if (occupation is Retired) return null; Career career = occupation as Career; if (career != null) { if (career.CurLevel == null) return null; if (occupation.CareerLoc == null) return null; if (occupation.CareerLoc.Owner == null) return null; DaysOfTheWeek nextWorkDay = career.CurLevel.GetNextWorkDay(SimClock.CurrentDayOfWeek); string entryKey = (occupation is School) ? "Gameplay/Careers/Career:FirstSchoolDayDetails" : "Gameplay/Careers/Career:FirstDayDetails"; string text = Common.LocalizeEAString(occupation.OwnerDescription.IsFemale, entryKey, new object[] { occupation.OwnerDescription, occupation.CareerLoc.Owner.CatalogName, SimClockUtils.GetText(career.CurLevel.StartTime), SimClockUtils.GetDayAsText(nextWorkDay) }); if (occupation.Boss != null) { text += Common.NewLine + Common.NewLine + Common.LocalizeEAString(occupation.OwnerDescription.IsFemale, "Gameplay/Careers:MetBoss", new object[] { occupation.OwnerDescription, occupation.Boss }); } return text; } else { XpBasedCareer xpCareer = occupation as XpBasedCareer; if (xpCareer != null) { return PromotedScenario.GenerateXPBasedLevelUp(xpCareer); } } return null; }
public void SetOccupation(Occupation occupation) { //set Occupation in supervillain object and in building where supervillain works supervillain.SetOccupation(occupation); }
public static void EnsureVacationDays(Occupation ths, float hours) { int count = (int)hours / 24; bool flag = false; while ((ths.HoursUntilWork <= hours) && (count >= 0)) { ths.mUnpaidDaysOff++; ths.SetHoursUntilWork(); flag = true; count--; } if (flag) { Sim ownerSim = ths.OwnerSim; if (ownerSim != null) { EventTracker.SendEvent(EventTypeId.kOccupationTookUnpaidTimeOff, ownerSim); } } }
public static void FixCareer(Occupation job, bool allowDrop, Logger log) { if (job == null) return; if (job.Coworkers != null) { for (int i = job.Coworkers.Count - 1; i >= 0; i--) { SimDescription coworker = job.Coworkers[i]; if ((!IsValidCoworker(coworker, job is School)) || (coworker == job.OwnerDescription)) { job.Coworkers.RemoveAt(i); if (coworker == null) { if (log != null) { log(" Bad Coworker " + job.CareerName + " - <Invalid>"); } } else { if (log != null) { log(" Bad Coworker " + job.CareerName + " - " + coworker.FullName); } } } } } if ((allowDrop) && (job is Career)) { bool replace = false; if (job.CareerLoc == null) { if (log != null) { log(" Bad Location " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole hole = job.CareerLoc.Owner; if (hole == null) { if (log != null) { log(" Missing Rabbithole " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { RabbitHole proxy = hole.RabbitHoleProxy; if (proxy == null) { if (log != null) { log(" Missing Proxy " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } else { if ((proxy.EnterSlots == null) || (proxy.EnterSlots.Count == 0) || (proxy.ExitSlots == null) || (proxy.ExitSlots.Count == 0)) { if (log != null) { log(" Missing Slots " + job.CareerName + " - " + job.GetType().ToString()); } replace = true; } } } } if (replace) { SimDescription me = job.OwnerDescription; Occupation retiredJob = me.CareerManager.mRetiredCareer; try { CareerLocation location = Sims3.Gameplay.Careers.Career.FindClosestCareerLocation(me, job.Guid); if (location != null) { if (log != null) { log(" Location Replaced " + me.FullName); } if (job.CareerLoc != null) { job.CareerLoc.Workers.Remove(me); } job.CareerLoc = location; location.Workers.Add(me); } else { if (log != null) { log(" Career Dropped " + me.FullName); } job.LeaveJobNow(Career.LeaveJobReason.kJobBecameInvalid); } } finally { me.CareerManager.mRetiredCareer = retiredJob; } } } }
public void SetOccupation(Occupation eOccu) { Occupation = eOccu; }
// From ManagerCareer in SP. Seems fitting here... public static bool IsCoworkerOrBoss(Occupation career, SimDescription sim) { if (career == null) return false; if (career.Boss == sim) return true; if (career.Coworkers != null) { if (career.Coworkers.Contains(sim)) return true; } return false; }
private PlayerSpawnRequest(Occupation requestedOccupation, JoinedViewer joinedViewer, CharacterSettings characterSettings) { RequestedOccupation = requestedOccupation; JoinedViewer = joinedViewer; CharacterSettings = characterSettings; }
internal bool AddIfEquals(int ageCat, Occupation occ, TTSEmploymentStatus empStat, bool dlic, bool female, float expFac) { if ( this.AgeCat == ageCat & this.Female == female & this.Occupation == occ & this.EmploymentStatus == empStat & this.DriversLicense == dlic ) { lock ( this ) { this.ExpansionFactor += expFac; } return true; } return false; }
private void SaveWorkerCategoryData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[][] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerCategoryDirectory))) { writer.WriteLine("Zone,WorkerCategory,Persons"); for(int i = 0; i < workers.Length; i++) { var factor = 1.0f / workers[i].Sum(); if(float.IsNaN(factor)) { continue; } for(int cat = 0; cat < workers[i].Length; cat++) { workers[i][cat] *= factor; } for(int cat = 0; cat < workers[i].Length; cat++) { if(workers[i][cat] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.Write(cat + 1); writer.Write(','); writer.WriteLine(workers[i][cat]); } } } } }
public bool OccupyBed(Bed bed, Occupation occupation) => bedService.OccupyBed(bed, occupation);
public async Task Option_try(string name, string middleName, string lastName, Occupation occupation, int age) { //Arrange's var repo = new PersonRepository(); //Act var option = repo.GetPerson(Guid.NewGuid()) .OnTry(x => x.ChangingName(name)) .OnTry(x => x.ChangingMiddleName(middleName)) .OnTry(x => x.ChangingLastName(lastName)) .OnTry(x => x.ChangingOccupation(occupation)) .OnTry(x => x.ChangingAge(age)) .OnTry(x => x.ChangingAge(age)) .OnValidation(x => x.Validation()) //.Catch(x => x.Error) .Finally(); //Assert's option.IsNone.Should().BeFalse(); option.IsSome.Should().BeTrue(); option.Message.Should().BeNull(); option.Value.Should().NotBeNull(); option.Value.Name.Should().Be(name); option.Value.MiddleName.Should().Be(middleName); option.Value.LastName.Should().Be(lastName); option.Value.Occupation.Should().Be(occupation); option.Value.Age.Should().Be(age); }
public CareerItem(Occupation career, CareerLocation location) { mCareer = career; mLocation = location; }
protected static bool CarpoolEnabled(Occupation job) { return(job.mPickUpCarpool != null); }
public Adult(Occupation occupation){ this.occupation = occupation; }
protected override OptionResult RunAll(List <IMiniSimDescription> sims) { Dictionary <OccupationNames, Item> lookup = new Dictionary <OccupationNames, Item>(); foreach (IMiniSimDescription miniSim in sims) { SimDescription member = miniSim as SimDescription; if (member == null) { continue; } if (member.Occupation == null) { continue; } Item item; if (!lookup.TryGetValue(member.Occupation.Guid, out item)) { item = new Item(member.Occupation.Guid); lookup.Add(member.Occupation.Guid, item); } item.IncCount(); item.mSims.Add(new CareerElement(member.Occupation.CareerLevel, member, member.Occupation.Boss, StatusJobPerformance.GetPerformance(member))); } Item choice = new CommonSelection <Item>(Name, lookup.Values).SelectSingle(); if (choice == null) { return(OptionResult.Failure); } List <CareerElement> list = choice.mSims; list.Sort(new CareerElement.CompareByLevel()); string msg = null; foreach (CareerElement element in list) { if (msg != null) { msg += Common.NewLine; } msg += Common.Localize("JobsByCareer:Employee", element.mSim.IsFemale, new object[] { element.mLevel, element.mSim, element.mPerf }); if (element.mBoss != null) { msg += Common.NewLine + Common.Localize("JobsByCareer:Boss", element.mBoss.IsFemale, new object[] { element.mBoss }); } } string careerName = null; Occupation career = CareerManager.GetStaticOccupation(choice.Value); if (career != null) { careerName = career.CareerName; } Sims3.UI.SimpleMessageDialog.Show(careerName, msg); return(OptionResult.SuccessRetain); }
public override void Show(params object[] args) { MyDebug.Log("SUB CATEGORY" + Busca.subcategory); if (Busca.category == 0 && Busca.subcategory == -1) { txtNomeCategoria.text = "Busca"; } else if (Busca.category != 0 && Busca.subcategory <= 0) { txtNomeCategoria.text = FreeHelp.Instance.GetCategoryByID(Busca.category).name; } else { txtNomeCategoria.text = (Busca.subcategory == 0) ? "Histórico" : FreeHelp.Instance.GetSubcategoryByID(Busca.subcategory).name; } jsonData = (string)args[0]; usedJson = jsonData; busca.Hide(); JSONNode json = JSON.ParseFromWeb(jsonData); JSONNode data = json["data"]; originalButton.SetActive(false); originalTextSeparator.SetActive(false); foreach (GameObject go in generatedButtons) { Destroy(go); } goNotFound.SetActive(data.Count == 0); empresas.Clear(); List <ServiceData> servicesData = new List <ServiceData>(); for (int i = 0; i < data.Count; i++) { ServiceData sd = new ServiceData(); sd.data = data[i]; if (sd.data["id"].Value != "") { int id = sd.data["id"].AsInt; sd.id = id; //Debug.Log(sd.data["name"].Value + ", " + sd.data["id"].AsInt); if (empresas.Contains(id) == false) { empresas.Add(id); servicesData.Add(sd); } } } List <List <ServiceData> > serviceByOccupation = new List <List <ServiceData> >(); for (int i = 0; i < 512; i++) { serviceByOccupation.Add(new List <ServiceData>()); } Debug.Log("SUB CATEGORIA " + Busca.subcategory); for (int i = 0; i < servicesData.Count; i++) { ServiceData sd = servicesData[i]; List <int> o = new List <int>(); if (Busca.subcategory > 0) { for (int j = 1; j <= 3; j++) { if (sd.data["subcategory" + j].AsInt == Busca.subcategory) { o.Add(sd.data["occupation" + j].AsInt); } } } else { for (int j = 1; j <= 3; j++) { o.Add(sd.data["occupation" + j].AsInt); } } for (int j = 0; j < o.Count; j++) { if (o[j] > 0) { if (serviceByOccupation[o[j]].Contains(sd) == false) { serviceByOccupation[o[j]].Add(sd); sd.listed = true; } } } } int addCount = 0; float _i = 0; var SEPARATE_BY_OCCUPATION = false; if (SEPARATE_BY_OCCUPATION == true) { for (int o = 0; o < serviceByOccupation.Count; o++) { if (serviceByOccupation[o].Count > 0) { Debug.Log(o); Occupation occupation = FreeHelp.Instance.GetOccupationByID(o); if (occupation != null) { AddTitle(occupation.name, _i); _i += 0.3f; } for (int i = 0; i < serviceByOccupation[o].Count; i++) { AddService(serviceByOccupation[o][i], _i); servicesData.Remove(serviceByOccupation[o][i]); _i += 1.0f; addCount++; } } } } // OUTROS if (servicesData.Count > 0) { if (addCount > 0) { AddTitle("Outros", _i); _i += 0.3f; } for (var i = 0; i < servicesData.Count; i++) { AddService(servicesData[i], _i); _i += 1.0f; } } base.Show(args); }
internal static void InitializeDataBase() { using (var scope = ApplicationContext.Container.BeginLifetimeScope("ExecutionPipeline")) { using (var context = scope.Resolve <DbContext>()) { //context.Database.EnsureDeleted(); //if ((context.GetService<IDatabaseCreator>() as RelationalDatabaseCreator).Exists()) // return; context.Database.EnsureDeleted(); context.Database.EnsureCreated(); //context.Database.Migrate(); var organization = new EntityOrganization() { Name = "Default", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; var adminRole = new AuthorizationRole() { Id = 1, Name = "Administrator", EntityOrganization = organization }; var agentRole = new AuthorizationRole() { Id = 2, Name = "Agent", EntityOrganization = organization }; var advisoryRole = new AuthorizationRole() { Id = 3, Name = "Advisor", EntityOrganization = organization }; var workflowRole = new AuthorizationRole() { Id = 4, Name = "Workflow", EntityOrganization = organization }; var applicationUser = new ApplicationUser() { Name = "Default", Email = "*****@*****.**", Password = "******", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; var workflowUser = new ApplicationUser() { Name = "Workflow", Email = "*****@*****.**", Password = "******", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; var schedulerFlowUser = new ApplicationUser() { Name = "Scheduler", Email = "*****@*****.**", Password = "******", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; var currentAdviser = new CurrentAdvisor() { Id = 1, Description = "Advisor A", EntityOrganization = organization }; var gender = new Gender() { Id = 1, Description = "Male", EntityOrganization = organization }; var occupation = new Occupation() { Id = 1, Description = "Unemployed", EntityOrganization = organization }; var addressType = new AddressType() { Id = 1, Description = "Complex", EntityOrganization = organization }; var phoneCallActivityType = new LeadScheduledActivityType() { Id = 1, Description = "Phone Call", EntityOrganization = organization }; var meetingActivityType = new LeadScheduledActivityType() { Id = 2, Description = "Meeting", EntityOrganization = organization }; var authorizationGroupA = new AuthorizationGroup() { Id = 1, Name = "Group A", EntityOrganization = organization }; var authorizationGroupB = new AuthorizationGroup() { Id = 2, Name = "Group B", EntityOrganization = organization }; var portfolioTransactionTypeOpen = new PortfolioTransactionType() { Id = 1, Description = "Open", }; var portfolioTransactionTypeClose = new PortfolioTransactionType() { Id = 2, Description = "Close", }; var portfolioShareA = new PortfolioShare() { Description = "ABC short", Code = "ABC" }; var portfolioShareB = new PortfolioShare() { Description = "XYZ short", Code = "XXZ" }; context.Add(portfolioTransactionTypeClose); context.Add(portfolioTransactionTypeOpen); var portfolios = new List <Portfolio>() { new Portfolio() { OpenDate = DateTime.Now, Name = "Test A" }, new Portfolio() { OpenDate = DateTime.Now, Name = "Test B" }, new Portfolio() { OpenDate = DateTime.Now, Name = "Test C" }, new Portfolio() { OpenDate = DateTime.Now, Name = "Test D" }, }; foreach (var portfolio in portfolios) { var summaryDate = DateTime.Now; for (int i = 0; i < 10; i++) { var summary = new PortfolioTransactionsSummary() { CloseAmount = (decimal) new Random(i).NextDouble() * ((decimal) new Random(i).NextDouble() * 10), OpenAmount = (decimal) new Random(i).NextDouble() * ((decimal) new Random(i).NextDouble() * 10), CloseDate = summaryDate, OpenDate = summaryDate.AddDays(-30), Portfolio = portfolio }; context.Add(summary); summaryDate = summaryDate.AddDays(-30); } var transactionDate = DateTime.Now; for (int i = 0; i < 10; i++) { var transaction = new PortfolioTransaction() { Total = (decimal) new Random(i).NextDouble() * 10, Price = (decimal) new Random(i).NextDouble() * ((decimal) new Random(i).NextDouble() * 10), Quantity = Math.Abs(new Random(i).Next()), Date = transactionDate, Portfolio = portfolio, PortfolioShare = portfolioShareA, PortfolioTransactionType = portfolioTransactionTypeClose }; context.Add(transaction); transactionDate = transactionDate.AddDays(-1); } context.Add(portfolio); } applicationUser.AddEntityOrganization(organization); applicationUser.ActiveEntityOrganizationId = 1; applicationUser.AddAuthorizationGroup(authorizationGroupA); applicationUser.AuthorizationRole = adminRole; context.Add(organization); context.Add(adminRole); context.Add(advisoryRole); context.Add(agentRole); context.Add(workflowRole); context.Add(applicationUser); context.Add(workflowUser); context.Add(schedulerFlowUser); context.Add(currentAdviser); context.Add(gender); context.Add(occupation); context.Add(addressType); context.Add(phoneCallActivityType); context.Add(meetingActivityType); context.Add(authorizationGroupA); //context.Add(authorizationGroupB); for (int i = 0; i < 1000; i++) { var user = new ApplicationUser() { Name = "Default", Email = $"testB@test{i}.com", Password = "******", CreatedDate = DateTime.Now, ModifiedDate = DateTime.Now }; user.AddEntityOrganization(organization); user.ActiveEntityOrganizationId = 1; user.AddAuthorizationGroup(authorizationGroupA); user.AuthorizationRole = adminRole; context.Add(user); } context.Add(new Company() { Name = "database 1", Address = "Address 1", LastName = "Last Name 1" }); context.Add(new Company() { Name = "database 2", Address = "Address 2", LastName = "Last Name 2" }); context.Add(new Company() { Name = "database 3", Address = "Address 3", LastName = "Last Name 3" }); context.Add(new Company() { Name = "database 4", Address = "Address 4", LastName = "Last Name 4" }); context.Add(new Lead() { AgentId = 1 }); context.SaveChanges(); } } }
private string BuildFileName(Occupation occ, TTSEmploymentStatus empStat, FileLocation fileLocation) { var dirPath = fileLocation.GetFilePath(); var info = new DirectoryInfo(dirPath); if(!info.Exists) { info.Create(); } StringBuilder buildFileName = new StringBuilder(); switch(occ) { case Occupation.Professional: buildFileName.Append("P"); break; case Occupation.Office: buildFileName.Append("G"); break; case Occupation.Retail: buildFileName.Append("S"); break; case Occupation.Manufacturing: buildFileName.Append("M"); break; } switch(empStat) { case TTSEmploymentStatus.FullTime: buildFileName.Append("F.csv"); break; case TTSEmploymentStatus.PartTime: buildFileName.Append("P.csv"); break; } return Path.Combine(dirPath, buildFileName.ToString()); }
public static string OccupationId(Occupation x) { return ((int)x).ToString(); }
private void SaveWorkerData(IZone[] zones, Occupation occupation, TTSEmploymentStatus empStat, float[] workers) { using (StreamWriter writer = new StreamWriter(BuildFileName(occupation, empStat, WorkerForceDirectory))) { writer.WriteLine("Zone,Persons"); for(int i = 0; i < workers.Length; i++) { if(workers[i] > 0) { writer.Write(zones[i].ZoneNumber); writer.Write(','); writer.WriteLine(workers[i]); } } } }
public GridCell(int row, int column) { Coordinate = new Coordinate(row, column); Status = Occupation.Empty; }
public UserSettings setOccupation(Occupation occupation) { switch(occupation) { case Occupation.OTHER: { #if UNITY_ANDROID && !UNITY_EDITOR || UNITY_IPHONE && !UNITY_EDITOR getInstance().setOccupation(1); #endif return this; } case Occupation.WORK: { #if UNITY_ANDROID && !UNITY_EDITOR || UNITY_IPHONE && !UNITY_EDITOR getInstance().setOccupation(2); #endif return this; } case Occupation.SCHOOL: { #if UNITY_ANDROID && !UNITY_EDITOR || UNITY_IPHONE && !UNITY_EDITOR getInstance().setOccupation(3); #endif return this; } case Occupation.UNIVERSITY: { #if UNITY_ANDROID && !UNITY_EDITOR || UNITY_IPHONE && !UNITY_EDITOR getInstance().setOccupation(4); #endif return this;; } } return null; }
public void PrintAllPeopleByOccupation(IList<Person> people, Occupation occupation) { //Implement a method which will print the first and last name of all people with a particular occupation to the console. //Bonus #1: Use Linq! //Bonus #2: Reimagine this method as an extension method on an IList of people. }
public ActionResult Edit(Occupation occupation) { db.Entry(occupation).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); }
private IReadOnlyCollection <DataSetValuePair> UpdateDatasetSource() { var _sources = new List <DataSetValuePair>(); var persons = ViewModelLocatorStatic.Locator.PurokModule.EveryPerson; var _purokPersons = new ObservableCollection <AllPurokPersons>(); foreach (var person in persons) { _purokPersons.Add(new AllPurokPersons { PurokName = person.Purok.Model.PurokName, Name = person.Model.FirstName + " " + person.Model.LastName, Age = Convert.ToInt32(person.Model.Age), IsVoter = person.Model.IsVoter, HasCert = person.Model.HasBirthCert, Occupation = person.Model.Occupation, Gender = person.Model.Gender, Attainment = person.Model.Attainment, DateOfBirth = person.Model.Birthdate?.ToString("MM/dd/yy"), DateOfDeath = person.Model.DateOfDeath?.ToString("MM/dd/yy"), IsDead = person.Model.IsDead, Religion = person.Model.Religion, Tribe = person.Model.Tribe }); } if (!string.IsNullOrWhiteSpace(Occupation) || !string.IsNullOrEmpty(Occupation)) { try { var personCollection = new ObservableCollection <AllPurokPersons>(); foreach (var person in _purokPersons) { if (!string.IsNullOrWhiteSpace(person.Occupation) || !string.IsNullOrEmpty(person.Occupation)) { if (person.Occupation.ToLowerInvariant().Contains(Occupation.ToLowerInvariant())) { personCollection.Add(person); } } } _purokPersons = new ObservableCollection <AllPurokPersons>(personCollection); } catch (Exception e) { } } if (StartAge != null && EndAge != null) { var filteredpersons = _purokPersons.Where(f => f.Age >= StartAge && f.Age <= EndAge); _purokPersons = new ObservableCollection <AllPurokPersons>(filteredpersons); } if (SelectedGender != null) { if (SelectedGender == "All") { var filteredpersons = _purokPersons; _purokPersons = new ObservableCollection <AllPurokPersons>(filteredpersons); } else { var filteredpersons = _purokPersons.Where(f => f.Gender == SelectedGender); _purokPersons = new ObservableCollection <AllPurokPersons>(filteredpersons); } } if (IsVoter == true) { var filteredpersons = _purokPersons.Where(f => f.IsVoter == "Yes"); _purokPersons = new ObservableCollection <AllPurokPersons>(filteredpersons); } if (HasCert == true) { var filteredpersons = _purokPersons.Where(f => f.HasCert == "Yes"); _purokPersons = new ObservableCollection <AllPurokPersons>(filteredpersons); } _sources.Add(new DataSetValuePair("AllPurokPersons", _purokPersons)); return(_sources); }