/// <summary>Convert from VoluntaryPlanWaiverRequestType 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 VoluntaryPlanWaiverRequestType entity</returns>
        public static VoluntaryPlanWaiverRequestType FromDto(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestTypeDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((VoluntaryPlanWaiverRequestType)dtoEntities[dto]);
            }

            VoluntaryPlanWaiverRequestType entity = new VoluntaryPlanWaiverRequestType();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime                   = dto.CreateDateTime;
            entity.CreateUserId                     = dto.CreateUserId;
            entity.DurationInWeeksCode              = dto.DurationInWeeksCode;
            entity.LeaveTypeCode                    = dto.LeaveTypeCode;
            entity.PercentagePaid                   = dto.PercentagePaid;
            entity.UpdateDateTime                   = dto.UpdateDateTime;
            entity.UpdateNumber                     = dto.UpdateNumber;
            entity.UpdateProcess                    = dto.UpdateProcess;
            entity.UpdateUserId                     = dto.UpdateUserId;
            entity.VoluntaryPlanWaiverRequestId     = dto.VoluntaryPlanWaiverRequestId;
            entity.VoluntaryPlanWaiverRequestTypeId = dto.VoluntaryPlanWaiverRequestTypeId;

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

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

            return(entity);
        }
Example #2
0
        /// <summary>Convert from EmployerPreference 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 EmployerPreference entity</returns>
        public static EmployerPreference FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerPreferenceDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerPreference)dtoEntities[dto]);
            }

            EmployerPreference entity = new EmployerPreference();

            dtoEntities.Add(dto, entity);

            entity.CorrespondanceTypeCode = dto.CorrespondanceTypeCode;
            entity.CreateDateTime         = dto.CreateDateTime;
            entity.CreateUserId           = dto.CreateUserId;
            entity.Email          = dto.Email;
            entity.EmployerId     = dto.EmployerId;
            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);
        }
        /// <summary>Convert from AddressLink entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant AddressLink DTO</returns>
        public AddressLinkDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, AddressLinkDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((AddressLinkDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <AddressLink> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Reference(x => x.Address)?.IsLoaded == true)
            {
                dto.Address = Address?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Reference(x => x.Employer)?.IsLoaded == true)
            {
                dto.Employer = Employer?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Reference(x => x.EmployerUnit)?.IsLoaded == true)
            {
                dto.EmployerUnit = EmployerUnit?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }

            return(dto);
        }
Example #4
0
        /// <summary>Convert from SecurityDefinition 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 SecurityDefinition entity</returns>
        public static SecurityDefinition FromDto(FACTS.Framework.DAL.DbContext dbContext, SecurityDefinitionDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((SecurityDefinition)dtoEntities[dto]);
            }

            SecurityDefinition entity = new SecurityDefinition();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.Description    = dto.Description;
            entity.Name           = dto.Name;
            entity.Type           = dto.Type;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateUserId   = dto.UpdateUserId;


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

            return(entity);
        }
        /// <summary>Convert from FormAttachment entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant FormAttachment DTO</returns>
        public FormAttachmentDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, FormAttachmentDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((FormAttachmentDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <FormAttachment> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Reference(x => x.Document)?.IsLoaded == true)
            {
                dto.Document = Document?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Reference(x => x.Form)?.IsLoaded == true)
            {
                dto.Form = Form?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }

            return(dto);
        }
Example #6
0
        /// <summary>Convert from TaxRate 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 TaxRate entity</returns>
        public static TaxRate FromDto(FACTS.Framework.DAL.DbContext dbContext, TaxRateDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((TaxRate)dtoEntities[dto]);
            }

            TaxRate entity = new TaxRate();

            dtoEntities.Add(dto, entity);

            entity._TaxRate           = dto._TaxRate;
            entity.CreateDateTime     = dto.CreateDateTime;
            entity.CreateUserId       = dto.CreateUserId;
            entity.EffectiveBeginDate = dto.EffectiveBeginDate;
            entity.EffectiveEndDate   = dto.EffectiveEndDate;
            entity.TaxRateId          = dto.TaxRateId;
            entity.UpdateDateTime     = dto.UpdateDateTime;
            entity.UpdateNumber       = dto.UpdateNumber;
            entity.UpdateProcess      = dto.UpdateProcess;
            entity.UpdateUserId       = dto.UpdateUserId;


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

            return(entity);
        }
