/// <summary>
        /// Maps SurveyMetaData entity to SurveyInfoBO business object.
        /// </summary>
        /// <param name="entity">A SurveyMetaData entity to be transformed.</param>
        /// <returns>A SurveyInfoBO business object.</returns>
        internal static SurveyResponseBO Map(SurveyResponse entity, User User = null, int LastActiveUseerId = -1)
        {
            SurveyResponseBO SurveyResponseBO = new SurveyResponseBO();

            SurveyResponseBO.SurveyId         = entity.SurveyId.ToString();
            SurveyResponseBO.ResponseId       = entity.ResponseId.ToString();
            SurveyResponseBO.XML              = entity.ResponseXML;
            SurveyResponseBO.Status           = entity.StatusId;
            SurveyResponseBO.DateUpdated      = entity.DateUpdated;
            SurveyResponseBO.DateCompleted    = entity.DateCompleted;
            SurveyResponseBO.TemplateXMLSize  = (long)entity.ResponseXMLSize;
            SurveyResponseBO.DateCreated      = entity.DateCreated;
            SurveyResponseBO.IsDraftMode      = entity.IsDraftMode;
            SurveyResponseBO.IsLocked         = entity.IsLocked;
            SurveyResponseBO.LastActiveUserId = LastActiveUseerId;
            if (entity.SurveyMetaData != null)
            {
                SurveyResponseBO.ViewId = (int)entity.SurveyMetaData.ViewId;
            }
            if (entity.ParentRecordId != null)
            {
                SurveyResponseBO.ParentRecordId = entity.ParentRecordId.ToString();
            }
            if (entity.RelateParentId != null)
            {
                SurveyResponseBO.RelateParentId = entity.RelateParentId.ToString();
            }
            if (User != null)
            {
                SurveyResponseBO.UserEmail = User.EmailAddress;
            }

            return(SurveyResponseBO);
        }
Пример #2
0
        /// <summary>
        /// Maps SurveyInfoBO business object to SurveyMetaData entity.
        /// </summary>
        /// <param name="businessobject">A SurveyInfoBO business object.</param>
        /// <returns>A SurveyMetaData entity.</returns>
        internal static SurveyResponse ToEF(SurveyResponseBO pBO, int OrgId = -1)
        {
            SurveyResponse SurveyResponse = new SurveyResponse();
            Guid           RelateParentId = Guid.Empty;

            if (!string.IsNullOrEmpty(pBO.RelateParentId))
            {
                RelateParentId = new Guid(pBO.RelateParentId);
            }
            Guid ParentRecordId = Guid.Empty;

            if (!string.IsNullOrEmpty(pBO.ParentRecordId))
            {
                ParentRecordId = new Guid(pBO.ParentRecordId);
            }
            SurveyResponse.SurveyId        = new Guid(pBO.SurveyId);
            SurveyResponse.ResponseId      = new Guid(pBO.ResponseId);
            SurveyResponse.ResponseXML     = pBO.XML;
            SurveyResponse.StatusId        = pBO.Status;
            SurveyResponse.ResponseXMLSize = pBO.TemplateXMLSize;
            SurveyResponse.DateUpdated     = pBO.DateUpdated;
            SurveyResponse.DateCompleted   = pBO.DateCompleted;
            SurveyResponse.DateCreated     = pBO.DateCreated;
            SurveyResponse.IsDraftMode     = pBO.IsDraftMode;
            SurveyResponse.RecordSourceId  = pBO.RecrodSourceId;
            if (!string.IsNullOrEmpty(pBO.RelateParentId) && RelateParentId != Guid.Empty)
            {
                SurveyResponse.RelateParentId = new Guid(pBO.RelateParentId);
            }
            if (!string.IsNullOrEmpty(pBO.ParentRecordId) && ParentRecordId != Guid.Empty)
            {
                SurveyResponse.ParentRecordId = new Guid(pBO.ParentRecordId);
            }
            if (OrgId != -1)
            {
                SurveyResponse.OrganizationId = OrgId;
            }
            return(SurveyResponse);
        }