public ManorDataModel GetAllManorDataModel() { ManorDataModel tempDataModel = new ManorDataModel(); List <IPeopleModel> tempPeopleModel = new List <IPeopleModel>(); List <VillageModel> tempVillageModels = new List <VillageModel>(); List <int> wealth = new List <int>(); for (int x = 1; x < _fiefService.ManorList.Count; x++) { tempDataModel.ManorPopulation += _fiefService.ManorList[x].ManorPopulation; tempDataModel.ManorAcres += _fiefService.ManorList[x].ManorAcres; tempDataModel.ManorPasture += _fiefService.ManorList[x].ManorPasture; tempDataModel.ManorArable += _fiefService.ManorList[x].ManorArable; tempDataModel.ManorWoodland += _fiefService.ManorList[x].ManorWoodland; tempDataModel.ManorFelling += _fiefService.ManorList[x].ManorFelling; tempDataModel.ManorUseless += _fiefService.ManorList[x].ManorUseless; wealth.Add(Convert.ToInt32(_fiefService.ManorList[x].ManorWealth)); } tempDataModel.ManorWealth = wealth.Min() == wealth.Max() ? $"{wealth.Min()}" : $"{wealth.Min()} - {wealth.Max()}"; for (int x = 1; x < _fiefService.ArmyList.Count; x++) { for (int y = 0; y < _fiefService.ArmyList[x].TemplarKnightsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].TemplarKnightsList[y]); } for (int y = 0; y < _fiefService.ArmyList[x].KnightsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].KnightsList[y]); } for (int y = 0; y < _fiefService.ArmyList[x].CavalryTemplarKnightsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].CavalryTemplarKnightsList[y]); } for (int y = 0; y < _fiefService.ArmyList[x].OfficerCaptainsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].OfficerCaptainsList[y]); } for (int y = 0; y < _fiefService.ArmyList[x].OfficerCorporalsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].OfficerCorporalsList[y]); } for (int y = 0; y < _fiefService.ArmyList[x].OfficerSergeantsList.Count; y++) { tempPeopleModel.Add(_fiefService.ArmyList[x].OfficerSergeantsList[y]); } for (int y = 0; y < _fiefService.ManorList[x].ResidentsList.Count; y++) { tempPeopleModel.Add(_fiefService.ManorList[x].ResidentsList[y]); } for (int y = 0; y < _fiefService.ManorList[x].VillagesCollection.Count; y++) { tempVillageModels.Add(_fiefService.ManorList[x].VillagesCollection[y]); } } tempDataModel.ResidentsCollection = new ObservableCollection <IPeopleModel>(tempPeopleModel); tempDataModel.VillagesCollection = new ObservableCollection <VillageModel>(tempVillageModels); return(tempDataModel); }
public void SetDataModel(IDataModelBase dataModel, int index) { if (dataModel != null) { if (dataModel.GetType() == typeof(InformationDataModel)) { InformationDataModel tempDataModel = (InformationDataModel)dataModel; _fiefService.InformationList[index] = (InformationDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(ArmyDataModel)) { ArmyDataModel tempDataModel = (ArmyDataModel)dataModel; _fiefService.ArmyList[index] = (ArmyDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(EmployeesDataModel)) { EmployeesDataModel tempDataModel = (EmployeesDataModel)dataModel; _fiefService.EmployeesList[index] = (EmployeesDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(ManorDataModel)) { ManorDataModel tempDataModel = (ManorDataModel)dataModel; _fiefService.ManorList[index] = (ManorDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(BoatbuildingDataModel)) { BoatbuildingDataModel tempDataModel = (BoatbuildingDataModel)dataModel; _fiefService.BoatbuildingList[index] = (BoatbuildingDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(ExpensesDataModel)) { ExpensesDataModel tempDataModel = (ExpensesDataModel)dataModel; _fiefService.ExpensesList[index] = (ExpensesDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(StewardsDataModel)) { StewardsDataModel tempDataModel = (StewardsDataModel)dataModel; for (int x = 0; x < _fiefService.StewardsList.Count; x++) { _fiefService.StewardsList[x] = (StewardsDataModel)tempDataModel.Clone(); } } else if (dataModel.GetType() == typeof(SubsidiaryDataModel)) { SubsidiaryDataModel tempDataModel = (SubsidiaryDataModel)dataModel; _fiefService.SubsidiaryList[index] = (SubsidiaryDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(IncomeDataModel)) { IncomeDataModel tempDataModel = (IncomeDataModel)dataModel; _fiefService.IncomeList[index] = (IncomeDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(BuildingsDataModel)) { BuildingsDataModel tempDataModel = (BuildingsDataModel)dataModel; _fiefService.BuildingsList[index] = (BuildingsDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(WeatherDataModel)) { WeatherDataModel tempDataModel = (WeatherDataModel)dataModel; _fiefService.WeatherList[index] = (WeatherDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(MinesDataModel)) { MinesDataModel tempDataModel = (MinesDataModel)dataModel; _fiefService.MinesList[index] = (MinesDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(PortDataModel)) { PortDataModel tempDataModel = (PortDataModel)dataModel; _fiefService.PortsList[index] = (PortDataModel)tempDataModel.Clone(); } else if (dataModel.GetType() == typeof(TradeDataModel)) { TradeDataModel tempDataModel = (TradeDataModel)dataModel; _fiefService.TradeList[index] = (TradeDataModel)tempDataModel.Clone(); } else { Console.WriteLine("ERROR!"); } } }