Пример #1
0
        private static Models.Profile ServiceProfileToModelProfile(Messages.Profile profile)
        {
            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.CreateMap <Messages.Profile, Models.Profile>()
                              .ForPath(d => d.BasicProfile.Name, o => o.MapFrom(s => s.BasicProfile.Name))
                              .ForPath(d => d.BasicProfile.DateOfBirth, o => o.MapFrom(s => s.BasicProfile.DateOfBirth.ToDateTimeOffset()))
                              .ForPath(d => d.BasicProfile.Address.Street, o => o.MapFrom(s => s.BasicProfile.FullAddress.Street))
                              .ForPath(d => d.BasicProfile.Address.City, o => o.MapFrom(s => s.BasicProfile.FullAddress.City))
                              .ForPath(d => d.BasicProfile.Address.State, o => o.MapFrom(s => s.BasicProfile.FullAddress.State == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.BasicProfile.Address.Zip, o => o.MapFrom(s => s.BasicProfile.FullAddress.Zip))
                              .ForPath(d => d.BasicProfile.FedIncome, o => o.MapFrom(s => s.BasicProfile.FedIncome))
                              .ForPath(d => d.BasicProfile.StateIncome, o => o.MapFrom(s => s.BasicProfile.StateIncome))
                              .ForPath(d => d.BasicProfile.ApplicationType, o => o.MapFrom(s => s.BasicProfile.ApplicationType == Messages.ApplicationType.Individual ? Models.ApplicationType.Indivisual : Models.ApplicationType.Family))
                              .ForPath(d => d.BasicProfile.CitizenShip, o => o.MapFrom(s => s.BasicProfile.Citizenship))
                              .ForPath(d => d.CurrentHealthcarePlan.EnrollmentBorkerAssigedState, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentBrokerAssignedState == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.ActiveState, o => o.MapFrom(s => s.ActiveState == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.TransactionID, o => o.MapFrom(s => s.TransactionId ?? " "))
                              .ForPath(d => d.TransactedTime, o => o.MapFrom(s => s.TransactedTime.ToDateTimeOffset()))
                              .ForPath(d => d.CurrentHealthcarePlan.Plan.Id, o => o.MapFrom(s => s.CurrentHealthcarePlan.Plan.Id))
                              .ForPath(d => d.CurrentHealthcarePlan.Plan.Name, o => o.MapFrom(s => s.CurrentHealthcarePlan.Plan.Name))
                              .ForPath(d => d.CurrentHealthcarePlan.HealthcareStatus, o => o.MapFrom(s => s.CurrentHealthcarePlan.HealthcareStatus))
                              .ForPath(d => d.CurrentHealthcarePlan.CarePlanEligibilityStatus, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentStatus))
                              .ForPath(d => d.CurrentHealthcarePlan.OwnerState, o => o.MapFrom(s => s.CurrentHealthcarePlan.OwnerState == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.CurrentHealthcarePlan.EnrollmentBorkerAssigedState, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentBrokerAssignedState == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.CurrentHealthcarePlan.EnrollmentBorkerAssigedState, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentBrokerAssignedState == Messages.State.Ny ? "NY" : "NJ"))
                              .ForPath(d => d.CurrentHealthcarePlan.PlanApprover, o => o.MapFrom(s => s.CurrentHealthcarePlan.PlanApprover))
                              .ForPath(d => d.CurrentHealthcarePlan.Eligible, o => o.MapFrom(s => s.CurrentHealthcarePlan.Eligible))
                              .ForPath(d => d.CurrentHealthcarePlan.Approved, o => o.MapFrom(s => s.CurrentHealthcarePlan.Approved))
                              .ForPath(d => d.CurrentHealthcarePlan.AssignedDate, o => o.MapFrom(s => s.CurrentHealthcarePlan.AssignedDate.ToDateTimeOffset()))
                              .ForPath(d => d.CurrentHealthcarePlan.EnrolledDate, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrolledDate.ToDateTimeOffset()))
                              .ForPath(d => d.CurrentHealthcarePlan.ApprovedDate, o => o.MapFrom(s => s.CurrentHealthcarePlan.ApprovedDate.ToDateTimeOffset()))
                              );
            Healthcare.BC.Offchain.Repository.Models.Profile profileDTO = Mapper.Map <Healthcare.BC.Offchain.Repository.Models.Profile>(profile);

            //adding business logic to here. afraid but ESC logic doesn't work correctly.
            profileDTO.CurrentHealthcarePlan.Eligible = ((profileDTO.BasicProfile.ApplicationType == Models.ApplicationType.Indivisual) &&
                                                         (profileDTO.BasicProfile.FedIncome <= 12400.00) &&
                                                         (profileDTO.BasicProfile.StateIncome <= 12400.00) &&
                                                         (profileDTO.BasicProfile.CitizenShip) && (profileDTO.CurrentHealthcarePlan.HealthcareStatus != Models.HealthcareStatus.Enrolled));


            return(profileDTO);
        }
Пример #2
0
        private static Messages.Profile ModelProfileToServceProfile(Models.Profile profile)
        {
            Mapper.Reset();
            Mapper.Initialize(cfg => cfg.CreateMap <Models.Profile, Messages.Profile>()
                              .ForPath(d => d.BasicProfile.Name, o => o.MapFrom(s => s.BasicProfile.Name))
                              .ForPath(d => d.BasicProfile.DateOfBirth, o => o.MapFrom(s => Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(s.BasicProfile.DateOfBirth)))
                              .ForPath(d => d.BasicProfile.FullAddress.Street, o => o.MapFrom(s => s.BasicProfile.Address.Street))
                              .ForPath(d => d.BasicProfile.FullAddress.City, o => o.MapFrom(s => s.BasicProfile.Address.City))
                              .ForPath(d => d.BasicProfile.FullAddress.State, o => o.MapFrom(s => s.BasicProfile.Address.State.ToUpper() == "NY" ? Messages.State.Ny : Messages.State.Nj))
                              .ForPath(d => d.BasicProfile.FullAddress.Zip, o => o.MapFrom(s => s.BasicProfile.Address.Zip))
                              .ForPath(d => d.BasicProfile.FedIncome, o => o.MapFrom(s => s.BasicProfile.FedIncome))
                              .ForPath(d => d.BasicProfile.StateIncome, o => o.MapFrom(s => s.BasicProfile.StateIncome))
                              .ForPath(d => d.BasicProfile.ApplicationType, o => o.MapFrom(s => s.BasicProfile.ApplicationType == Models.ApplicationType.Indivisual ? Messages.ApplicationType.Individual : Messages.ApplicationType.Family))
                              .ForPath(d => d.BasicProfile.Citizenship, o => o.MapFrom(s => s.BasicProfile.CitizenShip))
                              .ForPath(d => d.CurrentHealthcarePlan.EnrollmentBrokerAssignedState, o => o.MapFrom(s => s.CurrentHealthcarePlan.EnrollmentBorkerAssigedState.ToUpper() == "NY" ? Messages.State.Ny : Messages.State.Nj))
                              .ForPath(d => d.TransactionId, o => o.MapFrom(s => s.TransactionID ?? " "))
                              .ForPath(d => d.TransactedTime, o => o.MapFrom(s => Google.Protobuf.WellKnownTypes.Timestamp.FromDateTimeOffset(s.TransactedTime)))
                              .ForPath(d => d.EnrolledHealthInsurance, o => o.MapFrom(s => s.CurrentHealthcarePlan.Plan.Name == null ? false : true))
                              );

            Messages.Profile profileDTO = Mapper.Map <Messages.Profile>(profile);
            return(profileDTO);
        }