/// <summary> /// Populate /// </summary> /// <param name="id"></param> /// <param name="languageID"></param> public void Populate(Guid languageID) { try { //Populate Countries, Regions, Sectors this.Country_Languages = CountryService.GetCountries(languageID); this.Region_Languages = RegionService.GetRegions(languageID); // this.Sector_Languages = SectorService.GetSectors(languageID); // this.Sector_Languages = null; //Populate Variables this.Variable_Languages = VariableService.GetVariables(languageID); this.LanguageID = languageID; //Populate Record Variables PopulateRecordVariables(); } catch (Exception ex) { ErrorLog.WriteLog("ManageRecordModel", "Populate", ex, string.Empty); } }
/// <summary> /// Populate /// </summary> /// <param name="id"></param> /// <returns></returns> public bool Populate(Guid id, string urlPath) { bool isExists = false; var languageID = TSMContext.CurrentSiteLanguageID; this.ThematicFocus = new List <string>(); this.DesignProcess = new List <string>(); try { this.RecordLanguage = RecordService.GetRecordLanguage(id, languageID); if (this.RecordLanguage != null) { isExists = true; this.Name = RecordLanguage.Name; this.ID = id.ToString(); //Document Type var documentType = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.DocumentTypeVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (documentType != null) { this.DocumentType = documentType.Value; } //Description var description = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.DescriptionVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (description != null) { this.Description = description.Value; } this.Region = GetRegionName(RecordLanguage, languageID); this.Countries = GetCountryNames(RecordLanguage, languageID); // Year var year = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.YearVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (year != null) { this.Year = year.Value; } //last updated var lastUpdated = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.LastUpdatedVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (lastUpdated != null) { this.LastUpdated = GetLastUpdatedValue(lastUpdated.Value); } //Implementation Period var startYear = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.StartYearVariableID) && v.LanguageID == languageID).FirstOrDefault(); var endYear = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.EndYearVariableID) && v.LanguageID == languageID).FirstOrDefault(); if (startYear != null) { this.ImplementationPeriod = startYear.Value; } if (endYear != null) { this.ImplementationPeriod += "/" + endYear.Value; } var variableLanguages = VariableService.GetVariables(languageID); //Thematic focus var thematicVariables = variableLanguages.Where(vl => vl.Variable.VariableCategory == VariableCategory.ThematicFocus && CompareVariableValue(RecordLanguage.Record.Variables, vl, "true")).ToList(); foreach (var variableLanguage in thematicVariables) { this.ThematicFocus.Add(variableLanguage.DisplayName); } this.ThematicFocus = this.ThematicFocus.OrderBy(tf => tf).ToList(); //design process focus var designProcessVariables = variableLanguages.Where(vl => vl.Variable.VariableCategory == VariableCategory.DesignProcess && CompareVariableValue(RecordLanguage.Record.Variables, vl, "true")).ToList(); foreach (var variableLanguage in designProcessVariables) { this.DesignProcess.Add(variableLanguage.DisplayName); } this.DesignProcess = this.DesignProcess.OrderBy(dp => dp).ToList(); //Populate Sectors var sectorLanguages = PrioritySectorService.GetSectors(languageID); var tsmSectors = SectorService.GetTSMSectors(languageID); List <Guid> sectorIds = this.RecordLanguage.Record.Sectors.Select(s => s.ID).ToList(); this.ServiceSectors = PopulateSectors(sectorIds, sectorLanguages, tsmSectors, SectorType.Service); this.ProductSectors = PopulateSectors(sectorIds, sectorLanguages, tsmSectors, SectorType.Product); //Populate Files this.Files = new List <Document>(); if (RecordLanguage.Record.Documents != null) { this.Files = RecordLanguage.Record.Documents; } //Get Public var isPub = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.isDownload) && v.LanguageID == languageID).FirstOrDefault(); if (isPub != null) { if (isPub.Value == "true") { this.isPublic = "ITCdownload"; } else { this.isPublic = "Regulardownload"; } } else { this.isPublic = "Regulardownload"; } //Link Record var linkRecord = RecordLanguage.Record.Variables.Where(v => v.VariableID == AppSettingsUtility.GetGuid(AppSettingsKeys.RecordLink) && v.LanguageID == languageID).FirstOrDefault(); if (linkRecord != null) { this.recordLink = linkRecord.Value; } this.ZipFilePath = ""; this.LoginStat = ""; this.urlPathForDoc = urlPath.ToString(); } } catch (Exception ex) { ErrorLog.WriteLog("DocumentDetailModel", "Populate", ex, ""); } return(isExists); }