Ejemplo n.º 1
0
        /// <summary>
        /// Map the basic fields for the Agreement table to the Agreement model object
        /// </summary>
        /// <param name="record">The SqlDataReader with the executed query result</param>
        /// <param name="prefix">a prefix used to identify fields for the Agreement model  in the resultset if required</param>        
        /// <returns>An instance of Model.Business.Agreement</returns>
        internal static Agreement MapRecord(IDataRecord record, string prefix = "")
        {
            var resultAgreement = new Agreement
                {
                    Id = DbHelper.ConvertValue<int>(record[prefix + SelectParameters.Id]),
                    AgreementType = DbHelper.ConvertEnumValue<AgreementType>(record[prefix + SelectParameters.AgreementTypeCode]),
                    AgreementTypeName = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.AgreementTypeName]),
                    BusinessIdsNeedingAgreement = new List<long>(),
                    BusinessNames = string.Empty,
                    Name = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.Name]),
                    CountryId = DbHelper.ConvertValue<int?>(record[prefix + SelectParameters.CountryId]),
                    CountryName = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.CountryName]),
                    AgreementStatus = DbHelper.ConvertEnumValue<AgreementStatus>(record[prefix + SelectParameters.AgreementStatusCode]),
                    ContentType = DbHelper.ConvertEnumValue<ContentTypeEnum>(record[prefix + SelectParameters.ContentTypeCode]),
                    AgreementText = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.AgreementText]),
                    IsCurrent = DbHelper.ConvertValue<bool>(record[prefix + SelectParameters.IsCurrent]),
                    PublishedDateTime = DbHelper.ConvertValue<DateTime>(record[prefix + SelectParameters.PublishedDatetime]),
                    UpdatedByUserId = DbHelper.ConvertValue<Guid>(record[prefix + SelectParameters.UpdatedByUserId]),
                    UpdatedDateTime = DbHelper.ConvertValue<DateTime>(record[prefix + SelectParameters.UpdatedDatetime])
                };

            if (record.HasColumn(prefix + SelectParameters.BusinessNames))
            {
                resultAgreement.BusinessNames = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.BusinessNames]);
            }

            if (record.HasColumn(prefix + SelectParameters.BusinessIds))
            {
                var businessIds = DbHelper.ConvertValue<string>(record[prefix + SelectParameters.BusinessIds]);
                var idsAsString = new List<string>();
                if (string.IsNullOrWhiteSpace(businessIds) == false)
                {
                    idsAsString = businessIds.Split(',').ToList();
                }

                resultAgreement.BusinessIdsNeedingAgreement = idsAsString.ConvertAll(long.Parse);
            }

            return resultAgreement;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Convert agreement model to dto
 /// </summary>
 /// <param name="agreement">agreement to convert</param>
 /// <returns>dto of agreement</returns>
 public static AgreementDto ConvertAgreementToDto(Agreement agreement)
 {
     return new AgreementDto
                {
                    Id = agreement.Id,
                    AgreementStatus = (AgreementStatusDto)agreement.AgreementStatus,
                    AgreementText = agreement.AgreementText,
                    AgreementType = (AgreementTypeDto)agreement.AgreementType,
                    AgreementTypeName = agreement.AgreementTypeName,
                    ContentType = (ContentTypeEnumDto)agreement.ContentType,
                    IsCurrent = agreement.IsCurrent,
                    Name = agreement.Name,
                    BusinessNames = agreement.BusinessNames,
                    BusinessIdsNeedingAgreement = agreement.BusinessIdsNeedingAgreement,
                    PublishedDateTime = agreement.PublishedDateTime,
                    CountryId = agreement.CountryId,
                    CountryName = agreement.CountryName,
                    UpdatedByUserId = agreement.UpdatedByUserId,
                    UpdatedDateTime = agreement.UpdatedDateTime
                };
 }