Пример #1
0
        public void Delete(long HouseholdMemberId)
        {
            HouseholdMember householdMember = _context.HouseholdMember.FirstOrDefault(p => p.PersonId == HouseholdMemberId);

            _context.HouseholdMember.Remove(householdMember);
            _context.SaveChanges();
        }
        public ActionResult Create([Bind(Include = "Id,HouseholdProfileID,PersonID,RelationToHead")] HouseholdMember householdMember)
        {
            if (ModelState.IsValid)
            {
                if (householdMember.PersonID <= 0)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                var patient = db.Patient.First(p => p.PersonID == householdMember.PersonID);
                if (patient != null)
                {
                    db.Patient.Find(patient.PersonID).HouseholdProfileID = householdMember.HouseholdProfileID;
                }

                db.HouseholdMembers.Add(householdMember);
                db.SaveChanges();
                //return RedirectToAction("Index");
                int householdId = db.HouseholdProfiles.First(y => y.HouseholdProfileID == householdMember.HouseholdProfileID).Id;
                return(RedirectToAction("Details", "HouseholdProfiles", new { id = householdId }));
            }
            var NonHouseholdMemberPatients = db.Patient.Where(y => y.HouseholdProfileID == null || y.HouseholdProfileID == "");

            ViewBag.PersonID = new SelectList(NonHouseholdMemberPatients, "PersonID", "FullName", householdMember.PersonID);
            return(View(householdMember));
        }
        public async Task Update_EvacuationFileMultiplePrimaryRegistrants_ThrowsError()
        {
            var now = DateTime.UtcNow;

            now = new DateTime(now.Ticks - (now.Ticks % TimeSpan.TicksPerSecond), now.Kind);
            var registrant = (await GetRegistrantByUserId("CHRIS-TEST"));

            var file = (await manager.Handle(new EvacuationFilesQuery {
                PrimaryRegistrantId = registrant.Id
            })).Items.Last();

            if (file.NeedsAssessment.HouseholdMembers.Count() <= 1)
            {
                var member = new HouseholdMember
                {
                    FirstName           = registrant.FirstName,
                    LastName            = registrant.LastName,
                    Initials            = registrant.Initials,
                    Gender              = registrant.Gender,
                    DateOfBirth         = registrant.DateOfBirth,
                    IsPrimaryRegistrant = true,
                    LinkedRegistrantId  = registrant.Id
                };
                file.NeedsAssessment.HouseholdMembers = file.NeedsAssessment.HouseholdMembers.Concat(new[] { member });
            }

            foreach (var member in file.NeedsAssessment.HouseholdMembers)
            {
                member.IsPrimaryRegistrant = true;
            }

            Should.Throw <Exception>(() => manager.Handle(new SubmitEvacuationFileCommand {
                File = file
            })).Message.ShouldBe($"File {file.Id} can not have multiple primary registrant household members");
        }
        public ActionResult DeleteConfirmed(int id)
        {
            HouseholdMember householdMember = db.HouseholdMembers.Find(id);

            householdMember.Member.HouseholdProfileID = null;
            db.HouseholdMembers.Remove(householdMember);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #5
0
        public NewMemberViewModel()
        {
            PickImageCommand  = new Command(async() => await OnPickImageCommandExecuted());
            TakePhotoCommand  = new Command(async() => await OnTakePhotoCommandExecuted());
            SaveMemberCommand = new Command(async() => await OnSaveMemberCommandExecuted());

            Title  = "New Member";
            Member = new HouseholdMember();
        }
        // GET: HouseholdMembers/Create
        public ActionResult Create(string houseHoldId)
        {
            var householdProfile = db.HouseholdProfiles.First(y => y.HouseholdProfileID == houseHoldId);
            var householdMember  = new HouseholdMember();

            householdMember.HouseholdProfileID = houseHoldId;
            var NonHouseholdMemberPatients = db.Patient.Where(y => y.HouseholdProfileID == null || y.HouseholdProfileID == "");

            ViewBag.PersonID   = new SelectList(NonHouseholdMemberPatients, "PersonID", "FullName");
            ViewBag.Respondent = householdProfile.Respondent.FullName;
            return(View(householdMember));
        }
        // GET: HouseholdMembers/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HouseholdMember householdMember = db.HouseholdMembers.Find(id);

            if (householdMember == null)
            {
                return(HttpNotFound());
            }
            return(View(householdMember));
        }
        public ActionResult Edit([Bind(Include = "Id,HouseholdProfileID,PersonID,RelationToHead")] HouseholdMember householdMember)
        {
            if (ModelState.IsValid)
            {
                db.Entry(householdMember).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            //           ViewBag.PersonID = new SelectList(db.Patient, "PersonID", "FullName", householdMember.PersonID);
            var member = db.Patient.Find(householdMember.PersonID);

            householdMember.Member = member;
            return(View(householdMember));
        }
        public IActionResult Details(long id)
        {
            HouseholdMember member = _householdMember.Get(id);

            var model = new HouseholdMemberDetailModel()
            {
                Id             = member.PersonId,
                FullName       = member.Person.FullName,
                Sex            = member.Person.Sex.ToString(),
                RelationToHead = member.RelationToHead.ToString(),
                YearsOld       = member.Person.DateOfBirth.Year,
                MonthsOld      = member.Person.DateOfBirth.Month,
                DaysOld        = member.Person.DateOfBirth.Day,
            };

            return(View(model));
        }
        // GET: HouseholdMembers/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            HouseholdMember householdMember = db.HouseholdMembers.Find(id);

            if (householdMember == null)
            {
                return(HttpNotFound());
            }
            var member = db.Patient.Find(householdMember.PersonID);

            householdMember.Member = member;

            return(View(householdMember));
        }
        private async Task <ResidentContactDetails> GetContactDetailsAsync(HouseholdMember householdMember)
        {
            Uri url      = new Uri($"contactDetails?targetId={householdMember.Id}", UriKind.Relative);
            var response = await _apiGateway.ExecuteRequest <ContactDetailsResponse>(HttpClientNames.ContactDetails, url);

            if (response.Status == HttpStatusCode.NotFound)
            {
                _logger.LogInformation($"ContactDetails not found for targetId: {householdMember.Id}");

                return(null);
            }

            if (!response.IsSuccess)
            {
                _logger.LogError($"Call to {url} failed with {response.Status}");
                throw new ApiException(response.Status, Resources.ContactsFailure);
            }

            return(response.Content.ToDomain(householdMember));
        }
