Exemplo n.º 1
0
        /// <summary>Convert from EmployerContact DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant EmployerContact entity</returns>
        public static EmployerContact FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerContactDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerContact)dtoEntities[dto]);
            }

            EmployerContact entity = new EmployerContact();

            dtoEntities.Add(dto, entity);
            FromDtoSet(dbContext, dto, entity, dtoEntities);

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
Exemplo n.º 2
0
        /// <summary>Convert from EmployerContact DTO to entity</summary>
        /// <param name="dbContext">DB Context to use for attaching entity</param>
        /// <param name="dto">DTO to convert from</param>
        /// <param name="dtoEntities">Used internally to track which dtos have been converted to entites already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant EmployerContact entity</returns>
        public static EmployerContact FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerContactDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerContact)dtoEntities[dto]);
            }

            EmployerContact entity = new EmployerContact();

            dtoEntities.Add(dto, entity);

            entity.ContactSeqNo             = dto.ContactSeqNo;
            entity.ContactTypeCode          = dto.ContactTypeCode;
            entity.CreateDateTime           = dto.CreateDateTime;
            entity.CreateUserId             = dto.CreateUserId;
            entity.Email                    = dto.Email;
            entity.EmployerId               = dto.EmployerId;
            entity.FirstName                = dto.FirstName;
            entity.LastName                 = dto.LastName;
            entity.MiddleInitial            = dto.MiddleInitial;
            entity.PhoneNumber              = dto.PhoneNumber;
            entity.PhoneNumberExtn          = dto.PhoneNumberExtn;
            entity.SecondaryPhoneNumber     = dto.SecondaryPhoneNumber;
            entity.SecondaryPhoneNumberExtn = dto.SecondaryPhoneNumberExtn;
            entity.StatusCode               = dto.StatusCode;
            entity.Title                    = dto.Title;
            entity.UpdateDateTime           = dto.UpdateDateTime;
            entity.UpdateNumber             = dto.UpdateNumber;
            entity.UpdateProcess            = dto.UpdateProcess;
            entity.UpdateUserId             = dto.UpdateUserId;

            entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities);

            if (dbContext != null)
            {
                dbContext.Entry(entity).State = (dto.IsNew ? EntityState.Added : (dto.IsDeleted ? EntityState.Deleted : EntityState.Modified));
            }

            return(entity);
        }
Exemplo n.º 3
0
        protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, EmployerContactDto dto, EmployerContact entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities)
        {
            entity.ContactSeqNo             = dto.ContactSeqNo;
            entity.ContactTypeCode          = dto.ContactTypeCode;
            entity.CreateDateTime           = dto.CreateDateTime;
            entity.CreateUserId             = dto.CreateUserId;
            entity.Email                    = dto.Email;
            entity.EmployerId               = dto.EmployerId;
            entity.FirstName                = dto.FirstName;
            entity.LastName                 = dto.LastName;
            entity.MiddleInitial            = dto.MiddleInitial;
            entity.PhoneNumber              = dto.PhoneNumber;
            entity.PhoneNumberExtn          = dto.PhoneNumberExtn;
            entity.SecondaryPhoneNumber     = dto.SecondaryPhoneNumber;
            entity.SecondaryPhoneNumberExtn = dto.SecondaryPhoneNumberExtn;
            entity.StatusCode               = dto.StatusCode;
            entity.Title                    = dto.Title;
            entity.UpdateDateTime           = dto.UpdateDateTime;
            entity.UpdateNumber             = dto.UpdateNumber;
            entity.UpdateProcess            = dto.UpdateProcess;
            entity.UpdateUserId             = dto.UpdateUserId;

            entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities);
        }