/// <summary> /// Get International nomenclature list /// </summary> public List <TSMSector> GetINTlist(string sectorType) { List <TSMSector> lstTSMSector = new List <TSMSector>(); lstTSMSector = PrioritySectorService.GetINTlist(sectorType); this.ITCSectorList = lstTSMSector; return(lstTSMSector); }
public void Delete(Guid id) { Sector sector = PrioritySectorService.GetSector(id); sector.IsDeleted = true; sector.IsActive = false; sector.LastModifiedBy = TSMContext.CurrentUser.ID; sector.LastModifiedDate = DateTime.UtcNow; PrioritySectorService.Delete(sector); }
public Sector GetSectorFull(Guid id) { Sector sector = new Sector(); try { sector = PrioritySectorService.GetSector(id); sector.Sector_Languages = new List <Sector_Language>(); //sector = new List<Variable_Language>(); } catch (Exception ex) { ErrorLog.WriteLog("PrioritySectorModel", "GetSectorFull", ex, ""); } return(sector); }
/// <summary> /// Save /// </summary> /// <returns></returns> public Sector Save() { Sector sector = new Sector(); try { if (this.ID == Guid.Empty) { sector = new Sector(); sector.CreatedBy = TSM.Model.TSMContext.CurrentUser.ID; sector.CreatedDate = DateTime.UtcNow; } else { sector = this.GetSectorFull(this.ID); sector.LastModifiedBy = TSM.Model.TSMContext.CurrentUser.ID; sector.LastModifiedDate = DateTime.UtcNow; } sector.Type = this.Sectortype; try { sector.ITC_NomenclatureID = new Guid(this.ITCSector); sector.International_NomenclatureID = new Guid(this.INTSector); } catch { } sector.IsActive = true; sector.IsDeleted = false; sector.Sector_Languages.Add(new Sector_Language { ID = this.ID, LanguageID = TSM.Model.TSMContext.CurrentLanguageID, Name = this.PrioritySectorName, Label = this.PrioritySectorName }); PrioritySectorService.Save(sector); } catch (Exception ex) { ErrorLog.WriteLog("PrioritySectorModel", "Save", ex, ""); } return(sector); }
/// <summary> /// Get Sector Language /// </summary> public void GetSectorLanguage() { var sectorIds = this.SelectedSectors; this.Sector_Languages = PrioritySectorService.GetSectorLanguage(sectorIds); }
/// <summary> /// Populate Record /// </summary> /// <param name="id"></param> /// <param name="languageID"></param> public void PopulateRecord(Guid id, Guid languageID) { try { //Populate record if (id != Guid.Empty) { this.Record = RecordService.GetRecord(id); if (this.Record != null && this.Record.Record_Languages != null && this.Record.Record_Languages.Count > 0) { Record_Language recordLanguage = new Record_Language(); this.IsActive = this.Record.IsActive; this.IsPublic = this.Record.IsPublic; if (this.Record.Record_Languages.Any(rl => rl.LanguageID == languageID)) { recordLanguage = this.Record.Record_Languages.Where(rl => rl.LanguageID == languageID).FirstOrDefault(); } else // populate with default language id { var defaultLanguageID = new Guid(AppSettingsUtility.GetString(AppSettingsKeys.DefaultLanguageID)); recordLanguage = this.Record.Record_Languages.Where(rl => rl.LanguageID == defaultLanguageID).FirstOrDefault(); } //populate name if (recordLanguage != null) { this.Name = recordLanguage.Name; this.Record.Record_Languages = new List<Record_Language>(); this.Record.Record_Languages.Add(recordLanguage); } //Populate selected Countries if (this.Record.Countries != null && this.Record.Countries.Count > 0) { this.SelectedCountries = (from c in this.Record.Countries select c.ID).ToList(); } //Populate selected Regions if (this.Record.Regions != null && this.Record.Regions.Count > 0) { this.SelectedRegions = (from r in this.Record.Regions select r.ID).ToList(); } //Populate selected Sectors if (this.Record.Sectors != null && this.Record.Sectors.Count > 0) { this.SelectedSectors = (from s in this.Record.Sectors select s.ID).ToList(); } if (this.SelectedSectors != null && this.SelectedSectors.Count > 0) { this.Sector_Languages = PrioritySectorService.GetSectorLanguage(this.SelectedSectors); } //populate documents this.Documents = string.Empty; if (this.Record.Documents != null && this.Record.Documents.Count > 0) { foreach (var document in this.Record.Documents) { this.Documents += document.Path + "|"; } this.Documents = this.Documents.TrimEnd('|'); } } } } catch (Exception ex) { ErrorLog.WriteLog("ManageRecordModel", "PopulateRecord", 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); }
/// <summary> /// Get Sector Details /// </summary> /// <param name="id"></param> /// <returns></returns> public Sector GetSectorData(Guid id) { Sector sector = PrioritySectorService.GetSector(id); return(sector); }