Exemple #1
0
        /// <summary>
        /// Converts DTO to distractor.
        /// </summary>
        /// <param name="value">The distractor.</param>
        /// <param name="getImageFunc">Function that retrieves image content as base64 string.</param>
        /// <param name="getImageNameFunc">Function that retrieves image name.</param>
        /// <returns>The distractor.</returns>
        public static EdugameDistractor Convert(Distractor value, Func <File, string> getImageFunc, Func <File, string> getImageNameFunc)
        {
            if (value == null)
            {
                return(null);
            }

            var result = new EdugameDistractor
            {
                Image          = getImageFunc(value.Image),
                ImageName      = getImageNameFunc(value.Image),
                IsCorrect      = value.IsCorrect ?? false,
                Order          = value.DistractorOrder,
                Title          = value.DistractorName,
                DistractorType = value.DistractorType ?? 1
            };

            return(result);
        }
Exemple #2
0
        /// <summary>
        /// Converts distractor to DTO.
        /// </summary>
        /// <param name="value">The distractor.</param>
        /// <param name="question">Question DTO.</param>
        /// <returns>Distractor DTO.</returns>
        public static Distractor Convert(EdugameDistractor value, Question question)
        {
            if (value == null || question == null)
            {
                return(null);
            }

            var result = new Distractor
            {
                IsCorrect       = value.IsCorrect,
                DistractorOrder = value.Order,
                DistractorName  = value.Title,
                Question        = question,
                DateCreated     = DateTime.Now,
                DateModified    = DateTime.Now,
                DistractorType  = value.DistractorType == 0 ? 1 : value.DistractorType,
                IsActive        = true,
                CreatedBy       = question.CreatedBy,
                ModifiedBy      = question.ModifiedBy
            };

            return(result);
        }