Example #1
0
 private static ResultsColumnDto BuildResultsColumn(ResultsColumn model)
 {
     return(new ResultsColumnDto
     {
         Title = model.Title,
         IsFinal = model.IsFinal,
         Components = model.Components.Select(BuildResultsComponent).ToList()
     });
 }
Example #2
0
        private ResultsList VerifyResultsList(ResultsListDto resultsListDto, HashSet <string> resultsListsIds, HashSet <string> disciplineIds)
        {
            if (string.IsNullOrEmpty(resultsListDto.ResultsListId))
            {
                throw new ArgumentNullException("Missing ResultsList.ResultsListId");
            }
            if (string.IsNullOrEmpty(resultsListDto.Title))
            {
                throw new ArgumentNullException("Missing ResultsList.Title");
            }
            if (!resultsListsIds.Add(resultsListDto.ResultsListId))
            {
                throw new ArgumentOutOfRangeException("Duplicate ResultsList.ResultsListId " + resultsListDto.ResultsListId);
            }
            if (resultsListDto.Columns == null || resultsListDto.Columns.Count == 0)
            {
                throw new ArgumentNullException("Missing ResultsList.Columns");
            }

            ResultsList resultsList = new ResultsList
            {
                Title         = resultsListDto.Title,
                ResultsListId = resultsListDto.ResultsListId,
                Columns       = new List <ResultsColumn>()
            };

            foreach (var columnDto in resultsListDto.Columns)
            {
                if (string.IsNullOrEmpty(columnDto.Title))
                {
                    throw new ArgumentNullException("Missing ResultsList.Column.Title");
                }
                if (columnDto.Components == null || columnDto.Components.Count == 0)
                {
                    throw new ArgumentNullException("Missing ResultsList.Column.Components");
                }

                var column = new ResultsColumn
                {
                    Title      = columnDto.Title,
                    IsFinal    = columnDto.IsFinal,
                    Components = new List <ResultsComponent>()
                };

                foreach (var componentDto in columnDto.Components)
                {
                    if (string.IsNullOrEmpty(componentDto.DisciplineId))
                    {
                        throw new ArgumentNullException("Missing ResultsList.Column.Component.DisciplineId");
                    }
                    if (!disciplineIds.Contains(componentDto.DisciplineId))
                    {
                        throw new ArgumentOutOfRangeException("Unknown ResultsList.Column.Component.DisciplineId " + componentDto.DisciplineId);
                    }

                    column.Components.Add(new ResultsComponent
                    {
                        DisciplineId          = componentDto.DisciplineId,
                        FinalPointsCoeficient = componentDto.FinalPointsCoeficient
                    });
                }

                resultsList.Columns.Add(column);
            }

            return(resultsList);
        }