Example #7
0
        /// <summary>Convert from Form entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant Form DTO</returns>
        public FormDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, FormDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((FormDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <Form> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Collection(x => x.FormAttachments)?.IsLoaded == true)
            {
                foreach (FormAttachment formAttachment in FormAttachments)
                {
                    dto.FormAttachments.Add(formAttachment.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }
            if (entry?.Collection(x => x.VoluntaryPlanWaiverRequests)?.IsLoaded == true)
            {
                foreach (VoluntaryPlanWaiverRequest voluntaryPlanWaiverRequest in VoluntaryPlanWaiverRequests)
                {
                    dto.VoluntaryPlanWaiverRequests.Add(voluntaryPlanWaiverRequest.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }

            return(dto);
        }
        /// <summary>Convert from FormAttachment 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 FormAttachment entity</returns>
        public static FormAttachment FromDto(FACTS.Framework.DAL.DbContext dbContext, FormAttachmentDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((FormAttachment)dtoEntities[dto]);
            }

            FormAttachment entity = new FormAttachment();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime   = dto.CreateDateTime;
            entity.CreateUserId     = dto.CreateUserId;
            entity.DocumentId       = dto.DocumentId;
            entity.FormAttachmentId = dto.FormAttachmentId;
            entity.FormId           = dto.FormId;
            entity.UpdateDateTime   = dto.UpdateDateTime;
            entity.UpdateNumber     = dto.UpdateNumber;
            entity.UpdateProcess    = dto.UpdateProcess;
            entity.UpdateUserId     = dto.UpdateUserId;

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

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

            return(entity);
        }
Example #9
0
        /// <summary>Convert from PaymentProfile 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 PaymentProfile entity</returns>
        public static PaymentProfile FromDto(FACTS.Framework.DAL.DbContext dbContext, PaymentProfileDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((PaymentProfile)dtoEntities[dto]);
            }

            PaymentProfile entity = new PaymentProfile();

            dtoEntities.Add(dto, entity);

            entity.AgentId                = dto.AgentId;
            entity.BankAccountNumber      = dto.BankAccountNumber;
            entity.CreateDateTime         = dto.CreateDateTime;
            entity.CreateUserId           = dto.CreateUserId;
            entity.EmployerId             = dto.EmployerId;
            entity.PaymentAccountTypeCode = dto.PaymentAccountTypeCode;
            entity.PaymentProfileId       = dto.PaymentProfileId;
            entity.PaymentTypeCode        = dto.PaymentTypeCode;
            entity.RoutingTransitNumber   = dto.RoutingTransitNumber;
            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);
        }
Example #10
0
        /// <summary>Convert from SecurityPermission 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 SecurityPermission entity</returns>
        public static SecurityPermission FromDto(FACTS.Framework.DAL.DbContext dbContext, SecurityPermissionDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((SecurityPermission)dtoEntities[dto]);
            }

            SecurityPermission entity = new SecurityPermission();

            dtoEntities.Add(dto, entity);

            entity.AccessType     = dto.AccessType;
            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.SourceName     = dto.SourceName;
            entity.SourceType     = dto.SourceType;
            entity.TargetName     = dto.TargetName;
            entity.TargetType     = dto.TargetType;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;


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

            return(entity);
        }
