예제 #1
0
        /// <summary>
        /// Gets the member details for dash board.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <param name="auditLogBO">The audit log bo.</param>
        /// <param name="leftNavPermission">The left nav permission.</param>
        /// <returns></returns>
        public async Task <MemberDashboardBO> GetMemberDetailsForDashBoard(long userId, AuditLogBO auditLogBO, int leftNavPermission)
        {
            var dashboardBO = new MemberDashboardBO();
            var userDetails = await _unitOfWork.GetRepository <Users>().GetFirstOrDefaultAsync(i => i, predicate: u => u.UserId == userId);

            //To fetch last login
            var appUserDetails = await _authUnitOfWork.GetRepository <ApplicationUser>().GetFirstOrDefaultAsync(i => i, predicate: u => u.Id == userId);

            if (userDetails != null && appUserDetails != null)
            {
                var member = await _unitOfWork.GetRepository <Member>()
                             .GetFirstOrDefaultAsync(i => i, predicate: m => m.UserId == userId, include: i => i
                                                     .Include(a => a.MemberDetail)
                                                     .Include(a => a.MemberDependent)
                                                     .ThenInclude(s => s.MemberDetail)
                                                     .ThenInclude(a => a.MemberDependentStatusHistory)
                                                     .Include(s => s.MemberSubscription));

                if (member != null)
                {
                    dashboardBO.LastLogin = appUserDetails.LastLogin;
                    dashboardBO.FirstName = member.MemberDetail.FirstName;
                    dashboardBO.LastName  = member.MemberDetail.LastName;
                    if (leftNavPermission == MemberConstants.HasPermission)
                    {
                        dashboardBO.ExternalId = member.ExternalId;

                        dashboardBO.DepandentDetails = member.MemberDependent.Select(memberDependents => new MemberDependentBO
                        {
                            Name           = memberDependents.MemberDetail.FirstName + " " + memberDependents.MemberDetail.LastName,
                            Gender         = memberDependents.MemberDetail.Gender,
                            Age            = new DateTime(DateTime.Now.Subtract(memberDependents.MemberDetail.DateOfBirth).Ticks).Year - 1,
                            AvatarImageId  = memberDependents.MemberDetail.AvatarImageId,
                            MemberDetailId = memberDependents.MemberDetail.MemberDetailId,
                            Status         = SetStatus(memberDependents.MemberDetail.MemberDependentStatusHistory
                                                       .FirstOrDefault(x => x.MemberDetailId == memberDependents.MemberDetailId), memberDependents)
                        }).ToList();

                        dashboardBO.DepandentDetails.RemoveAll(dep => dep.Status == (int)DependentStatus.PendingActivation);
                    }
                }
            }

            //await AuditMapper.AuditLogging(auditLogBO, userId, AuditAction.Select, null);
            return(dashboardBO);
        }
예제 #2
0
        /// <summary>
        /// Gets the user details.
        /// </summary>
        /// <param name="userId">The user identifier.</param>
        /// <returns></returns>
        public async Task <MemberDashboardBO> GetUserDetails(long userId)
        {
            var dashboardBO = new MemberDashboardBO();
            var userDetails = await _unitOfWork.GetRepository <Users>().GetFirstOrDefaultAsync(i => i, predicate: u => u.UserId == userId);

            //To fetch last login
            var appUserDetails = await _authUnitOfWork.GetRepository <ApplicationUser>().GetFirstOrDefaultAsync(i => i, predicate: u => u.Id == userId);

            if (userDetails != null && appUserDetails != null)
            {
                dashboardBO.LastLogin       = appUserDetails.LastLogin;
                dashboardBO.FirstName       = userDetails.FirstName;
                dashboardBO.LastName        = userDetails.LastName;
                dashboardBO.SessionIdleTime = _appSettings.Value.SessionIdleTime;
                dashboardBO.SessionTimeOut  = _appSettings.Value.SessionTimeOut;
            }

            return(dashboardBO);
        }
