예제 #1
0
        public async Task CanGetBenefitPlanMembers()
        {
            foreach (var testAccount in TestAccounts.TyLinAccounts.Accounts)
            {
                foreach (var benefitPlanId in testAccount.BenefitPlans)
                {
                    var employer = EmployerCache.Employers.FirstOrDefault(e =>
                                                                          e.Id == testAccount.EmployerId);

                    var repository = new Employee.Data.V2.EmployeeRepository();
                    repository.Initialize(employer.ConnectionString);

                    var dispatcher = new EmployeeDispatcher(repository);
                    var controller = new EmployeesController(dispatcher);

                    var result = await controller.GetEmployeeBenefitPlanMembersAsync(
                        employer,
                        testAccount.CchId,
                        benefitPlanId,
                        2016);

                    Assert.IsNotNull(result);
                    //Assert.IsNotNull(result.Content);
                }
            }
        }
예제 #2
0
        public override void OnActionExecuting(HttpActionContext actionContext)
        {
            base.OnActionExecuting(actionContext);

            // The cchId in the url needs to match the cchId in the Request or one of their dependents.
            // Retrieve employee dependents
            var employer = EmployerCache.Employers.FirstOrDefault(e =>
                                                                  e.Id == actionContext.Request.EmployerID());

            var cchId   = actionContext.Request.CCHID();
            var members = new List <PlanMember>();

            var repository = new Employee.Data.V2.EmployeeRepository();

            repository.Initialize(employer.ConnectionString);


            // Is this a datawarehouse database?
            bool isDataWarehouseEnabled = false;

            Task.Run(async() => isDataWarehouseEnabled =
                         await repository.IsExistingTableAsync("dbo", "BenefitEnrollment_f")).Wait();

            // Always add a record from Request.CCHID()
            members.Add(new PlanMember {
                CchId = cchId
            });

            if (isDataWarehouseEnabled)
            {
                // Grab list of members.
                var dispatcher = new EmployeeDispatcher(repository);
                Task.Run(async() => members.AddRange(await dispatcher.GetEmployeeDependentsAsync(
                                                         employer,
                                                         actionContext.Request.CCHID()))).Wait();
            }

            // Verify that the requested cchId is viewable by the logged in cchId.
            int  requestedCchId    = 0;
            bool validCchIdRequest = false;

            Int32.TryParse(actionContext.ActionArguments["cchId"].ToString(), out requestedCchId);

            foreach (var member in members)
            {
                if (member.CchId == requestedCchId)
                {
                    validCchIdRequest = true;
                    break;
                }
            }

            if (!validCchIdRequest)
            {
                throw new HttpResponseException(HttpStatusCode.Forbidden);
            }
        }
        private async Task LoadEmployeeAndDependentsAccumulationsAsync(int employerId, int cchId)
        {
            // Retrieve employee dependents
            var employer = EmployerCache.Employers.FirstOrDefault(e =>
                                                                  e.Id == employerId);

            var repository = new Employee.Data.V2.EmployeeRepository();

            var dispatcher = new EmployeeDispatcher(repository);
            var members    = await dispatcher.GetEmployeeDependentsAsync(employer, cchId);

            using (var ctx = new PlatformContext()) {
                foreach (var member in members)
                {
                    var pEmployerId = new SqlParameter("@EmployerID", employerId);
                    var pCchId      = new SqlParameter("@CCHID", member.CchId);

                    ctx.Database.ExecuteSqlCommand("EXEC CCH_FrontEnd2.dbo.[270_CallConsoleApp] @EmployerID, @CCHID", pEmployerId, pCchId);
                }
            }
            Dispose();
        }