Example #11
0
        /// <summary>Convert from LookupValue 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 LookupValue entity</returns>
        public static LookupValue FromDto(FACTS.Framework.DAL.DbContext dbContext, LookupValueDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((LookupValue)dtoEntities[dto]);
            }

            LookupValue entity = new LookupValue();

            dtoEntities.Add(dto, entity);

            entity.Code           = dto.Code;
            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.Description    = dto.Description;
            entity.Name           = dto.Name;
            entity.Property       = dto.Property;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateUserId   = dto.UpdateUserId;
            entity.Value          = dto.Value;

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

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

            return(entity);
        }
Example #12
0
        /// <summary>Convert from Address entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant Address DTO</returns>
        public AddressDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, AddressDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((AddressDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <Address> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Collection(x => x.AddressLinks)?.IsLoaded == true)
            {
                foreach (AddressLink addressLink in AddressLinks)
                {
                    dto.AddressLinks.Add(addressLink.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }

            return(dto);
        }
Example #13
0
        /// <summary>Convert from LookupProperty entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant LookupProperty DTO</returns>
        public LookupPropertyDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, LookupPropertyDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((LookupPropertyDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <LookupProperty> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Reference(x => x.LookupName)?.IsLoaded == true)
            {
                dto.LookupName = LookupName?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }
            if (entry?.Collection(x => x.LookupValues)?.IsLoaded == true)
            {
                foreach (LookupValue lookupValue in LookupValues)
                {
                    dto.LookupValues.Add(lookupValue.ToDtoDeep(dbContext, entityDtos: entityDtos));
                }
            }

            return(dto);
        }
Example #14
0
        /// <summary>Convert from Address 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 Address entity</returns>
        public static Address FromDto(FACTS.Framework.DAL.DbContext dbContext, AddressDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((Address)dtoEntities[dto]);
            }

            Address entity = new Address();

            dtoEntities.Add(dto, entity);

            entity.AddressId               = dto.AddressId;
            entity.AddressLine1            = dto.AddressLine1;
            entity.AddressLine2            = dto.AddressLine2;
            entity.AddressVerificationCode = dto.AddressVerificationCode;
            entity.Attention               = dto.Attention;
            entity.BusinessWebAddress      = dto.BusinessWebAddress;
            entity.City                 = dto.City;
            entity.CountryCode          = dto.CountryCode;
            entity.CountyCode           = dto.CountyCode;
            entity.CreateDateTime       = dto.CreateDateTime;
            entity.CreateUserId         = dto.CreateUserId;
            entity.Email                = dto.Email;
            entity.FaxNumber            = dto.FaxNumber;
            entity.IntFaxNumber         = dto.IntFaxNumber;
            entity.IntPhoneNumber       = dto.IntPhoneNumber;
            entity.IntPhoneNumberExtn   = dto.IntPhoneNumberExtn;
            entity.OtherPhoneNumber     = dto.OtherPhoneNumber;
            entity.OtherPhoneNumberExtn = dto.OtherPhoneNumberExtn;
            entity.PhoneNumber          = dto.PhoneNumber;
            entity.PhoneNumberExtn      = dto.PhoneNumberExtn;
            entity.StateCode            = dto.StateCode;
            entity.UpdateDateTime       = dto.UpdateDateTime;
            entity.UpdateNumber         = dto.UpdateNumber;
            entity.UpdateProcess        = dto.UpdateProcess;
            entity.UpdateUserId         = dto.UpdateUserId;
            entity.Zip = dto.Zip;

            if (dto.AddressLinks != null)
            {
                foreach (AddressLinkDto addressLink in dto.AddressLinks)
                {
                    entity.AddressLinks.Add(DbEntities.AddressLink.FromDto(dbContext, addressLink, dtoEntities));
                }
            }

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

            return(entity);
        }
Example #15
0
        /// <summary>Convert from WageUnitDetail 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 WageUnitDetail entity</returns>
        public static WageUnitDetail FromDto(FACTS.Framework.DAL.DbContext dbContext, WageUnitDetailDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((WageUnitDetail)dtoEntities[dto]);
            }

            WageUnitDetail entity = new WageUnitDetail();

            dtoEntities.Add(dto, entity);

            entity.AdjReasonCode      = dto.AdjReasonCode;
            entity.CreateDateTime     = dto.CreateDateTime;
            entity.CreateUserId       = dto.CreateUserId;
            entity.EmployerId         = dto.EmployerId;
            entity.EmployerUnitId     = dto.EmployerUnitId;
            entity.FilingMethod       = dto.FilingMethod;
            entity.FirstName          = dto.FirstName;
            entity.HoursWorked        = dto.HoursWorked;
            entity.IsEmploymentMonth1 = dto.IsEmploymentMonth1;
            entity.IsEmploymentMonth2 = dto.IsEmploymentMonth2;
            entity.IsEmploymentMonth3 = dto.IsEmploymentMonth3;
            entity.IsOwnerOrOfficer   = dto.IsOwnerOrOfficer;
            entity.LastName           = dto.LastName;
            entity.MiddleInitialName  = dto.MiddleInitialName;
            entity.Occupation         = dto.Occupation;
            entity.ReportingQuarter   = dto.ReportingQuarter;
            entity.ReportingYear      = dto.ReportingYear;
            entity.Ssn            = dto.Ssn;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;
            entity.WageAmount     = dto.WageAmount;

            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);
        }
