Esempio n. 1
0
        public IActionResult Summary(ApplicantDataViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            // obliczenie punktow
            int age = AgeHelper.CountAge(model.BirthDate.Value);
            int pointForAge;

            if (model.SpouseExist == false)
            {
                pointForAge = AgePointsCalculator.CountPointsForAge(age);
            }
            else
            {
                pointForAge = AgePointsCalculator.CountPointsForAgeWithSpouse(age);
            }


            int pointForEducation;

            if (model.SpouseExist == false)
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducation(model.EducationLevel);
            }
            else
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducationWithSpouse(model.EducationLevel);
            }

            LanguagePoints primaryAplicantFirstLangPoints;

            if (model.TypeOfFirstExam.HasValue)
            {
                var firstExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfFirstExam.Value);
                primaryAplicantFirstLangPoints = new LanguagePoints(firstExamType, model.SpeakingPoints, model.WritingPoints, model.ReadingPoints, model.ListeningPoints);
            }
            else
            {
                primaryAplicantFirstLangPoints = new LanguagePoints();
            }

            int pointsForSpeaking;
            int pointsForWriting;
            int pointsForReading;
            int pointsForListening;
            int pointsForLanguage;

            if (model.SpouseExist == false)
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            else
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            pointsForLanguage = pointsForSpeaking + pointsForWriting + pointsForReading + pointsForListening;

            var            secondExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSecondExam);
            LanguagePoints primaryAplicantSecondLangPoints = new LanguagePoints(secondExamType, model.SpeakingPointsSecondLanguage, model.WritingPointsSecondLanguage, model.ReadingPointsSecondLanguage, model.ListeningPointsSecondLanguage);

            int pointsForSecondLangSpeaking;
            int pointsForSecondLangWriting;;
            int pointsForSecondLangReading;
            int pointsForSecondLangListening;
            int pointsForSecondLanguage;

            pointsForSecondLangSpeaking  = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBSpeakingPoints);
            pointsForSecondLangWriting   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBWritingPoints);
            pointsForSecondLangReading   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBReadingPoints);
            pointsForSecondLangListening = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBListeningPoints);

            pointsForSecondLanguage = pointsForSecondLangSpeaking + pointsForSecondLangWriting + pointsForSecondLangReading + pointsForSecondLangListening;

            int pointsForExperience;

            if (model.SpouseExist == false)
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithoutSpouse(model.CanadianExperience);
            }
            else
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithSpouse(model.CanadianExperience);
            }

            int sectionA = pointForAge + pointForEducation + pointsForLanguage + pointsForSecondLanguage + pointsForExperience;

            int pointsForSpouseEducation;

            pointsForSpouseEducation = EducationPointsCalculator.CountPointsForSpouseEducation(model.SpouseEducationLevel);

            LanguagePoints spouseFirstLangPoints;

            if (model.TypeOfSpouseExam.HasValue)
            {
                var spouseExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSpouseExam.Value);
                spouseFirstLangPoints = new LanguagePoints(spouseExamType, model.SpouseSpeakingPoints, model.SpouseWritingPoints, model.SpouseReadingPoints, model.SpouseListeningPoints);
            }
            else
            {
                spouseFirstLangPoints = new LanguagePoints();
            }

            int pointsForSpouseSpeaking;
            int pointsForSpouseWriting;
            int pointsForSpouseReading;
            int pointsForSpouseListening;
            int pointsForSpouseLanguage;

            pointsForSpouseSpeaking  = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBSpeakingPoints);
            pointsForSpouseWriting   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBWritingPoints);
            pointsForSpouseReading   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBReadingPoints);
            pointsForSpouseListening = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBListeningPoints);

            pointsForSpouseLanguage = pointsForSpouseSpeaking + pointsForSpouseWriting + pointsForSpouseReading + pointsForSpouseListening;

            int pointsForSpouseExperience;

            pointsForSpouseExperience = ExperiencePointsCalculator.CountPointsForSpouseExperience(model.SpouseCanadianExperience);

            int sectionB = pointsForSpouseEducation + pointsForSpouseLanguage + pointsForSpouseExperience;

            int sectionC;

            sectionC = SkillTransferabilityFactorsCalculator.CalculateSkillTransferabilityFactorsPoints(primaryAplicantFirstLangPoints, model.EducationLevel, model.CanadianExperience, model.ExperienceOutsideCanada);

            int sectionD;

            int canadianFamilyMemberPoints       = AdditionalPointsCalculator.GiveAdditionalPoints(model.CanadianFamilyMember);
            int canadianEducationPoints          = AdditionalPointsCalculator.CanadianEducationPoints(model.CanadianEducation);
            int canadianArrangedEmploymentPoints = AdditionalPointsCalculator.CalculatePointsForArrangementEmployment(model.CanadianArrangedEmployment);
            int canadianProvincialOrTerritorialNominationPoints = AdditionalPointsCalculator.GiveAdditionalPointsForProvincialOrTerritorialNomination(model.CanadianProvincialOrTerritorialNomination);
            int additionalLanguagePoints = 0;

            if (primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TEF)
            {
                additionalLanguagePoints = AdditionalPointsCalculator.GiveAdditionalPointsForLanguages(primaryAplicantFirstLangPoints, primaryAplicantSecondLangPoints);
            }
            sectionD = canadianFamilyMemberPoints + canadianEducationPoints + canadianArrangedEmploymentPoints + canadianProvincialOrTerritorialNominationPoints + additionalLanguagePoints;


            int totalPointsForExpressEntry;

            totalPointsForExpressEntry = sectionA + sectionB + sectionC + sectionD;


            PointsSummaryViewModel points = new PointsSummaryViewModel();

            points.PointsForAge                = pointForAge;
            points.PointsForEducation          = pointForEducation;
            points.PointsForFirstLanguage      = pointsForLanguage;
            points.PointsForSecondLanguage     = pointsForSecondLanguage;
            points.PointsForCanadianExperience = pointsForExperience;
            points.PointsInSectionA            = sectionA;

            points.PointsForSpouseEducation          = pointsForSpouseEducation;
            points.PointsForSpouseLanguageExam       = pointsForSpouseLanguage;
            points.PointsForSpouseCanadianExperience = pointsForSpouseExperience;
            points.PointsInSectionB = sectionB;

            points.PointsInSectionC = sectionC;

            points.PointsInSectionD = sectionD;

            points.TotalPointsForExpressEntry = totalPointsForExpressEntry;
            points.LastExpressEntryStats      = _expressEntryStats;

            return(View(points));
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            DisplayMessage("Please provide your first name.");
            string firstname = System.Console.ReadLine();

            DisplayMessage("Please provide your last name.");
            string lastname = System.Console.ReadLine();

            DateTime parsedDateOfBirth;
            string   dateOfBirth;

            bool isFirstAttempt = true;

            do
            {
                if (!isFirstAttempt)
                {
                    DisplayMessage("Wrong date format. Please try again.", ConsoleColor.Red);
                }
                DisplayMessage("Please provide your date of birth (required format: yyyy-mm-dd).");
                dateOfBirth = System.Console.ReadLine();

                isFirstAttempt = false;
            }while (DateTime.TryParse(dateOfBirth, out parsedDateOfBirth) == false);

            int age = AgeHelper.CountAge(parsedDateOfBirth);

            DisplayMessage("Please provide fullname your spouse or common - law partner if exist.");
            string spouseFullname = System.Console.ReadLine();
            bool   noSpouse       = String.IsNullOrWhiteSpace(spouseFullname);

            int pointForAge;

            if (noSpouse == true)
            {
                pointForAge = AgePointsCalculator.CountPointsForAge(age);
            }
            else
            {
                pointForAge = AgePointsCalculator.CountPointsForAgeWithSpouse(age);
            }
            DisplayMessage("Points for age: " + pointForAge.ToString(), ConsoleColor.Green);

            DisplayMessage("Please select the level of your education (enter the number from 1 to 8).");

            ushort educationLevel = GetEducationalLevel();

            int pointForEducation;

            if (noSpouse == true)
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducation(educationLevel);
            }
            else
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducationWithSpouse(educationLevel);
            }
            DisplayMessage("Points for education: " + pointForEducation.ToString(), ConsoleColor.Green);

            LanguagePoints primaryAplicantFirstLangPoints = SetAndCalculateLanguagePoints();

            int pointsForSpeaking;
            int pointsForWriting;
            int pointsForReading;
            int pointsForListening;
            int pointsForLanguage;

            if (noSpouse == true)
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            else
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            pointsForLanguage = pointsForSpeaking + pointsForWriting + pointsForReading + pointsForListening;
            DisplayMessage("Points for 1st language: " + pointsForLanguage.ToString(), ConsoleColor.Green);


            DisplayMessage("Did you pass second language exam? (YES or NO).");
            string         secondLanguage                  = System.Console.ReadLine();
            int            pointsForSecondLanguage         = 0;
            LanguagePoints primaryAplicantSecondLangPoints = null;

            if (secondLanguage.ToUpper() == "YES")
            {
                primaryAplicantSecondLangPoints = SetAndCalculateLanguagePoints();


                int pointsForSecondLangSpeaking;
                int pointsForSecondLangWriting;
                int pointsForSecondLangReading;
                int pointsForSecondLangListening;

                pointsForSecondLangSpeaking  = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBSpeakingPoints);
                pointsForSecondLangWriting   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBWritingPoints);
                pointsForSecondLangReading   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBReadingPoints);
                pointsForSecondLangListening = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBListeningPoints);

                pointsForSecondLanguage = pointsForSecondLangSpeaking + pointsForSecondLangWriting + pointsForSecondLangReading + pointsForSecondLangListening;
                DisplayMessage("Point for second language: " + pointsForSecondLanguage.ToString(), ConsoleColor.Green);
            }
            else
            {
                DisplayMessage("No points for the second language.", ConsoleColor.Green);
            }

            isFirstAttempt = true;
            string experienceTime;
            int    parsedExperienceTime;

            do
            {
                if (!isFirstAttempt)
                {
                    DisplayMessage("Wrong value. Please try again.", ConsoleColor.Red);
                }
                DisplayMessage("How many years of work experience do you have in the Canadian labour market? (warning!: The year of experience is calculated after having completed the full year worked. If you have worked less than a year, enter 0. There is no rounding up).");
                experienceTime = System.Console.ReadLine();

                isFirstAttempt = false;
            }while (Int32.TryParse(experienceTime, out parsedExperienceTime) == false);

            int pointsForExperience;

            if (noSpouse == true)
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithoutSpouse(parsedExperienceTime);
            }
            else
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithSpouse(parsedExperienceTime);
            }
            DisplayMessage("Points for experience: " + pointsForExperience.ToString(), ConsoleColor.Green);

            int totalPointsForHumanCapitalFactors;

            totalPointsForHumanCapitalFactors = pointForAge + pointForEducation + pointsForLanguage + pointsForSecondLanguage + pointsForExperience;
            DisplayMessage("Points earned by you: " + totalPointsForHumanCapitalFactors.ToString(), ConsoleColor.Cyan);

            int totalPointsForSpouseOrCommonLawPartnerFactors = 0;

            if (noSpouse == true)
            {
                DisplayMessage("No points earned by spouse or common-law partner.", ConsoleColor.Cyan);
            }
            else
            {
                DisplayMessage("Please select the level of education of spouse or common-law partner (enter the number from 1 to 8).");
                ushort spouseEducationLevel = GetEducationalLevel();
                int    pointsForSpouseEducation;
                pointsForSpouseEducation = EducationPointsCalculator.CountPointsForSpouseEducation(spouseEducationLevel);
                DisplayMessage("Points for education of spouse or common-law partner: " + pointsForSpouseEducation.ToString(), ConsoleColor.Green);

                LanguagePoints spouseFirstLangPoints = SetAndCalculateLanguagePoints();

                int pointsForSpouseSpeaking;
                int pointsForSpouseWriting;
                int pointsForSpouseReading;
                int pointsForSpouseListening;
                int pointsForSpouseLanguage;

                pointsForSpouseSpeaking  = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBSpeakingPoints);
                pointsForSpouseWriting   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBWritingPoints);
                pointsForSpouseReading   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBReadingPoints);
                pointsForSpouseListening = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBListeningPoints);

                pointsForSpouseLanguage = pointsForSpouseSpeaking + pointsForSpouseWriting + pointsForSpouseReading + pointsForSpouseListening;
                DisplayMessage("Points for language of spouse or common-law partner: " + pointsForSpouseLanguage.ToString(), ConsoleColor.Green);

                isFirstAttempt = true;
                int parsedSpouseExperienceTime;
                int pointsForSpouseExperience;
                do
                {
                    if (!isFirstAttempt)
                    {
                        DisplayMessage("Wrong value. Please try again.", ConsoleColor.Red);
                    }
                    DisplayMessage("How many years of work experience in the Canadian labour market has your spouse or common-law partner? (warning!: The year of experience is calculated after having completed the full year worked. If your spouse or common-law partner has worked less than a year, enter 0. There is no rounding up).");
                    string spouseExperienceTime = System.Console.ReadLine();

                    isFirstAttempt = false;
                }while (Int32.TryParse(experienceTime, out parsedSpouseExperienceTime) == false);

                pointsForSpouseExperience = ExperiencePointsCalculator.CountPointsForSpouseExperience(parsedSpouseExperienceTime);

                DisplayMessage("Points for spouse experience: " + pointsForSpouseExperience.ToString(), ConsoleColor.Green);

                totalPointsForSpouseOrCommonLawPartnerFactors = pointsForSpouseEducation + pointsForSpouseLanguage + pointsForSpouseExperience;
                DisplayMessage("Points earned by spouse or common-law partner: " + totalPointsForSpouseOrCommonLawPartnerFactors.ToString(), ConsoleColor.Cyan);
            }

            isFirstAttempt = true;
            string foreignExperienceTime;
            int    parsedForeignExperienceTime = 0;

            do
            {
                if (!isFirstAttempt)
                {
                    DisplayMessage("Wrong value. Please try again.", ConsoleColor.Red);
                }
                DisplayMessage("How many years of foreign work experiencein (outside Canada) do you have? (warning!: The year of experience is calculated after having completed the full year worked. If your spouse or common-law partner has worked less than a year, enter 0. There is no rounding up).");
                foreignExperienceTime = System.Console.ReadLine();

                isFirstAttempt = false;
            }while (Int32.TryParse(foreignExperienceTime, out parsedForeignExperienceTime) == false);


            int pointsForSkillTransferabilityFactors;

            pointsForSkillTransferabilityFactors = SkillTransferabilityFactorsCalculator.CalculateSkillTransferabilityFactorsPoints(primaryAplicantFirstLangPoints, educationLevel, parsedExperienceTime, parsedForeignExperienceTime);
            DisplayMessage("Points for skill transferability factor: " + pointsForSkillTransferabilityFactors.ToString(), ConsoleColor.Cyan);


            DisplayMessage("Does your brother or sister who is a citizen or permanent resident of Canada live in Canada? (YES or NO).");
            string canadianFamilyMember       = System.Console.ReadLine();
            int    canadianFamilyMemberPoints = AdditionalPointsCalculator.GiveAdditionalPoints(canadianFamilyMember);

            DisplayMessage("Have you graduated post-secondary education in Canada - credential of one or two years (YES or NO).");
            string canadianEducation       = System.Console.ReadLine();
            int    canadianEducationPoints = AdditionalPointsCalculator.GiveAdditionalPoints(canadianEducation);

            DisplayMessage("Have you graduated post-secondary education in Canada - credential three years or longer (YES or NO).");
            string canadianLongerEducation       = System.Console.ReadLine();
            int    canadianLongerEducationPoints = AdditionalPointsCalculator.GiveDoubleAdditionalPoints(canadianLongerEducation);

            DisplayMessage("Do you have arranged employment – any other NOC 0, A or B (YES or NO).");
            string canadianArrangedEmployment       = System.Console.ReadLine();
            int    canadianArrangedEmploymentPoints = AdditionalPointsCalculator.GiveAdditionalPointsForArrangedEmployment(canadianArrangedEmployment);

            DisplayMessage("Do you have arranged employment – any other NOC 00 (YES or NO).");
            string canadianArrangedEmploymentPlus       = System.Console.ReadLine();
            int    canadianArrangedEmploymentPlusPoints = AdditionalPointsCalculator.GiveMoreAdditionalPointsForArrangedEmployment(canadianArrangedEmploymentPlus);

            DisplayMessage("Have you got provincial or territorial nomination? (YES or NO).");
            string canadianProvincialOrTerritorialNomination       = System.Console.ReadLine();
            int    canadianProvincialOrTerritorialNominationPoints = AdditionalPointsCalculator.GiveAdditionalPointsForProvincialOrTerritorialNomination(canadianProvincialOrTerritorialNomination);


            int additionalLanguagePoints = 0;

            if (primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TEF)
            {
                additionalLanguagePoints = AdditionalPointsCalculator.GiveAdditionalPointsForLanguages(primaryAplicantFirstLangPoints, primaryAplicantSecondLangPoints);
            }

            int additionalPoints;

            additionalPoints = canadianFamilyMemberPoints + canadianEducationPoints + canadianLongerEducationPoints + canadianArrangedEmploymentPoints + canadianArrangedEmploymentPlusPoints + canadianProvincialOrTerritorialNominationPoints + additionalLanguagePoints;
            DisplayMessage("Additional points: " + additionalPoints.ToString(), ConsoleColor.Cyan);

            int totalPointsForExpressEntry;

            totalPointsForExpressEntry = totalPointsForHumanCapitalFactors + totalPointsForSpouseOrCommonLawPartnerFactors + pointsForSkillTransferabilityFactors + additionalPoints;
            DisplayMessage("Total points for Express Entry: " + totalPointsForExpressEntry.ToString(), ConsoleColor.Blue);

            Console.Read();
        }
        public async Task <IActionResult> Run(
            [HttpTrigger(AuthorizationLevel.Anonymous, "post", Route = null)] HttpRequest req,
            ILogger log)
        {
            log.LogInformation("C# HTTP trigger function processed a request.");

            string requestBody = new StreamReader(req.Body).ReadToEnd();

            var model = JsonConvert.DeserializeObject <ApplicantDataViewModel>(requestBody);

            // TODO:DK validation to return 400?
            //if (!ModelState.IsValid)
            //{
            //    return View("Index", model);
            //}

            int age = AgeHelper.CountAge(model.BirthDate.Value, _systemTime.UtcNow);
            int pointForAge;

            if (model.SpouseExist == false)
            {
                pointForAge = AgePointsCalculator.CountPointsForAge(age);
            }
            else
            {
                pointForAge = AgePointsCalculator.CountPointsForAgeWithSpouse(age);
            }


            int pointForEducation;

            if (model.SpouseExist == false)
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducation(model.EducationLevel);
            }
            else
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducationWithSpouse(model.EducationLevel);
            }

            LanguagePoints primaryAplicantFirstLangPoints;

            if (model.TypeOfFirstExam.HasValue)
            {
                var firstExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfFirstExam.Value);
                primaryAplicantFirstLangPoints = new LanguagePoints(firstExamType, model.SpeakingPoints, model.WritingPoints, model.ReadingPoints, model.ListeningPoints);
            }
            else
            {
                primaryAplicantFirstLangPoints = new LanguagePoints();
            }

            int pointsForSpeaking;
            int pointsForWriting;
            int pointsForReading;
            int pointsForListening;
            int pointsForLanguage;

            if (model.SpouseExist == false)
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            else
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            pointsForLanguage = pointsForSpeaking + pointsForWriting + pointsForReading + pointsForListening;

            var            secondExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSecondExam);
            LanguagePoints primaryAplicantSecondLangPoints = new LanguagePoints(secondExamType, model.SpeakingPointsSecondLanguage, model.WritingPointsSecondLanguage, model.ReadingPointsSecondLanguage, model.ListeningPointsSecondLanguage);

            int pointsForSecondLangSpeaking;
            int pointsForSecondLangWriting;;
            int pointsForSecondLangReading;
            int pointsForSecondLangListening;
            int pointsForSecondLanguage;

            pointsForSecondLangSpeaking  = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBSpeakingPoints);
            pointsForSecondLangWriting   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBWritingPoints);
            pointsForSecondLangReading   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBReadingPoints);
            pointsForSecondLangListening = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBListeningPoints);

            pointsForSecondLanguage = pointsForSecondLangSpeaking + pointsForSecondLangWriting + pointsForSecondLangReading + pointsForSecondLangListening;

            int pointsForExperience;

            if (model.SpouseExist == false)
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithoutSpouse(model.CanadianExperience);
            }
            else
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithSpouse(model.CanadianExperience);
            }

            int sectionA = pointForAge + pointForEducation + pointsForLanguage + pointsForSecondLanguage + pointsForExperience;

            int pointsForSpouseEducation  = 0;
            int pointsForSpouseSpeaking   = 0;
            int pointsForSpouseWriting    = 0;
            int pointsForSpouseReading    = 0;
            int pointsForSpouseListening  = 0;
            int pointsForSpouseLanguage   = 0;
            int pointsForSpouseExperience = 0;

            if (model.SpouseExist)
            {
                pointsForSpouseEducation = EducationPointsCalculator.CountPointsForSpouseEducation(model.SpouseEducationLevel);

                LanguagePoints spouseFirstLangPoints;

                if (model.TypeOfSpouseExam.HasValue)
                {
                    var spouseExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSpouseExam.Value);
                    spouseFirstLangPoints = new LanguagePoints(spouseExamType, model.SpouseSpeakingPoints, model.SpouseWritingPoints, model.SpouseReadingPoints, model.SpouseListeningPoints);
                }
                else
                {
                    spouseFirstLangPoints = new LanguagePoints();
                }

                pointsForSpouseSpeaking  = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBSpeakingPoints);
                pointsForSpouseWriting   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBWritingPoints);
                pointsForSpouseReading   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBReadingPoints);
                pointsForSpouseListening = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBListeningPoints);

                pointsForSpouseLanguage   = pointsForSpouseSpeaking + pointsForSpouseWriting + pointsForSpouseReading + pointsForSpouseListening;
                pointsForSpouseExperience = ExperiencePointsCalculator.CountPointsForSpouseExperience(model.SpouseCanadianExperience);
            }

            int sectionB = pointsForSpouseEducation + pointsForSpouseLanguage + pointsForSpouseExperience;

            int sectionC;

            sectionC = SkillTransferabilityFactorsCalculator.CalculateSkillTransferabilityFactorsPoints(primaryAplicantFirstLangPoints, model.EducationLevel, model.CanadianExperience, model.ExperienceOutsideCanada);

            int sectionD;

            int canadianFamilyMemberPoints       = AdditionalPointsCalculator.GiveAdditionalPoints(model.CanadianFamilyMember);
            int canadianEducationPoints          = AdditionalPointsCalculator.CanadianEducationPoints(model.CanadianEducation);
            int canadianArrangedEmploymentPoints = AdditionalPointsCalculator.CalculatePointsForArrangementEmployment(model.CanadianArrangedEmployment);
            int canadianProvincialOrTerritorialNominationPoints = AdditionalPointsCalculator.GiveAdditionalPointsForProvincialOrTerritorialNomination(model.CanadianProvincialOrTerritorialNomination);
            int additionalLanguagePoints = 0;

            if (primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TEF ||
                primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TCF)
            {
                additionalLanguagePoints = AdditionalPointsCalculator.GiveAdditionalPointsForLanguages(primaryAplicantFirstLangPoints, primaryAplicantSecondLangPoints);
            }
            sectionD = canadianFamilyMemberPoints + canadianEducationPoints + canadianArrangedEmploymentPoints + canadianProvincialOrTerritorialNominationPoints + additionalLanguagePoints;

            int totalPointsForExpressEntry;

            totalPointsForExpressEntry = sectionA + sectionB + sectionC + sectionD;

            PointsSummaryViewModel points = new PointsSummaryViewModel();

            points.PointsForAge                      = pointForAge;
            points.PointsForEducation                = pointForEducation;
            points.PointsForFirstLanguage            = pointsForLanguage;
            points.PointsForSecondLanguage           = pointsForSecondLanguage;
            points.PointsForCanadianExperience       = pointsForExperience;
            points.PointsInSectionA                  = sectionA;
            points.PointsForSpouseEducation          = pointsForSpouseEducation;
            points.PointsForSpouseLanguageExam       = pointsForSpouseLanguage;
            points.PointsForSpouseCanadianExperience = pointsForSpouseExperience;
            points.PointsInSectionB                  = sectionB;
            points.PointsInSectionC                  = sectionC;
            points.PointsInSectionD                  = sectionD;
            points.TotalPointsForExpressEntry        = totalPointsForExpressEntry;

            return(await Task.FromResult(new OkObjectResult(points)));
        }
        public IActionResult Summary(ApplicantDataViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View("Index", model));
            }

            // save model to temp data
            // by clicking browser's back button user expects to see form populated with data
            // so user can quickly change one/more form params and calculate again
            // need to serialize model because TempData can't serialize complex objects
            TempData[APPLICANT_DATA_MODEL_KEY] = JsonConvert.SerializeObject(model);

            // obliczenie punktow
            int age = AgeHelper.CountAge(model.BirthDate.Value);
            int pointForAge;

            if (model.SpouseExist == false)
            {
                pointForAge = AgePointsCalculator.CountPointsForAge(age);
            }
            else
            {
                pointForAge = AgePointsCalculator.CountPointsForAgeWithSpouse(age);
            }


            int pointForEducation;

            if (model.SpouseExist == false)
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducation(model.EducationLevel);
            }
            else
            {
                pointForEducation = EducationPointsCalculator.CountPointsForEducationWithSpouse(model.EducationLevel);
            }

            LanguagePoints primaryAplicantFirstLangPoints;

            if (model.TypeOfFirstExam.HasValue)
            {
                var firstExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfFirstExam.Value);
                primaryAplicantFirstLangPoints = new LanguagePoints(firstExamType, model.SpeakingPoints, model.WritingPoints, model.ReadingPoints, model.ListeningPoints);
            }
            else
            {
                primaryAplicantFirstLangPoints = new LanguagePoints();
            }

            int pointsForSpeaking;
            int pointsForWriting;
            int pointsForReading;
            int pointsForListening;
            int pointsForLanguage;

            if (model.SpouseExist == false)
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithoutSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            else
            {
                pointsForSpeaking  = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBSpeakingPoints);
                pointsForWriting   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBWritingPoints);
                pointsForReading   = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBReadingPoints);
                pointsForListening = LanguagePointsCalculator.LanguagePointsCalculatorWithSpouse(primaryAplicantFirstLangPoints.CLBListeningPoints);
            }
            pointsForLanguage = pointsForSpeaking + pointsForWriting + pointsForReading + pointsForListening;

            var            secondExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSecondExam);
            LanguagePoints primaryAplicantSecondLangPoints = new LanguagePoints(secondExamType, model.SpeakingPointsSecondLanguage, model.WritingPointsSecondLanguage, model.ReadingPointsSecondLanguage, model.ListeningPointsSecondLanguage);

            int pointsForSecondLangSpeaking;
            int pointsForSecondLangWriting;;
            int pointsForSecondLangReading;
            int pointsForSecondLangListening;
            int pointsForSecondLanguage;

            pointsForSecondLangSpeaking  = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBSpeakingPoints);
            pointsForSecondLangWriting   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBWritingPoints);
            pointsForSecondLangReading   = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBReadingPoints);
            pointsForSecondLangListening = SecondLanguagePointsCalculator.SecondLangPointsCalculator(primaryAplicantSecondLangPoints.CLBListeningPoints);

            pointsForSecondLanguage = pointsForSecondLangSpeaking + pointsForSecondLangWriting + pointsForSecondLangReading + pointsForSecondLangListening;

            int pointsForExperience;

            if (model.SpouseExist == false)
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithoutSpouse(model.CanadianExperience);
            }
            else
            {
                pointsForExperience = ExperiencePointsCalculator.CountPointsForExperienceWithSpouse(model.CanadianExperience);
            }

            int sectionA = pointForAge + pointForEducation + pointsForLanguage + pointsForSecondLanguage + pointsForExperience;

            int pointsForSpouseEducation  = 0;
            int pointsForSpouseSpeaking   = 0;
            int pointsForSpouseWriting    = 0;
            int pointsForSpouseReading    = 0;
            int pointsForSpouseListening  = 0;
            int pointsForSpouseLanguage   = 0;
            int pointsForSpouseExperience = 0;

            if (model.SpouseExist)
            {
                pointsForSpouseEducation = EducationPointsCalculator.CountPointsForSpouseEducation(model.SpouseEducationLevel);

                LanguagePoints spouseFirstLangPoints;

                if (model.TypeOfSpouseExam.HasValue)
                {
                    var spouseExamType = LanguagePoints.IdentifyingTheTypeOfExam(model.TypeOfSpouseExam.Value);
                    spouseFirstLangPoints = new LanguagePoints(spouseExamType, model.SpouseSpeakingPoints, model.SpouseWritingPoints, model.SpouseReadingPoints, model.SpouseListeningPoints);
                }
                else
                {
                    spouseFirstLangPoints = new LanguagePoints();
                }

                pointsForSpouseSpeaking  = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBSpeakingPoints);
                pointsForSpouseWriting   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBWritingPoints);
                pointsForSpouseReading   = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBReadingPoints);
                pointsForSpouseListening = LanguagePointsCalculator.CalculatorOfSpouseLanguagePoints(spouseFirstLangPoints.CLBListeningPoints);

                pointsForSpouseLanguage   = pointsForSpouseSpeaking + pointsForSpouseWriting + pointsForSpouseReading + pointsForSpouseListening;
                pointsForSpouseExperience = ExperiencePointsCalculator.CountPointsForSpouseExperience(model.SpouseCanadianExperience);
            }

            int sectionB = pointsForSpouseEducation + pointsForSpouseLanguage + pointsForSpouseExperience;

            int sectionC;

            sectionC = SkillTransferabilityFactorsCalculator.CalculateSkillTransferabilityFactorsPoints(primaryAplicantFirstLangPoints, model.EducationLevel, model.CanadianExperience, model.ExperienceOutsideCanada);

            int sectionD;

            int canadianFamilyMemberPoints       = AdditionalPointsCalculator.GiveAdditionalPoints(model.CanadianFamilyMember);
            int canadianEducationPoints          = AdditionalPointsCalculator.CanadianEducationPoints(model.CanadianEducation);
            int canadianArrangedEmploymentPoints = AdditionalPointsCalculator.CalculatePointsForArrangementEmployment(model.CanadianArrangedEmployment);
            int canadianProvincialOrTerritorialNominationPoints = AdditionalPointsCalculator.GiveAdditionalPointsForProvincialOrTerritorialNomination(model.CanadianProvincialOrTerritorialNomination);
            int additionalLanguagePoints = 0;

            if (primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TEF ||
                primaryAplicantFirstLangPoints.LanguageExamType == LanguagePoints.LanguageExamTypes.TCF)
            {
                additionalLanguagePoints = AdditionalPointsCalculator.GiveAdditionalPointsForLanguages(primaryAplicantFirstLangPoints, primaryAplicantSecondLangPoints);
            }
            sectionD = canadianFamilyMemberPoints + canadianEducationPoints + canadianArrangedEmploymentPoints + canadianProvincialOrTerritorialNominationPoints + additionalLanguagePoints;

            int totalPointsForExpressEntry;

            totalPointsForExpressEntry = sectionA + sectionB + sectionC + sectionD;

            PointsSummaryViewModel points = new PointsSummaryViewModel();

            points.PointsForAge                      = pointForAge;
            points.PointsForEducation                = pointForEducation;
            points.PointsForFirstLanguage            = pointsForLanguage;
            points.PointsForSecondLanguage           = pointsForSecondLanguage;
            points.PointsForCanadianExperience       = pointsForExperience;
            points.PointsInSectionA                  = sectionA;
            points.PointsForSpouseEducation          = pointsForSpouseEducation;
            points.PointsForSpouseLanguageExam       = pointsForSpouseLanguage;
            points.PointsForSpouseCanadianExperience = pointsForSpouseExperience;
            points.PointsInSectionB                  = sectionB;
            points.PointsInSectionC                  = sectionC;
            points.PointsInSectionD                  = sectionD;
            points.TotalPointsForExpressEntry        = totalPointsForExpressEntry;
            points.LastExpressEntryStats             = _expressEntryStats;

            return(View(points));
        }