protected override void MapEntityFields(StandardFinding <T> domainObject, StandardFindingEntity entityToMapTo) { entityToMapTo.StandardFindingId = (int)domainObject.Id; entityToMapTo.Label = domainObject.Label; entityToMapTo.Description = domainObject.Description; //entityToMapTo.MinValue = domainObject.MinValue; //entityToMapTo.MaxValue = domainObject.MaxValue; }
public StandardFindingEntity CreateStandardFinding <T>(StandardFinding <T> standardFinding) { if (standardFinding == null) { throw new ArgumentNullException("standardFinding", "Standard Finding must be provided."); } var standardFindingEntity = new StandardFindingEntity((int)standardFinding.Id) { Label = standardFinding.Label, Description = standardFinding.Description }; return(standardFindingEntity); }
protected override void MapDomainFields(StandardFindingEntity entity, StandardFinding <T> domainObjectToMapTo) { domainObjectToMapTo.Id = entity.StandardFindingId; domainObjectToMapTo.Label = entity.Label; domainObjectToMapTo.Description = entity.Description; if (typeof(T) == typeof(int?)) { int returnValue; if (entity.MinValue.HasValue) { returnValue = decimal.ToInt32(entity.MinValue.Value); domainObjectToMapTo.MinValue = (T)Convert.ChangeType(returnValue, typeof(int)); } else { domainObjectToMapTo.MinValue = default(T); } if (entity.MaxValue.HasValue) { returnValue = decimal.ToInt32(entity.MaxValue.Value); domainObjectToMapTo.MaxValue = (T)Convert.ChangeType(returnValue, typeof(int)); } else { domainObjectToMapTo.MaxValue = default(T); } } else if (typeof(T) == typeof(decimal?)) { domainObjectToMapTo.MinValue = entity.MinValue.HasValue ? (T)Convert.ChangeType(entity.MinValue, typeof(decimal)) : default(T); domainObjectToMapTo.MaxValue = entity.MaxValue.HasValue ? (T)Convert.ChangeType(entity.MaxValue, typeof(decimal)) : default(T); } }
public StandardFinding <T> CreateStandardFinding <T>(StandardFindingEntity standardFindingEntity) { if (standardFindingEntity == null) { throw new ArgumentNullException("standardFindingEntity", "Standard Finding Entity must be provided."); } var standardFinding = new StandardFinding <T>(standardFindingEntity.StandardFindingId) { Label = standardFindingEntity.Label, Description = standardFindingEntity.Description, ResultInterpretation = standardFindingEntity.ResultInterpretation, PathwayRecommendation = standardFindingEntity.PathwayRecommendation, LongDescription = standardFindingEntity.LongDescription, WorstCaseOrder = standardFindingEntity.WorstCaseOrder }; if (typeof(T) == typeof(int?) || typeof(T) == typeof(int)) // For Type Int { int returnValue; // Setting for Min Value if (standardFindingEntity.MinValue != null) { returnValue = decimal.ToInt32((decimal)standardFindingEntity.MinValue); standardFinding.MinValue = (T)Convert.ChangeType(returnValue, typeof(int)); } else { standardFinding.MinValue = default(T); } //Setting for Max Value if (standardFindingEntity.MaxValue != null) { returnValue = decimal.ToInt32((decimal)standardFindingEntity.MaxValue); standardFinding.MaxValue = (T)Convert.ChangeType(returnValue, typeof(int)); } else { standardFinding.MaxValue = default(T); } } else if (typeof(T) == typeof(decimal?) || typeof(T) == typeof(decimal)) // For Type Decimal { // Setting for min Value if (standardFindingEntity.MinValue != null) { standardFinding.MinValue = (T)Convert.ChangeType(standardFindingEntity.MinValue, typeof(decimal)); } else { standardFinding.MinValue = default(T); } // Setting for max Value if (standardFindingEntity.MaxValue != null) { standardFinding.MaxValue = (T)Convert.ChangeType(standardFindingEntity.MaxValue, typeof(decimal)); } else { standardFinding.MaxValue = default(T); } } return(standardFinding); }