Example #16
0
        /// <summary>Convert from TaxRate entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant TaxRate DTO</returns>
        public TaxRateDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, TaxRateDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((TaxRateDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <TaxRate> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);


            return(dto);
        }
Example #17
0
        /// <summary>Convert from Form 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 Form entity</returns>
        public static Form FromDto(FACTS.Framework.DAL.DbContext dbContext, FormDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((Form)dtoEntities[dto]);
            }

            Form entity = new Form();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.FormId         = dto.FormId;
            entity.FormTypeCode   = dto.FormTypeCode;
            entity.StatusCode     = dto.StatusCode;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;

            if (dto.FormAttachments != null)
            {
                foreach (FormAttachmentDto formAttachment in dto.FormAttachments)
                {
                    entity.FormAttachments.Add(DbEntities.FormAttachment.FromDto(dbContext, formAttachment, dtoEntities));
                }
            }
            if (dto.VoluntaryPlanWaiverRequests != null)
            {
                foreach (VoluntaryPlanWaiverRequestDto voluntaryPlanWaiverRequest in dto.VoluntaryPlanWaiverRequests)
                {
                    entity.VoluntaryPlanWaiverRequests.Add(DbEntities.VoluntaryPlanWaiverRequest.FromDto(dbContext, voluntaryPlanWaiverRequest, dtoEntities));
                }
            }

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

            return(entity);
        }
Example #18
0
        /// <summary>Convert from LookupName 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 LookupName entity</returns>
        public static LookupName FromDto(FACTS.Framework.DAL.DbContext dbContext, LookupNameDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((LookupName)dtoEntities[dto]);
            }

            LookupName entity = new LookupName();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.Description    = dto.Description;
            entity.Name           = dto.Name;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;

            if (dto.LookupCodes != null)
            {
                foreach (LookupCodeDto lookupCode in dto.LookupCodes)
                {
                    entity.LookupCodes.Add(DbEntities.LookupCode.FromDto(dbContext, lookupCode, dtoEntities));
                }
            }
            if (dto.LookupProperties != null)
            {
                foreach (LookupPropertyDto lookupProperty in dto.LookupProperties)
                {
                    entity.LookupProperties.Add(DbEntities.LookupProperty.FromDto(dbContext, lookupProperty, dtoEntities));
                }
            }

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

            return(entity);
        }
