Esempio n. 1
0
        public static DTO.AnalyticValueDriver ToDto(this Display.AnalyticValueDriver displayEntity)
        {
            var modes = new List <DTO.AnalyticValueDriverMode>();

            foreach (Display.AnalyticValueDriverMode mode in displayEntity.Modes)
            {
                modes.Add(mode.ToDto());
            }

            var results = new List <DTO.AnalyticResultValueDriverGroup>();

            foreach (Display.AnalyticResult result in displayEntity.Results)
            {
                results.Add(result.ToDto());
            }

            var dto = new DTO.AnalyticValueDriver(
                displayEntity.Id,
                displayEntity.Key,
                displayEntity.IsSelected,
                displayEntity.Name,
                displayEntity.Title,
                displayEntity.Sort,
                results,
                modes);

            dto.RunResults = displayEntity.RunResults;

            return(dto);
        }
Esempio n. 2
0
        public static Display.AnalyticValueDriver ToDisplayEntity(this DTO.AnalyticValueDriver dto)
        {
            var displayEntity = new Display.AnalyticValueDriver();

            displayEntity.Key        = dto.Key;
            displayEntity.Id         = dto.Id;
            displayEntity.Name       = dto.Name;
            displayEntity.Title      = dto.Title;
            displayEntity.Sort       = dto.Sort;
            displayEntity.IsSelected = dto.IsSelected;
            displayEntity.RunResults = dto.RunResults;

            if (dto.Modes != null)
            {
                foreach (DTO.AnalyticValueDriverMode mode in dto.Modes)
                {
                    displayEntity.Modes.Add(mode.ToDisplayEntity());
                }
            }

            if (dto.Results != null)
            {
                foreach (DTO.AnalyticResultValueDriverGroup result in dto.Results)
                {
                    displayEntity.Results.Add(result.ToDisplayEntity());
                }
            }

            displayEntity.IsDirty = false;

            return(displayEntity);
        }
Esempio n. 3
0
        /// <summary>
        /// Ensures that the SelectedMode is set for the specified ValueDriver.
        /// This is to support expected behavior in bound views.
        /// </summary>
        public void EnsureModeIsSelected(AnalyticValueDriver driver)
        {
            if (driver.SelectedMode == null)
            {
                var selectedMode = driver.Modes.FirstOrDefault(mode => mode.IsSelected);
                if (selectedMode == null && driver.Modes.Count > 0)
                {
                    selectedMode = driver.Modes[0];
                }
                driver.SelectedMode = selectedMode;
            }

            if (driver.SelectedMode != null)
            {
                driver.SelectedMode.RecalculateEditableGroups();
            }
        }