Пример #12
0
        public async Task Update_EvacuationFileMultiplePrimaryRegistrants_ThrowsError()
        {
            var now = DateTime.UtcNow;

            now = new DateTime(now.Ticks - now.Ticks % TimeSpan.TicksPerSecond, now.Kind);

            var file = await GetEvacuationFileById(TestData.EvacuationFileId);

            var newPrimaryMember = new HouseholdMember
            {
                FirstName           = registrant.FirstName,
                LastName            = registrant.LastName,
                Initials            = registrant.Initials,
                Gender              = registrant.Gender,
                DateOfBirth         = registrant.DateOfBirth,
                IsPrimaryRegistrant = true,
                LinkedRegistrantId  = registrant.Id
            };

            if (file.NeedsAssessment.HouseholdMembers.Count() <= 1)
            {
                file.NeedsAssessment.HouseholdMembers = file.NeedsAssessment.HouseholdMembers.Concat(new[] { newPrimaryMember });
            }

            foreach (var member in file.NeedsAssessment.HouseholdMembers)
            {
                member.IsPrimaryRegistrant = true;
            }

            (await Should.ThrowAsync <Exception>(async() => await manager.Handle(new SubmitEvacuationFileCommand {
                File = file
            })))
            .Message.ShouldBe($"File {file.Id} can not have multiple primary registrant household members");

            file.NeedsAssessment.HouseholdMembers = new[] { newPrimaryMember };

            (await Should.ThrowAsync <Exception>(async() => await manager.Handle(new SubmitEvacuationFileCommand {
                File = file
            })))
            .Message.ShouldBe($"File {file.Id} can not have multiple primary registrant household members");
        }
        public IActionResult Create(HouseholdMemberCreateModel householdMemberCreateModel)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var householdMember = new HouseholdMember();
                    householdMember.HouseholdProfileId = householdMemberCreateModel.HouseholdProfileId;
                    householdMember.PersonId           = householdMemberCreateModel.PersonId;
                    householdMember.RelationToHead     = householdMemberCreateModel.RelationToHouseholdHead;

                    _householdMember.Add(householdMember);
                    return(RedirectToAction("Index"));
                }
                return(View(householdMemberCreateModel));
            }
            catch (Exception err)
            {
                ModelState.AddModelError(err.ToString(), "Unable to save changes. Try again, and if the problem persists, see your system administrator.");
            }
            return(View(householdMemberCreateModel));
        }
Пример #14
0
 public MemberDetailsViewModel(HouseholdMember member = null)
 {
     Title  = member?.Text;
     Member = member;
 }