Example #19
0
        /// <summary>Convert from VoluntaryPlanWaiverRequest 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 VoluntaryPlanWaiverRequest entity</returns>
        public static VoluntaryPlanWaiverRequest FromDto(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((VoluntaryPlanWaiverRequest)dtoEntities[dto]);
            }

            VoluntaryPlanWaiverRequest entity = new VoluntaryPlanWaiverRequest();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime = dto.CreateDateTime;
            entity.CreateUserId   = dto.CreateUserId;
            entity.EmployerId     = dto.EmployerId;
            entity.EndDate        = dto.EndDate;
            entity.FormId         = dto.FormId;
            entity.IsVoluntaryPlanWaiverRequestAcknowledged = dto.IsVoluntaryPlanWaiverRequestAcknowledged;
            entity.StartDate      = dto.StartDate;
            entity.UpdateDateTime = dto.UpdateDateTime;
            entity.UpdateNumber   = dto.UpdateNumber;
            entity.UpdateProcess  = dto.UpdateProcess;
            entity.UpdateUserId   = dto.UpdateUserId;
            entity.VoluntaryPlanWaiverRequestId = dto.VoluntaryPlanWaiverRequestId;

            entity.Employer = (dto.Employer == null) ? null : Employer.FromDto(dbContext, dto.Employer, dtoEntities);
            entity.Form     = (dto.Form == null) ? null : Form.FromDto(dbContext, dto.Form, dtoEntities);
            if (dto.VoluntaryPlanWaiverRequestTypes != null)
            {
                foreach (VoluntaryPlanWaiverRequestTypeDto voluntaryPlanWaiverRequestType in dto.VoluntaryPlanWaiverRequestTypes)
                {
                    entity.VoluntaryPlanWaiverRequestTypes.Add(DbEntities.VoluntaryPlanWaiverRequestType.FromDto(dbContext, voluntaryPlanWaiverRequestType, dtoEntities));
                }
            }

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

            return(entity);
        }
        /// <summary>Convert from EmployerUnit 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 EmployerUnit entity</returns>
        public static EmployerUnit FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerUnitDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerUnit)dtoEntities[dto]);
            }

            EmployerUnit entity = new EmployerUnit();

            dtoEntities.Add(dto, entity);

            entity.CountyCode          = dto.CountyCode;
            entity.CreateDateTime      = dto.CreateDateTime;
            entity.CreateUserId        = dto.CreateUserId;
            entity.DoingBusinessAsName = dto.DoingBusinessAsName;
            entity.EmployerId          = dto.EmployerId;
            entity.EmployerUnitSeqNo   = dto.EmployerUnitSeqNo;
            entity.FirstWageDate       = dto.FirstWageDate;
            entity.StatusCode          = dto.StatusCode;
            entity.StatusDate          = dto.StatusDate;
            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 (dto.AddressLinks != null)
            {
                foreach (AddressLinkDto addressLink in dto.AddressLinks)
                {
                    entity.AddressLinks.Add(DbEntities.AddressLink.FromDto(dbContext, addressLink, dtoEntities));
                }
            }

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

            return(entity);
        }
Example #21
0
        /// <summary>Convert from VoluntaryPlanWaiverRequestType 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 VoluntaryPlanWaiverRequestType entity</returns>
        public static VoluntaryPlanWaiverRequestType FromDto(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestTypeDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((VoluntaryPlanWaiverRequestType)dtoEntities[dto]);
            }

            VoluntaryPlanWaiverRequestType entity = new VoluntaryPlanWaiverRequestType();

            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);
        }
Example #22
0
        /// <summary>Convert from Address 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 Address entity</returns>
        public static Address FromDto(FACTS.Framework.DAL.DbContext dbContext, AddressDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((Address)dtoEntities[dto]);
            }

            Address entity = new Address();

            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);
        }
        /// <summary>Convert from EmployerAccountTransaction 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 EmployerAccountTransaction entity</returns>
        public static EmployerAccountTransaction FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerAccountTransactionDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerAccountTransaction)dtoEntities[dto]);
            }

            EmployerAccountTransaction entity = new EmployerAccountTransaction();

            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);
        }
