/// <summary>
        /// Converts to domain.
        /// </summary>
        /// <returns>
        /// MissionDraft.
        /// </returns>
        internal new MissionDraft ConvertToDomain()
        {
            var draft = new MissionDraft
            {
                AddDate        = AddDate,
                AgeFrom        = AgeFrom,
                AgeTo          = AgeTo,
                Author         = Author,
                CorrectAnswers = CorrectAnswers,
                Description    = Description,
                Difficulty     = Difficulty,
                Id             = Id,
                Name           = Name,
                PhotoUrl       = PhotoUrl
            };

            if (PersonQualitiesWithScores != null)
            {
                draft.PersonQualities =
                    PersonQualitiesWithScores.Where(ptws => ptws.PersonQualityId != null)
                    .GroupBy(ptws => ptws.PersonQualityId)
                    .Select(grp => grp.First())
                    .Select(
                        ptws =>
                {
                    var personQualityWithScore = new PersonQualityIdWithScore
                    {
                        PersonQualityId = ptws.PersonQualityId,
                        Score           = ptws.Score
                    };
                    return(personQualityWithScore);
                }).ToList();
            }

            return(draft);
        }
Exemple #2
0
        /// <summary>
        ///     Converts to domain.
        /// </summary>
        /// <returns>Mission.</returns>
        internal Mission ConvertToDomain()
        {
            var mission = new Mission
            {
                // Common
                Id                     = Id,
                Name                   = Name,
                PhotoUrl               = PhotoUrl,
                Description            = Description,
                Difficulty             = Difficulty,
                AgeFrom                = AgeFrom,
                AgeTo                  = AgeTo,
                ExecutionType          = ExecutionType,
                DependsOn              = DependsOn,
                IsFinal                = IsFinal,
                MessageAfterCompletion = MessageAfterCompletion,
                MissionSetId           = MissionSetId,

                // Right answer type
                AnswersCount   = AnswersCount,
                ExactAnswer    = ExactAnswer,
                CorrectAnswers = CorrectAnswers,
                TriesFor1Star  = TriesFor1Star,
                TriesFor2Stars = TriesFor2Stars,
                TriesFor3Stars = TriesFor3Stars,

                // Text Creation
                MinCharsCount = MinCharsCount,

                // Photo Creation
                NumberOfPhotos = NumberOfPhotos,

                // GeoCoordinates + GeoPath
                AccuracyRadius   = AccuracyRadius,
                CommonPlaceAlias = CommonPlaceAlias,
                UserCoordinatesCalculationFunction = UserCoordinatesCalculationFunction,
                CalculationFunctionParameters      = CalculationFunctionParameters,
                SecondsFor1Star  = SecondsFor1Star,
                SecondsFor2Stars = SecondsFor2Stars,
                SecondsFor3Stars = SecondsFor3Stars,
                Hints            = Hints
            };

            if (PersonQualitiesWithScores != null)
            {
                var qualitiesWithScores =
                    PersonQualitiesWithScores.Where(ptws => ptws.PersonQualityId != null)
                    .GroupBy(ptws => ptws.PersonQualityId)
                    .Select(grp => grp.First())
                    .Select(
                        ptws =>
                {
                    var personQualityWithScore = new PersonQualityIdWithScore
                    {
                        PersonQualityId = ptws.PersonQualityId,
                        Score           = ptws.Score
                    };
                    return(personQualityWithScore);
                }).ToList();

                mission.PersonQualities = qualitiesWithScores.Any() ? qualitiesWithScores : null;
            }
            return(mission);
        }