Пример #15
0
 public void Add(HouseholdMember newHouseholdMember)
 {
     _context.Add(newHouseholdMember);
     _context.SaveChanges();
 }
        /// <summary>
        /// Parses "raw" string values into a <see cref="DependentEfcCalculatorArguments"/> object that
        /// can be passed to the <see cref="EfcCalculator"/>. If validation errors occur while parsing the values,
        /// they are added to the <see cref="Errors"/> property of this validator
        /// </summary>
        /// <param name="args">Set of "raw" string arguments to parse</param>
        /// <returns>The parsed <see cref="DependentEfcCalculatorArguments"/> object or null if validation failed</returns>
        public DependentEfcCalculatorArguments ValidateDependentEfcCalculatorArguments(RawDependentEfcCalculatorArguments args)
        {
            if (args == null)
            {
                throw new ArgumentException("No raw arguments provided");
            }

            // Oldest Parent Age
            int oldestParentAge
                = _validator.ValidateNonZeroInteger(
                      args.OldestParentAge,
                      LabelOldestParentAge,
                      ParamOldestParentAge);

            // Marital Status
            MaritalStatus maritalStatus
                = _validator.ValidateMaritalStatus(
                      args.MaritalStatus,
                      LabelParentMaritalStatus,
                      ParamMaritalStatus);

            // Is First Parent Working?
            bool isFirstParentWorking
                = _validator.ValidateBoolean(
                      args.IsFirstParentWorking,
                      LabelIsFirstParentWorking,
                      ParamIsFirstParentWorking);

            // First Parent Work Income
            double firstParentWorkIncome
                = isFirstParentWorking
                      ? _validator.ValidatePositiveMoneyValue(
                      args.FirstParentWorkIncome,
                      LabelFirstParentWorkIncome,
                      ParamFirstParentWorkIncome)
                      : 0;

            HouseholdMember firstParent = new HouseholdMember
            {
                IsWorking  = isFirstParentWorking,
                WorkIncome = firstParentWorkIncome
            };

            HouseholdMember secondParent = null;

            if (maritalStatus == MaritalStatus.MarriedRemarried)
            {
                // Is Second Parent Working?
                bool isSecondParentWorking
                    = _validator.ValidateBoolean(
                          args.IsSecondParentWorking,
                          LabelIsSecondParentWorking,
                          ParamIsSecondParentWorking);

                // Mother Work Income
                double secondParentWorkIncome
                    = isSecondParentWorking
                          ? _validator.ValidatePositiveMoneyValue(
                          args.SecondParentWorkIncome,
                          LabelSecondParentWorkIncome,
                          ParamSecondParentWorkIncome)
                          : 0;

                secondParent = new HouseholdMember
                {
                    IsWorking  = isSecondParentWorking,
                    WorkIncome = secondParentWorkIncome
                };
            }

            // Is Student Working?
            bool isStudentWorking
                = _validator.ValidateBoolean(
                      args.IsStudentWorking,
                      LabelIsStudentWorking,
                      ParamIsStudentWorking);

            // Student Work Income
            double studentWorkIncome
                = isStudentWorking
                      ? _validator.ValidatePositiveMoneyValue(
                      args.StudentWorkIncome,
                      LabelStudentWorkIncome,
                      ParamStudentWorkIncome)
                      : 0;

            HouseholdMember student = new HouseholdMember
            {
                IsWorking  = isStudentWorking,
                WorkIncome = studentWorkIncome
            };

            // Parent AGI
            double parentAgi
                = _validator.ValidateMoneyValue(
                      args.ParentAgi,
                      LabelParentAgi,
                      ParamParentAgi);

            // Are Parents Tax Filers?
            bool areParentsTaxFilers
                = _validator.ValidateBoolean(
                      args.AreParentsTaxFilers,
                      LabelAreParentsTaxFilers,
                      ParamAreParentsTaxFilers);

            // Parent Income Tax Paid
            double parentIncomeTaxPaid
                = _validator.ValidateMoneyValue(
                      args.ParentIncomeTax,
                      LabelParentIncomeTax,
                      ParamParentIncomeTax);

            // Parent Untaxed Income and Benefits
            double parentUntaxedIncomeAndBenefits
                = _validator.ValidatePositiveMoneyValue(
                      args.ParentUntaxedIncomeAndBenefits,
                      LabelParentUntaxedIncomeAndBenefits,
                      ParamParentUntaxedIncomeAndBenefits);

            // Parent Additional Financial Info
            double parentAdditionalFinancialInfo
                = _validator.ValidatePositiveMoneyValue(
                      args.ParentAdditionalFinancialInfo,
                      LabelParentAdditionalFinancialInfo,
                      ParamParentAdditionalFinancialInfo);

            // Student AGI
            double studentAgi
                = _validator.ValidateMoneyValue(
                      args.StudentAgi,
                      LabelStudentAgi,
                      ParamStudentAgi);

            // Is Student Tax Filer?
            bool isStudentTaxFiler
                = _validator.ValidateBoolean(
                      args.IsStudentTaxFiler,
                      LabelIsStudentTaxFiler,
                      ParamIsStudentTaxFiler);

            // Student Income Tax Paid
            double studentIncomeTaxPaid
                = _validator.ValidateMoneyValue(
                      args.StudentIncomeTax,
                      LabelStudentIncomeTax,
                      ParamStudentIncomeTax);

            // Student Untaxed Income and Benefits
            double studentUntaxedIncomeAndBenefits
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentUntaxedIncomeAndBenefits,
                      LabelStudentUntaxedIncomeAndBenefits,
                      ParamStudentUntaxedIncomeAndBenefits);

            // Student Additional Financial Information
            double studentAdditionalFinancialInfo
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentAdditionalFinancialInfo,
                      LabelStudentAdditionalFinancialInfo,
                      ParamStudentAdditionalFinancialInfo);

            // Parent Cash, Savings, Checking
            double parentCashSavingsChecking
                = _validator.ValidatePositiveMoneyValue(
                      args.ParentCashSavingsChecking,
                      LabelParentCashSavingsChecking,
                      ParamParentCashSavingsChecking);

            // Parent Investment Net Worth
            double parentInvestmentNetWorth
                = _validator.ValidateMoneyValue(
                      args.ParentInvestmentNetWorth,
                      LabelParentInvestmentNetWorth,
                      ParamParentInvestmentNetWorth);

            // Parent Business Farm Net Worth
            double parentBusinessFarmNetWorth
                = _validator.ValidateMoneyValue(
                      args.ParentBusinessFarmNetWorth,
                      LabelParentBusinessFarmNetWorth,
                      ParamParentBusinessFarmNetWorth);

            // Student Cash, Savings, Checkings
            double studentCashSavingsCheckings
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentCashSavingsChecking,
                      LabelStudentCashSavingsChecking,
                      ParamStudentCashSavingsChecking);

            // Student Investment Net Worth
            double studentInvestmentNetWorth
                = _validator.ValidateMoneyValue(
                      args.StudentInvestmentNetWorth,
                      LabelStudentInvestmentNetWorth,
                      ParamStudentInvestmentNetWorth);

            // Student Business Farm Net Worth
            double studentBusinessFarmNetWorth
                = _validator.ValidateMoneyValue(
                      args.StudentBusinessFarmNetWorth,
                      LabelStudentBusinessFarmNetWorth,
                      ParamStudentBusinessFarmNetWorth);

            // State of Residency
            UnitedStatesStateOrTerritory stateOfResidency
                = _validator.ValidateUnitedStatesStateOrTerritory(
                      args.StateOfResidency,
                      LabelStateOfResidency,
                      ParamStateOfResidency);

            // Number in Household
            int numberInHousehold
                = _validator.ValidateNonZeroInteger(
                      args.NumberInHousehold,
                      LabelNumInHousehold,
                      ParamNumInHousehold);

            // Number in College
            int numberInCollege
                = _validator.ValidateNonZeroInteger(
                      args.NumberInCollege,
                      LabelNumInCollege,
                      ParamNumInCollege);

            // CHECK: If Married, Number in Household must be greater than 3
            if (numberInHousehold > 0 &&
                maritalStatus == MaritalStatus.MarriedRemarried &&
                numberInHousehold < 3)
            {
                _validator.Errors.Add(new ValidationError(ParamNumInHousehold,
                                                          String.Format(@"{0} was ""Married/Remarried"", but {1} was less than three",
                                                                        LabelParentMaritalStatus, LabelNumInHousehold)));
            }
            // CHECK: Number in household must be greater than two
            else if (numberInHousehold > 0 && numberInHousehold < 2)
            {
                _validator.Errors.Add(new ValidationError(ParamNumInHousehold,
                                                          String.Format(@"{0} must equal at least two",
                                                                        LabelNumInHousehold)));
            }

            // CHECK: Number in Household must be greater than or equal to Number in College
            if (numberInCollege > numberInHousehold)
            {
                _validator.Errors.Add(new ValidationError(ParamNumInCollege,
                                                          String.Format(@"{0} must be less than or equal to {1}",
                                                                        LabelNumInCollege, LabelNumInHousehold)));
            }

            // Is Qualified For Simplified?
            bool isQualifiedForSimplified
                = _validator.ValidateBoolean(
                      args.IsQualifiedForSimplified,
                      LabelIsQualifiedForSimplified,
                      ParamIsQualifiedForSimplified);

            // Months of Enrollment
            int monthsOfEnrollment
                = _validator.ValidateNonZeroInteger(
                      args.MonthsOfEnrollment,
                      LabelMonthsOfEnrollment,
                      ParamMonthsOfEnrollment);

            if (_validator.Errors.Count > 0)
            {
                return(null);
            }

            // Build calculation arguments
            DependentEfcCalculatorArguments parsedArgs = new DependentEfcCalculatorArguments
            {
                FirstParent  = firstParent,
                SecondParent = secondParent,
                Student      = student,
                ParentAdjustedGrossIncome      = parentAgi,
                AreParentsTaxFilers            = areParentsTaxFilers,
                ParentIncomeTaxPaid            = parentIncomeTaxPaid,
                ParentUntaxedIncomeAndBenefits = parentUntaxedIncomeAndBenefits,
                ParentAdditionalFinancialInfo  = parentAdditionalFinancialInfo,
                StudentAdjustedGrossIncome     = studentAgi,
                IsStudentTaxFiler               = isStudentTaxFiler,
                StudentIncomeTaxPaid            = studentIncomeTaxPaid,
                StudentUntaxedIncomeAndBenefits = studentUntaxedIncomeAndBenefits,
                StudentAdditionalFinancialInfo  = studentAdditionalFinancialInfo,
                ParentCashSavingsChecking       = parentCashSavingsChecking,
                ParentInvestmentNetWorth        = parentInvestmentNetWorth,
                ParentBusinessFarmNetWorth      = parentBusinessFarmNetWorth,
                StudentCashSavingsChecking      = studentCashSavingsCheckings,
                StudentInvestmentNetWorth       = studentInvestmentNetWorth,
                StudentBusinessFarmNetWorth     = studentBusinessFarmNetWorth,
                MaritalStatus            = maritalStatus,
                StateOfResidency         = stateOfResidency,
                NumberInHousehold        = numberInHousehold,
                NumberInCollege          = numberInCollege,
                OldestParentAge          = oldestParentAge,
                IsQualifiedForSimplified = isQualifiedForSimplified,
                MonthsOfEnrollment       = monthsOfEnrollment
            };

            return(parsedArgs);
        }