Example #24
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);
        }
        /// <summary>Convert from TaxableAmountSum 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 TaxableAmountSum entity</returns>
        public static TaxableAmountSum FromDto(FACTS.Framework.DAL.DbContext dbContext, TaxableAmountSumDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((TaxableAmountSum)dtoEntities[dto]);
            }

            TaxableAmountSum entity = new TaxableAmountSum();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime     = dto.CreateDateTime;
            entity.CreateUserId       = dto.CreateUserId;
            entity.EmployerId         = dto.EmployerId;
            entity.Quarter1GrossAmt   = dto.Quarter1GrossAmt;
            entity.Quarter1TaxableAmt = dto.Quarter1TaxableAmt;
            entity.Quarter2GrossAmt   = dto.Quarter2GrossAmt;
            entity.Quarter2TaxableAmt = dto.Quarter2TaxableAmt;
            entity.Quarter3GrossAmt   = dto.Quarter3GrossAmt;
            entity.Quarter3TaxableAmt = dto.Quarter3TaxableAmt;
            entity.Quarter4GrossAmt   = dto.Quarter4GrossAmt;
            entity.Quarter4TaxableAmt = dto.Quarter4TaxableAmt;
            entity.ReportingQuarter   = dto.ReportingQuarter;
            entity.ReportingYear      = dto.ReportingYear;
            entity.StatusCode         = dto.StatusCode;
            entity.TaxableAmountSeqNo = dto.TaxableAmountSeqNo;
            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);
        }
Example #26
0
        /// <summary>Convert from Document 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 Document entity</returns>
        public static Document FromDto(FACTS.Framework.DAL.DbContext dbContext, DocumentDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((Document)dtoEntities[dto]);
            }

            Document entity = new Document();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime      = dto.CreateDateTime;
            entity.CreateUserId        = dto.CreateUserId;
            entity.DocumentDescription = dto.DocumentDescription;
            entity.DocumentID          = dto.DocumentID;
            entity.DocumentName        = dto.DocumentName;
            entity.ExternalDocumentId  = dto.ExternalDocumentId;
            entity.UpdateDateTime      = dto.UpdateDateTime;
            entity.UpdateNumber        = dto.UpdateNumber;
            entity.UpdateProcess       = dto.UpdateProcess;
            entity.UpdateUserId        = dto.UpdateUserId;

            if (dto.FormAttachments != null)
            {
                foreach (FormAttachmentDto formAttachment in dto.FormAttachments)
                {
                    entity.FormAttachments.Add(DbEntities.FormAttachment.FromDto(dbContext, formAttachment, dtoEntities));
                }
            }

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

            return(entity);
        }
        /// <summary>Convert from EmployerAccountTransaction 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 EmployerAccountTransaction entity</returns>
        public static EmployerAccountTransaction FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerAccountTransactionDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerAccountTransaction)dtoEntities[dto]);
            }

            EmployerAccountTransaction entity = new EmployerAccountTransaction();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime   = dto.CreateDateTime;
            entity.CreateUserId     = dto.CreateUserId;
            entity.DueDate          = dto.DueDate;
            entity.EmployerId       = dto.EmployerId;
            entity.OwedAmount       = dto.OwedAmount;
            entity.ReportingQuarter = dto.ReportingQuarter;
            entity.ReportingYear    = dto.ReportingYear;
            entity.StatusCode       = dto.StatusCode;
            entity.ThresholdAmount  = dto.ThresholdAmount;
            entity.TransactionSeqNo = dto.TransactionSeqNo;
            entity.TypeCode         = dto.TypeCode;
            entity.UnpaidAmount     = dto.UnpaidAmount;
            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);
        }
