Exemple #1
0
 /// <summary>
 /// Indicates whether the current object is equal to another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.</returns>
 public bool Equals(TedsAnswerDto <T> other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other._response, _response) && Equals(other._tedsNonResponse, _tedsNonResponse));
 }
        private TedsDischargeInterviewSubstanceUsage CreateSubstanceUsage(TedsAnswerDto <SubstanceProblemTypeDto> substanceProblemType, TedsAnswerDto <TedsLookupBaseDto> useFrequencyType)
        {
            TedsDischargeInterviewSubstanceUsage substanceUsage = null;

            var problem   = TedsAnswerMapper.MapToTedsAnswer <SubstanceProblemType, SubstanceProblemTypeDto> (substanceProblemType, _mappingHelper);
            var frequency = TedsAnswerMapper.MapToTedsAnswer <UseFrequencyType, TedsLookupBaseDto>(useFrequencyType, _mappingHelper);

            if (problem != null || frequency != null)
            {
                var problemAndFrequency = new SubstanceProblemAndFrequency(problem, frequency);
                substanceUsage = new TedsDischargeInterviewSubstanceUsage(problemAndFrequency);
            }

            return(substanceUsage);
        }
Exemple #3
0
 /// <summary>
 /// Compares the current object with another object of the same type.
 /// </summary>
 /// <param name="other">An object to compare with this object.</param>
 /// <returns>A 32-bit signed integer that indicates the relative order of the objects being compared. The return value has the following meanings:
 /// Value
 /// Meaning
 /// Less than zero
 /// This object is less than the <paramref name="other"/> parameter.
 /// Zero
 /// This object is equal to <paramref name="other"/>.
 /// Greater than zero
 /// This object is greater than <paramref name="other"/>.</returns>
 public int CompareTo(TedsAnswerDto <T> other)
 {
     if (other == null)
     {
         return(1);
     }
     if (HasValue() && !other.HasValue())
     {
         return(1);
     }
     if (!HasValue() && other.HasValue())
     {
         return(-1);
     }
     if (!HasValue() && !other.HasValue())
     {
         return(Comparer <LookupValueDto> .Default.Compare(TedsNonResponse, other.TedsNonResponse));
     }
     return(CompareTo(other.Response));
 }
Exemple #4
0
        /// <summary>
        /// Maps the type of to teds non response.
        /// </summary>
        /// <typeparam name="T">The type of the value.</typeparam>
        /// <param name="tedsAnswerDto">The teds non response type dto.</param>
        /// <param name="mappingHelper">The mapping helper.</param>
        /// <returns>A <see cref="TedsAnswer{T}"/></returns>
        public static TedsAnswer <T> MapToTedsAnswer <T> (
            TedsAnswerDto <T> tedsAnswerDto, IDtoToDomainMappingHelper mappingHelper)
        {
            TedsAnswer <T> result = null;

            if (tedsAnswerDto != null)
            {
                if (!typeof(T).IsNullable() || tedsAnswerDto.Response != null || tedsAnswerDto.TedsNonResponse != null)
                {
                    result = tedsAnswerDto.TedsNonResponse != null
                                 ? new TedsAnswer <T> (
                        mappingHelper.MapLookupField <TedsNonResponse> (tedsAnswerDto.TedsNonResponse))
                                 : new TedsAnswer <T> (tedsAnswerDto.Response);
                }
            }
            else
            {
                throw new InvalidOperationException("TedsAnswerDto Cannot be Null.");
            }

            return(result);
        }
Exemple #5
0
        /// <summary>
        /// Maps to teds answer.
        /// </summary>
        /// <typeparam name="TLookupBase">The type of the lookup base.</typeparam>
        /// <typeparam name="TLookupValueDto">The type of the lookup value dto.</typeparam>
        /// <param name="tedsAnswerDto">The teds answer dto.</param>
        /// <param name="mappingHelper">The mapping helper.</param>
        /// <returns>A <see cref="TedsAnswer{T}"/></returns>
        public static TedsAnswer <TLookupBase> MapToTedsAnswer <TLookupBase, TLookupValueDto> (
            TedsAnswerDto <TLookupValueDto> tedsAnswerDto, IDtoToDomainMappingHelper mappingHelper)
            where TLookupBase : LookupBase
            where TLookupValueDto : LookupValueDto
        {
            TedsAnswer <TLookupBase> result = null;

            if (tedsAnswerDto != null)
            {
                if (tedsAnswerDto.Response != null || tedsAnswerDto.TedsNonResponse != null)
                {
                    result = tedsAnswerDto.TedsNonResponse != null
                                 ? new TedsAnswer <TLookupBase>(
                        mappingHelper.MapLookupField <TedsNonResponse> (tedsAnswerDto.TedsNonResponse))
                                 : new TedsAnswer <TLookupBase>(mappingHelper.MapLookupField <TLookupBase>(tedsAnswerDto.Response));
                }
            }
            else
            {
                throw new InvalidOperationException("TedsAnswerDto Cannot be Null.");
            }

            return(result);
        }
Exemple #6
0
 /// <summary>
 /// Maps the type of TedsAnswerDto to TedsAnswer.
 /// </summary>
 /// <typeparam name="T">The type of the value.</typeparam>
 /// <param name="tedsAnswerDto">The teds non response type dto.</param>
 /// <param name="mappingHelper">The mapping helper.</param>
 /// <returns>A <see cref="TedsAnswer{T}"/></returns>
 public static TedsAnswer <T> MapToTedsAnswer <T>(
     TedsAnswerDto <LookupValueDto> tedsAnswerDto, IDtoToDomainMappingHelper mappingHelper) where T : LookupBase
 {
     return(MapToTedsAnswer <T, LookupValueDto>(tedsAnswerDto, mappingHelper));
 }