Пример #17
0
        public DependentEfcCalculatorArguments ValidateSimpleDependentEfcCalculatorArguments(RawSimpleDependentEfcCalculatorArguments args)
        {
            if (args == null)
            {
                throw new ArgumentException("No raw arguments provided");
            }

            // Marital Status
            MaritalStatus maritalStatus =
                _validator.ValidateMaritalStatus(
                    args.MaritalStatus,
                    LabelParentMaritalStatus,
                    ParamMaritalStatus);

            // Parent Income
            double parentIncome =
                _validator.ValidatePositiveMoneyValue(
                    args.ParentIncome,
                    LabelParentIncome,
                    ParamParentIncome);

            // Parent Other Income
            double parentOtherIncome =
                _validator.ValidatePositiveMoneyValue(
                    args.ParentOtherIncome,
                    LabelParentOtherIncome,
                    ParamParentOtherIncome);

            // Parent Income Earned By
            IncomeEarnedBy incomeEarnedBy =
                _validator.ValidateIncomeEarnedBy(
                    args.ParentIncomeEarnedBy,
                    LabelParentIncomeEarnedBy,
                    ParamParentIncomeEarnedBy);

            // CHECK: If Single/Separated/Divorced, "Parent Income Earned By" can not be "Both"
            if (maritalStatus == MaritalStatus.SingleSeparatedDivorced && incomeEarnedBy == IncomeEarnedBy.Both)
            {
                _validator.Errors.Add(new ValidationError(ParamParentIncomeEarnedBy,
                                                          String.Format(@"{0} was ""Single/Separated/Divorced"", but {1} was marked as earned by both parents",
                                                                        LabelParentMaritalStatus, LabelParentIncomeEarnedBy)));
            }

            // CHECK: If "Parent Income Earned By" is "None", then "Parent Income" must be 0
            if (incomeEarnedBy == IncomeEarnedBy.None && parentIncome > 0)
            {
                _validator.Errors.Add(new ValidationError(ParamParentIncome,
                                                          String.Format(@"{0} was marked as earned by neither parents, but {1} was greater than 0",
                                                                        LabelParentIncomeEarnedBy, LabelParentIncome)));
            }

            // Parent Income Tax Paid
            double parentIncomeTaxPaid =
                _validator.ValidatePositiveMoneyValue(
                    args.ParentIncomeTax,
                    LabelParentIncomeTax,
                    ParamParentIncomeTax);

            // Parent Assets
            double parentAssets =
                _validator.ValidatePositiveMoneyValue(
                    args.ParentAssets,
                    LabelParentAssets,
                    ParamParentAssets);

            // Student Income
            double studentIncome =
                _validator.ValidatePositiveMoneyValue(
                    args.StudentIncome,
                    LabelStudentIncome,
                    ParamStudentIncome);

            // Student Other Income
            double studentOtherIncome =
                _validator.ValidatePositiveMoneyValue(
                    args.StudentOtherIncome,
                    LabelStudentOtherIncome,
                    ParamStudentOtherIncome);

            // Student Income Tax Paid
            double studentIncomeTaxPaid =
                _validator.ValidatePositiveMoneyValue(
                    args.StudentIncomeTax,
                    LabelStudentIncomeTax,
                    ParamStudentIncomeTax);

            // Student Assets
            double studentAssets =
                _validator.ValidatePositiveMoneyValue(
                    args.StudentAssets,
                    LabelStudentAssets,
                    ParamStudentAssets);

            // Number in Household
            int numberInHousehold =
                _validator.ValidateNonZeroInteger(
                    args.NumberInHousehold,
                    LabelNumInHousehold,
                    ParamNumInHousehold);

            // Number in College
            int numberInCollege =
                _validator.ValidateNonZeroInteger(
                    args.NumberInCollege,
                    LabelNumInCollege,
                    ParamNumInCollege);

            // CHECK: Number in Household must be greater than or equal to Number in College
            if (numberInCollege > numberInHousehold)
            {
                _validator.Errors.Add(new ValidationError(ParamNumInCollege,
                                                          String.Format(@"{0} must be less than or equal to {1}",
                                                                        LabelNumInCollege, LabelNumInHousehold)));
            }

            // State of Residency
            UnitedStatesStateOrTerritory stateOfResidency =
                _validator.ValidateUnitedStatesStateOrTerritory(
                    args.StateOfResidency,
                    LabelStateOfResidency,
                    ParamStateOfResidency);

            if (_validator.Errors.Count > 0)
            {
                return(null);
            }

            // Build a list of arguments for the full EFC calculation using assumed
            // values gleaned from the "simplified" values provided

            bool isFirstParentWorking  = false;
            bool isSecondParentWorking = false;

            double firstParentWorkIncome  = 0;
            double secondParentWorkIncome = 0;

            if (incomeEarnedBy == IncomeEarnedBy.One)
            {
                isFirstParentWorking  = true;
                firstParentWorkIncome = parentIncome;
            }

            if (incomeEarnedBy == IncomeEarnedBy.Both)
            {
                isFirstParentWorking  = isSecondParentWorking = true;
                firstParentWorkIncome = secondParentWorkIncome = (parentIncome / 2);
            }

            HouseholdMember firstParent = new HouseholdMember
            {
                IsWorking  = isFirstParentWorking,
                WorkIncome = firstParentWorkIncome
            };

            HouseholdMember secondParent = null;

            if (maritalStatus == MaritalStatus.MarriedRemarried)
            {
                secondParent = new HouseholdMember
                {
                    IsWorking  = isSecondParentWorking,
                    WorkIncome = secondParentWorkIncome
                };
            }

            // ASSUME: Student is working
            HouseholdMember student = new HouseholdMember
            {
                IsWorking  = true,
                WorkIncome = studentIncome
            };

            // Build calculation arguments
            DependentEfcCalculatorArguments parsedArgs = new DependentEfcCalculatorArguments
            {
                FirstParent  = firstParent,
                SecondParent = secondParent,
                Student      = student,

                // ASSUME: "Age of Oldest Parent" is 45
                OldestParentAge = 45,

                // ASSUME: "Parent's AGI" == "Parent's Income"
                ParentAdjustedGrossIncome = parentIncome,

                // ASSUME: Parents are tax filers
                AreParentsTaxFilers = true,

                ParentIncomeTaxPaid = parentIncomeTaxPaid,

                // ASSUME: "Parent's Untaxed Income and Benefits" == "Parent's Other Income"
                ParentUntaxedIncomeAndBenefits = parentOtherIncome,

                // ASSUME: "Parent's Additional Financial Information" is zero
                ParentAdditionalFinancialInfo = 0,

                // ASSUME: "Student's AGI" == "Student's Income"
                StudentAdjustedGrossIncome = studentIncome,

                // ASSUME: Student is a tax filer
                IsStudentTaxFiler = true,

                StudentIncomeTaxPaid = studentIncomeTaxPaid,

                // ASSUME: "Student's Untaxed Income and Benefits" == "Student's Other Income"
                StudentUntaxedIncomeAndBenefits = studentOtherIncome,

                // ASSUME: "Student's Additional Financial Information" is zero
                StudentAdditionalFinancialInfo = 0,

                // ASSUME: "Parent's Cash, Savings, and Checking" == "Parent's Assets"
                ParentCashSavingsChecking = parentAssets,

                // ASSUME: "Parent's Net Worth of Investments" is zero
                ParentInvestmentNetWorth = 0,

                // ASSUME: "Parent's Net Worth of Business and/or Investment Farm" is zero
                ParentBusinessFarmNetWorth = 0,

                // ASSUME: "Student's Cash, Savings, and Checking" == "Student's Assets"
                StudentCashSavingsChecking = studentAssets,

                // ASSUME: "Student's Net Worth of Investments" is zero
                StudentInvestmentNetWorth = 0,

                // ASSUME: "Student's Net Worth of Business and/or Investment Farm" is zero
                StudentBusinessFarmNetWorth = 0,

                MaritalStatus     = maritalStatus,
                StateOfResidency  = stateOfResidency,
                NumberInHousehold = numberInHousehold,
                NumberInCollege   = numberInCollege,

                // ASSUME: Student is NOT qualified for simplified formula
                IsQualifiedForSimplified = false,

                // ASSUME: Nine months of enrollment
                MonthsOfEnrollment = 9
            };

            return(parsedArgs);
        }
        public IndependentEfcCalculatorArguments ValidateIndependentEfcCalculatorArguments(RawIndependentEfcCalculatorArguments args)
        {
            if (args == null)
            {
                throw new ArgumentException("No raw arguments provided");
            }

            // Age
            int age
                = _validator.ValidateNonZeroInteger(
                      args.StudentAge,
                      LabelIndStudentAge,
                      ParamIndStudentAge);

            // Marital Status
            MaritalStatus maritalStatus
                = _validator.ValidateMaritalStatus(
                      args.MaritalStatus,
                      LabelIndStudentMaritalStatus,
                      ParamMaritalStatus);

            // Is Student Working?
            bool isStudentWorking
                = _validator.ValidateBoolean(
                      args.IsStudentWorking,
                      LabelIsStudentWorking,
                      ParamIsStudentWorking);

            // Student Work Income
            double studentWorkIncome
                = isStudentWorking
                        ? _validator.ValidatePositiveMoneyValue(
                      args.StudentWorkIncome,
                      LabelStudentWorkIncome,
                      ParamStudentWorkIncome)
                        : 0;

            HouseholdMember student = new HouseholdMember
            {
                IsWorking  = isStudentWorking,
                WorkIncome = studentWorkIncome
            };

            HouseholdMember spouse = null;

            if (maritalStatus == MaritalStatus.MarriedRemarried)
            {
                // Is Spouse Working?
                bool isSpouseWorking
                    = _validator.ValidateBoolean(
                          args.IsSpouseWorking,
                          LabelIsSpouseWorking,
                          ParamIsSpouseWorking);

                // Spouse Work Income
                double spouseWorkIncome
                    = isSpouseWorking
                            ? _validator.ValidatePositiveMoneyValue(
                          args.SpouseWorkIncome,
                          LabelSpouseWorkIncome,
                          ParamSpouseWorkIncome)
                            : 0;

                spouse = new HouseholdMember
                {
                    IsWorking  = isSpouseWorking,
                    WorkIncome = spouseWorkIncome
                };
            }

            // Student and Spouse's AGI
            double agi = _validator.ValidateMoneyValue(
                args.StudentAgi,
                LabelIndStudentAgi,
                ParamIndStudentAgi);

            // Are Tax Filers?
            bool areTaxFilers
                = _validator.ValidateBoolean(
                      args.IsStudentTaxFiler,
                      LabelIsIndStudentTaxFiler,
                      ParamIsIndStudentTaxFiler);

            // Income Tax Paid
            double incomeTaxPaid
                = _validator.ValidateMoneyValue(
                      args.StudentIncomeTax,
                      LabelIndStudentIncomeTax,
                      ParamIndStudentIncomeTax);

            // Untaxed Income And Benefits
            double untaxedIncomeAndBenefits
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentUntaxedIncomeAndBenefits,
                      LabelIndStudentUntaxedIncomeAndBenefits,
                      ParamIndStudentUntaxedIncomeAndBenefits);

            // Additional Financial Information
            double additionalFinancialInfo
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentAdditionalFinancialInfo,
                      LabelIndStudentAdditionalFinancialInfo,
                      ParamIndStudentAdditionalFinancialInfo);

            // Cash, Savings, Checking
            double cashSavingsChecking
                = _validator.ValidatePositiveMoneyValue(
                      args.StudentCashSavingsChecking,
                      LabelIndStudentCashSavingsChecking,
                      ParamIndStudentCashSavingsChecking);

            // Investment Net Worth
            double investmentNetWorth
                = _validator.ValidateMoneyValue(
                      args.StudentInvestmentNetWorth,
                      LabelIndStudentInvestmentNetWorth,
                      ParamIndStudentInvestmentNetWorth);

            // Business Farm Net Worth
            double businessFarmNetWorth
                = _validator.ValidateMoneyValue(
                      args.StudentBusinessFarmNetWorth,
                      LabelIndStudentBusinessFarmNetWorth,
                      ParamIndStudentBusinessFarmNetWorth);

            // Has Dependents?
            bool hasDependents
                = _validator.ValidateBoolean(
                      args.HasDependents,
                      LabelIndStudentHasDep,
                      ParamIndStudentHasDep);

            // State of Residency
            UnitedStatesStateOrTerritory stateOfResidency
                = _validator.ValidateUnitedStatesStateOrTerritory(
                      args.StateOfResidency,
                      LabelStateOfResidency,
                      ParamStateOfResidency);

            // Number in Household
            int numberInHousehold
                = _validator.ValidateNonZeroInteger(
                      args.NumberInHousehold,
                      LabelNumInHousehold,
                      ParamNumInHousehold);

            // Number in College
            int numberInCollege
                = _validator.ValidateNonZeroInteger(
                      args.NumberInCollege,
                      LabelNumInCollege,
                      ParamNumInCollege);

            // CHECK: Number in Household must be greater than or equal to Number in College
            if (numberInCollege > numberInHousehold)
            {
                _validator.Errors.Add(new ValidationError(ParamNumInCollege,
                                                          String.Format(@"{0} must be less than or equal to {1}",
                                                                        LabelNumInCollege, LabelNumInHousehold)));
            }

            // CHECK: If student has dependents, Number in Household can not be less than two
            if (hasDependents && numberInHousehold < 2)
            {
                _validator.Errors.Add(new ValidationError(ParamIndStudentHasDep,
                                                          String.Format(@"Student has dependents, but {0} was less than two.",
                                                                        LabelNumInHousehold)));
            }

            // Is Qualified for Simplified
            bool isQualifiedForSimplified
                = _validator.ValidateBoolean(
                      args.IsQualifiedForSimplified,
                      LabelIsQualifiedForSimplified,
                      ParamIsQualifiedForSimplified);

            // Months of Enrollment
            int monthsOfEnrollment
                = _validator.ValidateNonZeroInteger(
                      args.MonthsOfEnrollment,
                      LabelMonthsOfEnrollment,
                      ParamMonthsOfEnrollment);

            if (_validator.Errors.Count > 0)
            {
                return(null);
            }

            // Build calculation arguments
            IndependentEfcCalculatorArguments parsedArgs =
                new IndependentEfcCalculatorArguments
            {
                Student                  = student,
                Spouse                   = spouse,
                AdjustedGrossIncome      = agi,
                AreTaxFilers             = areTaxFilers,
                IncomeTaxPaid            = incomeTaxPaid,
                UntaxedIncomeAndBenefits = untaxedIncomeAndBenefits,
                AdditionalFinancialInfo  = additionalFinancialInfo,
                CashSavingsCheckings     = cashSavingsChecking,
                InvestmentNetWorth       = investmentNetWorth,
                BusinessFarmNetWorth     = businessFarmNetWorth,
                HasDependents            = hasDependents,
                MaritalStatus            = maritalStatus,
                StateOfResidency         = stateOfResidency,
                NumberInHousehold        = numberInHousehold,
                NumberInCollege          = numberInCollege,
                Age = age,
                IsQualifiedForSimplified = isQualifiedForSimplified,
                MonthsOfEnrollment       = monthsOfEnrollment
            };

            return(parsedArgs);
        }