Example #28
0
        /// <summary>Convert from AddressLink 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 AddressLink entity</returns>
        public static AddressLink FromDto(FACTS.Framework.DAL.DbContext dbContext, AddressLinkDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((AddressLink)dtoEntities[dto]);
            }

            AddressLink entity = new AddressLink();

            dtoEntities.Add(dto, entity);

            entity.AddressId         = dto.AddressId;
            entity.AddressLinkId     = dto.AddressLinkId;
            entity.AddressTypeCode   = dto.AddressTypeCode;
            entity.AgentId           = dto.AgentId;
            entity.CreateDateTime    = dto.CreateDateTime;
            entity.CreateUserId      = dto.CreateUserId;
            entity.EmployerId        = dto.EmployerId;
            entity.EmployerUnitSeqNo = dto.EmployerUnitSeqNo;
            entity.StatusCode        = dto.StatusCode;
            entity.UpdateDateTime    = dto.UpdateDateTime;
            entity.UpdateNumber      = dto.UpdateNumber;
            entity.UpdateProcess     = dto.UpdateProcess;
            entity.UpdateUserId      = dto.UpdateUserId;

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

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

            return(entity);
        }
Example #29
0
        /// <summary>Convert from EmployerLiability 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 EmployerLiability entity</returns>
        public static EmployerLiability FromDto(FACTS.Framework.DAL.DbContext dbContext, EmployerLiabilityDto dto, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities = null)
        {
            dtoEntities = dtoEntities ?? new Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity>();
            if (dtoEntities.ContainsKey(dto))
            {
                return((EmployerLiability)dtoEntities[dto]);
            }

            EmployerLiability entity = new EmployerLiability();

            dtoEntities.Add(dto, entity);

            entity.CreateDateTime                   = dto.CreateDateTime;
            entity.CreateUserId                     = dto.CreateUserId;
            entity.EmployerId                       = dto.EmployerId;
            entity.GrossWagesPaid                   = dto.GrossWagesPaid;
            entity.HasEmployed10In20Weeks           = dto.HasEmployed10In20Weeks;
            entity.HasEmployed1In20Weeks            = dto.HasEmployed1In20Weeks;
            entity.HasPaid1KDomesticWages           = dto.HasPaid1KDomesticWages;
            entity.HasPaid20KAgriculturalLaborWages = dto.HasPaid20KAgriculturalLaborWages;
            entity.HasPaid450RegularWages           = dto.HasPaid450RegularWages;
            entity.LiabilityAmountMetQuarter        = dto.LiabilityAmountMetQuarter;
            entity.LiabilityAmountMetYear           = dto.LiabilityAmountMetYear;
            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);
        }
Example #30
0
        /// <summary>Convert from VoluntaryPlanWaiverRequestType entity to DTO</summary>
        /// <param name="dbContext">DB Context to use for setting DTO state</param>
        /// <param name="dto">DTO to use if already created instead of creating new one (can be inherited class instead as opposed to base class)</param>
        /// <param name="entityDtos">Used internally to track which entities have been converted to DTO's already (to avoid re-converting when circularly referenced)</param>
        /// <returns>Resultant VoluntaryPlanWaiverRequestType DTO</returns>
        public VoluntaryPlanWaiverRequestTypeDto ToDtoDeep(FACTS.Framework.DAL.DbContext dbContext, VoluntaryPlanWaiverRequestTypeDto dto = null, Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto> entityDtos = null)
        {
            entityDtos = entityDtos ?? new Dictionary <BaseEntity, FACTS.Framework.Dto.BaseDto>();
            if (entityDtos.ContainsKey(this))
            {
                return((VoluntaryPlanWaiverRequestTypeDto)entityDtos[this]);
            }

            dto = ToDto(dto);
            entityDtos.Add(this, dto);

            System.Data.Entity.Infrastructure.DbEntityEntry <VoluntaryPlanWaiverRequestType> entry = dbContext?.Entry(this);
            dto.IsNew     = (entry?.State == EntityState.Added);
            dto.IsDeleted = (entry?.State == EntityState.Deleted);

            if (entry?.Reference(x => x.VoluntaryPlanWaiverRequest)?.IsLoaded == true)
            {
                dto.VoluntaryPlanWaiverRequest = VoluntaryPlanWaiverRequest?.ToDtoDeep(dbContext, entityDtos: entityDtos);
            }

            return(dto);
        }