예제 #3
0
        /// <summary>
        /// Gets the member plan details.
        /// </summary>
        /// <param name="memberId">The member identifier.</param>
        /// <param name="userId">The user identifier.</param>
        /// <param name="auditLogBO">The audit log bo.</param>
        /// <returns></returns>
        public async Task <MemberDashboardBO> GetMemberPlanDetails(long memberId, long userId, AuditLogBO auditLogBO)
        {
            MemberDashboardBO memberDashboardBO = null;
            var memberSubscription = await _unitOfWork.GetRepository <MemberSubscription>()
                                     .GetFirstOrDefaultAsync(i => i, predicate: ms => ms.MemberId == memberId,
                                                             include: i => i
                                                             .Include(a => a.MemberSubscribedPlan)
                                                             .ThenInclude(a => a.Plan)
                                                             .ThenInclude(a => a.Product)
                                                             .Include(a => a.Broker)
                                                             .Include(a => a.Group)
                                                             .Include(a => a.Member)
                                                             );

            if (memberSubscription != null)
            {
                var planDetails = new List <MemberPlanBO>();

                memberDashboardBO = new MemberDashboardBO
                {
                    GroupId          = memberSubscription.Group?.GroupId,
                    BrokerId         = memberSubscription.Broker.BrokerId,
                    BrokerName       = memberSubscription.Broker?.FirstName + " " + memberSubscription.Broker?.LastName,
                    GroupName        = memberSubscription.Group?.GroupLabel,
                    IsInternalBroker = memberSubscription.Broker?.BrokerTypeId.Value == MemberConstants.CallCenterInternal ||
                                       memberSubscription.Broker?.BrokerTypeId.Value == MemberConstants.CallCenterAliera ? true : false,

                    //To verify whether member enrolled in dental, vision plans
                    PlansCovered = new CoveredPlansBO
                    {
                        IsMedical = true
                    }
                };

                var planIds = memberSubscription.MemberSubscribedPlan.Select(p => Convert.ToInt64(p.PlanId)).ToList();

                var memberPlanStatus = await _unitOfWork.GetRepository <MemberStatusHistory>().GetPagedListAsync(a => a,
                                                                                                                 predicate: msh => planIds.Contains(msh.MemberSubscribedPlanId),
                                                                                                                 pageIndex: BrokerConstants.PAGE_INDEX, pageSize: BrokerConstants.PAGE_SIZE);

                var result = memberSubscription.MemberSubscribedPlan.Join(memberPlanStatus.Items,
                                                                          subscribedPlan => subscribedPlan.MemberSubscribedPlanId,
                                                                          statusHistory => statusHistory.MemberSubscribedPlanId,
                                                                          (subscribedPlan, statusHistory) => new
                {
                    subscribedPlan.PlanId,
                    statusHistory.InActiveDate,
                    subscribedPlan.NextBillingDate
                });

                if (planIds.Count > 0)
                {
                    if (result.Any())
                    {
                        planDetails = memberSubscription.MemberSubscribedPlan.Join(result,
                                                                                   plan => plan.PlanId,
                                                                                   r => r.PlanId, (plan, r) => new MemberPlanBO
                        {
                            MemberExternalId = memberSubscription.Member.ExternalId,
                            MSRA             = plan.Plan.Msra,
                            Duration         = plan.Plan.CoverageDuration,
                            MaxLimit         = plan.Plan.CoverageLimit,
                            CoverageDate     = memberSubscription.EffectiveDate,
                            NextBillingDate  = r.NextBillingDate,
                            InActiveDate     = r.InActiveDate,
                            PlanType         = plan.Plan.Type,
                            PlanName         = plan.Plan.Name
                        }).ToList();
                    }
                    else
                    {
                        planDetails = memberSubscription.MemberSubscribedPlan.Select(plan => new MemberPlanBO
                        {
                            MemberExternalId = memberSubscription.Member.ExternalId,
                            MSRA             = plan.Plan.Msra,
                            Duration         = plan.Plan.CoverageDuration,
                            MaxLimit         = plan.Plan.CoverageLimit,
                            CoverageDate     = memberSubscription.EffectiveDate,
                            NextBillingDate  = result.Select(ms => ms.NextBillingDate).FirstOrDefault(),
                            PlanType         = plan.Plan.Type,
                            PlanName         = plan.Plan.Name
                        }).ToList();
                    }

                    memberDashboardBO.PlanDetails = planDetails;

                    memberDashboardBO.ProductCodes = memberSubscription.MemberSubscribedPlan.Select(a => new
                    {
                        name  = a.Plan?.Product?.Name,
                        label = (!string.IsNullOrEmpty(a?.Plan?.Product?.ProductLabel) &&
                                 (a.Plan.Product.ProductLabel.ToLower().Contains(MemberConstants.DentalPlan) ||
                                  a.Plan.Product.ProductLabel.ToLower().Contains(MemberConstants.VisionPlan) ||
                                  a.Plan.Product.ProductLabel.ToLower().Contains(MemberConstants.DentalVisionPlan)))
                        ? a.Plan.Product.ProductLabel : MemberConstants.MedicalPlan,
                    }).ToDictionary(dic => dic.name, dic => dic.label);

                    //await AuditMapper.AuditLogging(auditLogBO, userId, AuditAction.Select, null);
                }
            }

            return(memberDashboardBO);
        }