internal void Merge(MarketDescriptionDTO dto, CultureInfo culture) { Contract.Requires(dto != null); Contract.Requires(culture != null); lock (_lock) { _names[culture] = dto.Name; if (!string.IsNullOrEmpty(dto.Description)) { _descriptions[culture] = dto.Description; } Variant = dto.Variant; if (dto.Outcomes != null) { foreach (var outcomeDto in dto.Outcomes) { var existingOutcome = Outcomes?.FirstOrDefault(o => o.Id == outcomeDto.Id); if (existingOutcome != null) { existingOutcome.Merge(outcomeDto, culture); } else { ExecutionLog.Warn( $"Could not merge outcome[Id={outcomeDto.Id}] for lang={culture.TwoLetterISOLanguageName} on marketDescription[Id={Id}] because the specified outcome does not exist on stored market description."); ComparePrint(dto, culture); } } } if (dto.Mappings != null) { foreach (var mappingDto in dto.Mappings) { var existingMapping = Mappings?.FirstOrDefault(m => MarketMappingsMatch(m, mappingDto)); if (existingMapping != null) { existingMapping.Merge(mappingDto, culture); } else { ExecutionLog.Warn( $"Could not merge mapping[MarketId={mappingDto.MarketTypeId}:{mappingDto.MarketSubTypeId}] for lang={culture.TwoLetterISOLanguageName} on marketDescription[Id={dto.Id}]because the specified mapping does not exist on stored market description."); ComparePrint(dto, culture); } } } OutcomeType = dto.OutcomeType; Groups = dto.Groups == null ? null : new ReadOnlyCollection <string>(dto.Groups.ToList()); FetchedLanguages.Add(culture); LastDataReceived = DateTime.Now; } }
private void LoadTest() { if (null != TestResult) { Id = TestResult.Id; Date = TestResult.Date; SelectedMode = Modes.FirstOrDefault(x => x.ItemId == TestResult.Mode); SelectedOutcome = Outcomes.FirstOrDefault(x => x.ItemId == TestResult.Outcome); } }
public ProgramViewModel(ICourseInfoRepository courseRepository) { this.courseRepository = courseRepository ?? throw new ArgumentNullException(nameof(courseRepository)); refreshCourses(); SelectedOutcome = Outcomes.FirstOrDefault(); FilterText = string.Empty; MessengerInstance.Register <RefreshDatabaseMessage>(this, (m) => refreshCourses()); SaveButtonContent = defaultSaveButtonContent; CanSave = true; IsDirty = false; }
private void LoadTest() { if (null != TestResult) { Id = TestResult.Id; Date = TestResult.Date; SelectedMode = Modes.FirstOrDefault(x => x.ItemId == TestResult.Mode); SelectedOutcome = Outcomes.FirstOrDefault(x => x.ItemId == TestResult.Outcome); SelectedReasonNotContacted = ReasonsNotContacted.FirstOrDefault(x => x.ItemId == TestResult.ReasonNotContacted); ReasonNotContactedOther = TestResult.ReasonNotContactedOther; } }
public void Merge(MarketDescriptionDTO dto, CultureInfo culture) { Guard.Argument(dto, nameof(dto)).NotNull(); Guard.Argument(culture, nameof(culture)).NotNull(); _names[culture] = dto.Name; if (!string.IsNullOrEmpty(dto.Description)) { _descriptions[culture] = dto.Description; } Variant = dto.Variant; if (dto.Outcomes != null) { foreach (var outcomeDto in dto.Outcomes) { var existingOutcome = Outcomes?.FirstOrDefault(o => o.Id == outcomeDto.Id); if (existingOutcome != null) { existingOutcome.Merge(outcomeDto, culture); } else { Log.Warn($"Could not merge outcome[Id={outcomeDto.Id}] on marketDescription[Id={dto.Id}] because the specified outcome does not exist on stored market description"); } } } if (dto.Mappings != null) { foreach (var mappingDto in dto.Mappings) { var existingMapping = Mappings?.FirstOrDefault(m => m.MarketTypeId == mappingDto.MarketTypeId && m.MarketSubTypeId == mappingDto.MarketSubTypeId); if (existingMapping != null) { existingMapping.Merge(mappingDto); } else { Log.Warn($"Could not merge mapping[MarketId={mappingDto.MarketTypeId}:{mappingDto.MarketSubTypeId}] on marketDescription[Id={dto.Id}] because the specified mapping" + " does not exist on stored market description"); } } } _supportedLanguages.Add(culture); }
internal void Merge(VariantDescriptionDTO dto, CultureInfo culture) { Contract.Requires(dto != null); Contract.Requires(culture != null); if (dto.Outcomes != null) { foreach (var outcomeDto in dto.Outcomes) { var existingOutcome = Outcomes?.FirstOrDefault(o => o.Id == outcomeDto.Id); if (existingOutcome != null) { existingOutcome.Merge(outcomeDto, culture); } else { Log.Warn( $"Could not merge outcome[Id={outcomeDto.Id}] on variantDescription[Id={dto.Id}] because the specified outcome does not exist on stored variant description"); } } } if (dto.Mappings != null) { foreach (var mappingDto in dto.Mappings) { var existingMapping = Mappings?.FirstOrDefault(m => m.MarketTypeId == mappingDto.MarketTypeId && m.MarketSubTypeId == mappingDto.MarketSubTypeId); if (existingMapping != null) { existingMapping.Merge(mappingDto, culture); } else { Log.Warn( $"Could not merge mapping[MarketId={mappingDto.MarketTypeId}:{mappingDto.MarketSubTypeId}] on variantDescription[Id={dto.Id}] because the specified mapping does not exist on stored variant description"); } } } FetchedLanguages.Add(culture); LastDataReceived = DateTime.Now; }