Esempio n. 1
0
        /// <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);
        }
        public void MachineExecute()
        {
            //used to set wizard header
            Machine["ListSection"]    = LookupUtil.GetValues(LookupTable.WizEmployerRegistration, null, "{DisplaySortOrder}", null);
            Machine["CurrentSection"] = LookupUtil.GetLookupCode(LookupTable.WizEmployerRegistration, LookupTable_WizEmployerRegistration.EnterLiabilityInformation);
            Machine["ShowHeader"]     = false;

            //initialize EmployerRegistration object and required address objects
            Machine["EmployerRegistration"] = new EmployerRegistrationViewModel();
            Machine["EntityAddress"]        = new AddressLinkDto()
            {
                Address = new AddressDto()
            };
            Machine["PhysicalAddress"] = new AddressLinkDto()
            {
                Address = new AddressDto()
                {
                    StateCode = LookupTable_State.Washington, CountryCode = LookupTable_Country.UnitedStates
                }
            };
            Machine["BusinessAddress"] = new AddressLinkDto()
            {
                Address = new AddressDto()
            };
            Machine["YearList"] = PopulateYears(4, 0, true);
        }
Esempio n. 3
0
        /// <summary>
        /// Method executes during page load
        /// </summary>
        public void MachineExecute()
        {
            //used to set wizard header
            Machine["ListSection"]    = LookupUtil.GetValues(LookupTable.WizEmployerRegistration, null, "{DisplaySortOrder}", null);
            Machine["CurrentSection"] = LookupUtil.GetLookupCode(LookupTable.WizEmployerRegistration, LookupTable_WizEmployerRegistration.EnterLiabilityInformation);
            Machine["ShowHeader"]     = false;

            //initialize EmployerRegistration object and required address objects
            Machine["EmployerRegistration"] = new EmployerRegistrationViewModel();
            Machine["EntityAddress"]        = new AddressLinkDto()
            {
                Address = new AddressDto()
                {
                    StateCode = LookupTable_StatePrvnc.Washington, CountryCode = LookupTable_Country.UnitedStates
                }, AddressTypeCode = LookupTable_AddressType.Mailing
            };
            Machine["PhysicalAddress"] = new AddressLinkDto()
            {
                Address = new AddressDto()
                {
                    StateCode = LookupTable_StatePrvnc.Washington, CountryCode = LookupTable_Country.UnitedStates
                }, AddressTypeCode = LookupTable_AddressType.Physical
            };
            Machine["BusinessAddress"] = new AddressLinkDto()
            {
                Address = new AddressDto()
                {
                    StateCode = LookupTable_StatePrvnc.Washington, CountryCode = LookupTable_Country.UnitedStates
                }, AddressTypeCode = LookupTable_AddressType.Business
            };
            Machine["YearList"] = DateUtil.PopulateYears(Convert.ToInt16(LookupTable_WageDetailUnitYears.YearsForWageFiling), 0, false);
        }
        /// <summary>
        /// Set Pending Fields for EmployerUnitDto
        /// </summary>
        /// <param name="employerUnitDto"></param>
        /// <param name="listAddressLinkDto"></param>
        /// <returns></returns>
        private static EmployerUnitDto SetPendingFieldsEmployerUnitDto(EmployerUnitDto employerUnitDto, List <AddressLinkDto> listAddressLinkDto)
        {
            string         countyCode      = "0";
            AddressLinkDto physicalAddress = listAddressLinkDto.FirstOrDefault(addressLink => addressLink.AddressTypeCode == LookupTable_AddressType.Physical);

            employerUnitDto.EmployerUnitSeqNo   = 1;
            employerUnitDto.DoingBusinessAsName = Shared.Utility.StringUtil.ToUpper(employerUnitDto.DoingBusinessAsName);
            employerUnitDto.StatusCode          = LookupTable_EmployerStatus.Active;
            employerUnitDto.StatusDate          = DateTimeUtil.Now;
            //TODO: when CountyCode is NULL, county code is determined based on the zip code
            //County zip mapping for WA needs to be populated in the lookup data
            employerUnitDto.CountyCode = physicalAddress?.Address?.CountyCode ?? countyCode;

            return(employerUnitDto);
        }
        /// <summary>
        ///
        /// </summary>
        /// <param name="employerUnitDto"></param>
        /// <returns></returns>
        static EmployerUnit AddEmployerUnit(EmployerUnitDto employerUnitDto)
        {
            string         countyCode      = "0";
            AddressLinkDto physicalAddress = employerUnitDto.Employer.AddressLinks.FirstOrDefault(addressLink => addressLink.AddressTypeCode == LookupTable_AddressType.Physical);
            EmployerUnit   employerUnit    = new EmployerUnit
            {
                EmployerUnitSeqNo   = 1,
                DoingBusinessAsName = Shared.Utility.StringUtil.ToUpper(employerUnitDto.DoingBusinessAsName),
                FirstWageDate       = employerUnitDto.FirstWageDate,
                StatusCode          = LookupTable_EmployerStatus.Active,
                StatusDate          = DateTimeUtil.Now,
                //TODO: when CountyCode is NULL, county code is determined based on the zip code
                //County zip mapping for WA needs to be populated in the lookup data
                CountyCode = physicalAddress.Address.CountyCode
            };

            return(employerUnit);
        }
Esempio n. 6
0
        protected static void FromDtoSet(FACTS.Framework.DAL.DbContext dbContext, AddressLinkDto dto, AddressLink entity, Dictionary <FACTS.Framework.Dto.BaseDto, BaseEntity> dtoEntities)
        {
            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);
        }
Esempio n. 7
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);
            FromDtoSet(dbContext, dto, entity, dtoEntities);

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

            return(entity);
        }
Esempio n. 8
0
        /// <summary>Convert from AddressLink entity to DTO w/o checking entity state or entity navigation</summary>
        /// <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>
        /// <returns>Resultant AddressLink DTO</returns>
        public AddressLinkDto ToDto(AddressLinkDto dto = null)
        {
            dto       = dto ?? new AddressLinkDto();
            dto.IsNew = false;

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

            return(dto);
        }
Esempio n. 9
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);
        }