public SmoothController( ISmoothFailureMessageRepository smoothFailureMessageRepository, ISmoothConfigurationRepository smoothConfigurationRepository, IMapper mapper) { _smoothFailureMessageRepository = smoothFailureMessageRepository; _smoothConfigurationRepository = smoothConfigurationRepository; _mapper = mapper; }
public SmoothConfigurationDomainModelHandler( ISmoothConfigurationRepository smoothConfigurationRepository, ISqlServerDbContext dbContext, IMapper mapper) { _smoothConfigurationRepository = smoothConfigurationRepository ?? throw new ArgumentNullException(nameof(smoothConfigurationRepository)); _dbContext = dbContext ?? throw new ArgumentNullException(nameof(dbContext)); _mapper = mapper; }
/// <summary> /// Validate Smooth configuration /// </summary> /// <param name="run"></param> /// <param name="smoothConfigurationRepository"></param> /// <returns></returns> private List <SystemMessage> ValidateSmoothConfiguration(Run run, ISmoothConfigurationRepository smoothConfigurationRepository) { List <SystemMessage> messages = new List <SystemMessage>(); if (run.Smooth) { // Try loading configuration SmoothConfiguration smoothConfiguration = null; try { smoothConfiguration = smoothConfigurationRepository.GetById(SmoothConfiguration.DefaultId); if (smoothConfiguration == null) // Not found { messages.Add(FormatSystemMessage(SystemMessage.SmoothConfigurationMissing)); } } catch (System.Exception exception) // Possible corruption caused by manual modification { messages.Add(FormatSystemMessage(SystemMessage.SmoothConfigurationInvalid, new Dictionary <string, string>() { { _placeholderInvalidData, string.Format("Error loading Smooth configuration: {0}", exception.Message) } })); } // Validate Smooth configuration if (smoothConfiguration != null) { SmoothConfigurationValidator smoothConfigurationValidator = new SmoothConfigurationValidator(); var validationResults = smoothConfigurationValidator.Validate(smoothConfiguration); validationResults.ForEach(validationResult => messages.Add(FormatSystemMessage(SystemMessage.SmoothConfigurationInvalid, new Dictionary <string, string>() { { _placeholderInvalidData, validationResult } }))); } } return(messages); }