Пример #1
0
        public static string GetPeriodeString(DateTime debut, DateTime end)
        {
            var days = new AgeHelper(debut, end);

            if (days.Years == 0)
            {
                if (days.Months == 0 && days.TotalDays > 0)
                {
                    return($"{days.Days} {_("jours")}");
                }
                else if (days.TotalDays == 0)
                {
                    return(_($"Aujourd'hui"));
                }
                else
                {
                    return($"{days.Months} {_("mois")},{days.Days} {_("jours")}");
                }
            }
            else
            {
                return($"{days.Years} {_("ans")} et {days.Months} {_("mois")}");
            }

            return("");
        }
Пример #2
0
        /// <summary>
        /// Load using Preview information..
        /// </summary>
        /// <param name="selectedMovieInfo"></param>
        public void LoadMovieInfo(ref TmdbWrapper.Movies.Movie selectedMovieInfo)
        {
            lblTitle.Text = selectedMovieInfo.Title;
            if (selectedMovieInfo.ReleaseDate.HasValue)
            {
                lblReleaseDate.Text  = selectedMovieInfo.ReleaseDate.Value.ToShortDateString();
                lblReleaseDate.Text += AgeHelper.GetReleaseDateDelta(selectedMovieInfo.ReleaseDate.Value);
            }
            else
            {
                lblReleaseDate.Text = "TBD";
            }
            lblRunTime.Text = selectedMovieInfo.Runtime.ToString() + " minutes";
            lblRevenue.Text = selectedMovieInfo.Revenue.ToString("C0"); // Currency no cents.
            if (selectedMovieInfo.Homepage != null)
            {
                pbPoster.Tag = selectedMovieInfo.Homepage.AbsoluteUri;
            }
            else
            {
                pbPoster.Tag = null;
            }
            GetMoviePoster(ref selectedMovieInfo);
            //TmdbWrapper.Movies.ProductionCompany
            IReadOnlyList <TmdbWrapper.Movies.ProductionCompany> prodCos = selectedMovieInfo.ProductionCompanies;

            GetProductionCompanyLogos(prodCos);
        }
Пример #3
0
        private async void doWork()
        {
            //Check to see if the person has all available information
            if (!p.Updated)
            {
                p = await asyncUpdatePerson(p);
            }

            pbProfile.BackgroundImage = p.GetProfileImage(TmdbWrapper.Utilities.ProfileSize.w185);

            //Find Character(s !!!) this person played // BUG if Person played more than one Character in the selected Movie
            HashSet <Character> cpba = u.GetCharactersPlayedByActor(p.Id, selectedMovie.TmdbId);
            Character           c    = cpba.FirstOrDefault();
            //TODO - Look for CharacterID after translating to them
            String tnPath = PrivateData.GetAppPath() + @"\Cache\Images\Characters\tn_" + c.Name.Replace("/", "") + ".png";
            String piath  = PrivateData.GetAppPath() + @"\Cache\Images\Characters\pi_" + c.Name.Replace("/", "") + ".png";

            if (File.Exists(tnPath))
            {
                pbRole.BackgroundImage = Image.FromFile(tnPath);
            }
            else
            {
                pbRole.BackgroundImage = null;
            }
            if (File.Exists(piath))
            {
                pbRoleProfile.BackgroundImage = Image.FromFile(piath);
            }
            else
            {
                pbRoleProfile.BackgroundImage = null;
            }
            lblRole.Text = c.OriginalCharacterName;// .Name;
            lblName.Text = p.Name;
            if (p.Deathday != null)
            {
                if (p.Birthday.HasValue && p.Deathday.HasValue)
                {
                    DateTime deathDay = p.Deathday.Value.Date;
                    lblBirthday.Text  = p.Birthday.Value.ToShortDateString() + " - " + deathDay.ToShortDateString();
                    lblBirthday.Text += AgeHelper.GetAgeDelta(p.Birthday.Value, deathDay);
                }
            }
            else
            {
                if (p.Birthday.HasValue)
                {
                    lblBirthday.Text  = p.Birthday.Value.Date.ToShortDateString();
                    lblBirthday.Text += AgeHelper.GetAgeDelta(p.Birthday.Value);
                }
                else
                {
                    lblBirthday.Text = "";
                }
            }
            lblPlaceOfBirth.Text = p.PlaceOfBirth;
            lblBiography.Text    = p.Biography;
        }
Пример #4
0
        /// <summary>
        /// Create dropdown list for Employees without account
        /// </summary>
        private SelectList CreateEmployeesWithoutAccountDropDownList()
        {
            var employeesWithoutAccount = from e in context.Employees
                                          where !context.Users.Any(u => u.EmployeeId == e.Id)
                                          select new
            {
                e.Id,
                Details = $"{e.Name} {e.Patronymic} {e.Surname} (возраст: {AgeHelper.GetAge(e.Birthdate)}) - {e.Position.Name}"
            };

            return(new SelectList(employeesWithoutAccount.ToList(), "Id", "Details"));
        }
Пример #5
0
        protected virtual Expression GetFilter(ParameterExpression argParam)
        {
            var expression = ExpressionHelper.GetExpression(new[] { (Gender) }, Expression.Property(argParam, "Gender"));

            expression = ExpressionHelper.GetExpressionMinMax(HeightHelper.GetArrayItems(Height), Expression.Property(argParam, "Height"), expression);
            expression = ExpressionHelper.GetExpressionMinMax(AgeHelper.GetArrayItems(Age), Expression.Property(argParam, "BirthYear"), expression);

            expression = ExpressionHelper.GetExpression(BodyBuild, Expression.Property(argParam, "BodyBuild"), expression);
            expression = ExpressionHelper.GetExpression(EyeColor, Expression.Property(argParam, "EyeColor"), expression);
            expression = ExpressionHelper.GetExpression(HairColor, Expression.Property(argParam, "HairColor"), expression);
            return(expression);
        }
Пример #6
0
        public static string SearchCriteriaValueText <TModel>(this HtmlHelper <TModel> htmlHelper, string key, string range, out string lookupKey, string countryCode)
        {
            var value = "";

            lookupKey = range;
            switch (key)
            {
            case "CityCode":
                value = htmlHelper.LocationText("City", range, countryCode);
                break;

            case "CountryCode":
                value = htmlHelper.LocationText("Country", range);
                break;

            case "BodyBuild":
            case "HairColor":
            case "EyeColor":
            case "Smokes":
            case "Alcohol":
            case "Religion":
            case "DickSize":
            case "DickThickness":
            case "BreastSize":
                lookupKey = htmlHelper.LookupText(key, Convert.ToByte(range));
                value     = htmlHelper.LookupText(key, lookupKey);
                break;

            case "Search":
                lookupKey = htmlHelper.LookupText("LookingFor", Convert.ToByte(range));
                value     = htmlHelper.LookupText("LookingFor", lookupKey);
                break;

            case "BirthYear":
                const string k   = "Age";
                var          age = (byte)AgeHelper.GetEnum(range);
                lookupKey = htmlHelper.LookupText(k, age);
                value     = htmlHelper.LookupText(k, lookupKey);
                break;

            case "Height":
                var height = (byte)HeightHelper.GetEnum(range);
                lookupKey = htmlHelper.LookupText(key, height);
                value     = htmlHelper.LookupText(key, lookupKey);
                break;
            }
            value = (String.IsNullOrWhiteSpace(value)) ? htmlHelper.ResourceValue("NotFilled") : value;
            return(value);
        }
Пример #7
0
        /// <summary>
        /// Creates a default list of Persons.
        /// </summary>
        /// <returns>The default Persons list.</returns>
        private IEnumerable <Person> CreateDefaultDataItems()
        {
            var dataItems = new ObservableCollection <Person>()
            {
                new Person("Ivan", AgeHelper.CalculatePersonAge(1986)),
                new Person("Teodor", AgeHelper.CalculatePersonAge(2017)),
                new Person("Yana", AgeHelper.CalculatePersonAge(1988)),
                new Person("Vesela", AgeHelper.CalculatePersonAge(1983)),
                new Person("Georgi", AgeHelper.CalculatePersonAge(1986)),
                new Person("Krasimir", AgeHelper.CalculatePersonAge(1987)),
                new Person("Andrean", AgeHelper.CalculatePersonAge(1971))
            };

            return(dataItems);
        }
Пример #8
0
        public async Task <IActionResult> GetBirthDecadeRates()
        {
            int totalEmployees = await context.Employees.CountAsync();

            List <int> birthdates = await context.Employees.Select(e => AgeHelper.GetDecade(e.Birthdate))
                                    .ToListAsync();

            var decadesData = birthdates.GroupBy(e => e)
                              .Select(g => new
            {
                decade = g.Key.ToString(),
                rate   = (double)g.Count() / totalEmployees * 100
            });

            ViewData["DecadeData"] = JsonSerializer.Serialize(decadesData);

            return(View());
        }
Пример #9
0
        public JsonResult GetUserProfile(long?id)
        {
            var currentUserId = Convert.ToInt64(HttpContext.User.FindFirstValue("Id"));

            id = id ?? currentUserId;
            var user      = _userService.GetById(id.Value);
            var userModel = (UserProfileModel) new UserProfileModel().InjectFrom(user);

            userModel.Age = AgeHelper.CalculateAge(user.DateOfBirth);
            var userAttendedEvents       = _eventService.GetUserAttendedEvents(id.Value);
            var userAttendedEventsModels = MapperHelper.MapEventsToModels(userAttendedEvents);

            if (id == currentUserId)
            {
                var userEvents       = _eventService.GetUserUpcomingEvents(id.Value);
                var userEventsModels = MapperHelper.MapEventsToModels(userEvents);
                return(Json(new { userInfo = userModel, userAttendedEvents = userAttendedEventsModels, userEvents = userEventsModels }));
            }

            return(Json(new { userInfo = userModel, userAttendedEvents = userAttendedEventsModels }));
        }
Пример #10
0
        private Product CreateNewProduct(
            List <Offer> offers,
            DateTime updateDate)
        {
            var offer   = offers.First();
            var soldOut = offers.All(o => o.SoldOut);

            _dbHelper.RememberVendorIfUnknown(offer.VendorNameClearly, offer.OriginalVendor);

            return(new Product {
                Id = offer.ProductId,
                Url = offer.Url,
                UpdateDate = updateDate,
                Name = offer.Name ?? string.Empty,
                Description = offer.Description ?? string.Empty,
                Model = offer.Model ?? string.Empty,
                Gender = GenderHelper.Convert(offer.Gender),
                Age = AgeHelper.Convert(offer.Age),
                ShopId = offer.ShopId.ToString(),
                Price = offers.Max(o => o.Price),
                OldPrice = offer.OldPrice ?? 0m,
                TypePrefix = offer.TypePrefix ?? string.Empty,
                CategoryName = offer.CategoryPath ?? string.Empty,
                Discount = offer.Discount,
                Currency = offer.Currency.ToString(),
                CountryId = offer.CountryId.ToString(),
                VendorNameClearly = offer.VendorNameClearly,
                Photos = new List <string>(),
                Params = new List <string>(),
                Enable = 1,
                Soldout = (byte)(soldOut ? 1 : 0),
                Delivery = 0,
                BrandId = _dbHelper.GetBrandId(offer.VendorNameClearly),
                SalesNotes = offer.SalesNotes,
                OriginalCategoryId = offer.CategoryId,
                OfferIds = offers.Select(o => o.OriginalId).ToArray(),
                Vendor = offer.OriginalVendor,
                Rating = _calculation.Calculate()
            });
        }
Пример #11
0
        public static string GetPeriodeString(DateTime debut, DateTime end)
        {
            var days = new AgeHelper(debut, end);

            if (days.Years == 0)
            {
                if (days.Months == 0)
                {
                    return($"{days.Days} jours");
                }
                else
                {
                    return($"{days.Months} mois,{days.Days} jours");
                }
            }
            else
            {
                return($"{days.Years} ans et {days.Months} mois");
            }

            return("");
        }
Пример #12
0
        /// <summary>
        /// Universe Reference should only be used for Movies in the my Universe.
        /// </summary>
        /// <param name="movie"></param>
        /// <param name="univ"></param>
        public void LoadMovieInfo(ref Movie movie, ref Universe univ)
        {
            selectedMovie = movie;
            u             = univ;
            lblTitle.Text = movie.Title;
            if (movie.ReleaseDate.HasValue)
            {
                lblReleaseDate.Text  = movie.ReleaseDate.Value.ToShortDateString();
                lblReleaseDate.Text += AgeHelper.GetReleaseDateDelta(movie.ReleaseDate.Value);
            }
            else
            {
                lblReleaseDate.Text = "TBD";
            }

            lblRunTime.Text = movie.Runtime.ToString() + " minutes";
            lblRevenue.Text = movie.Revenue.ToString("C0"); // Currency no cents.
            //if (movie.HomePage != null)
            //{
            //    pbPoster.Tag = movie.HomePage.AbsoluteUri;
            //}
            //else
            //{
            //    pbPoster.Tag = null;
            //}
            if (movie.TrailerLink != null)
            {
                pbPoster.Tag = movie.TrailerLink;
            }
            else
            {
                pbPoster.Tag = null;
            }
            GetMoviePoster();
            GetProductionCompanyLogos();
        }
Пример #13
0
        bool isValidGroup(mzk_mmtgroupcode mmtgroupcode, string patientguid)
        {
            bool              ret           = false;
            int               patientGender = 0;
            DateTime          patientBirthDate;
            AgeHelper         ageHelper   = new AgeHelper(DateTime.Now);
            Patient           patient     = new Patient();
            PatientRepository patientRepo = new PatientRepository();

            patient          = new Patient().getPatientDetails(patientguid).Result;
            patientBirthDate = patient.dateOfBirth;
            patientGender    = patient.genderValue;

            if (mmtgroupcode.mzk_FilteronGender.HasValue)
            {
                if (mmtgroupcode.mzk_FilteronGender.Value)
                {
                    if (patientGender == mmtgroupcode.mzk_Gender.Value)
                    {
                        ret = true;
                    }
                    else
                    {
                        ret = false;
                    }
                }
                else
                {
                    ret = true;
                }
            }
            else
            {
                ret = true;
            }

            if (ret)
            {
                if (mmtgroupcode.mzk_FilteronAge.HasValue)
                {
                    if (mmtgroupcode.mzk_FilteronAge.Value)
                    {
                        if (mmtgroupcode.mzk_AgeValidationId != null)
                        {
                            if (ageHelper.isAgeMatched(patientBirthDate, (Helper.Enum.DayWeekMthYr)((OptionSetValue)((AliasedValue)mmtgroupcode.Attributes["AgeValidation.mzk_agefromunit"]).Value).Value, (int)((AliasedValue)mmtgroupcode.Attributes["AgeValidation.mzk_agefromvalue"]).Value, (Helper.Enum.DayWeekMthYr)((OptionSetValue)((AliasedValue)mmtgroupcode.Attributes["AgeValidation.mzk_agetounit"]).Value).Value, (int)((AliasedValue)mmtgroupcode.Attributes["AgeValidation.mzk_agetovalue"]).Value))
                            {
                                ret = true;
                            }
                            else
                            {
                                ret = false;
                            }
                        }
                    }
                    else
                    {
                        ret = true;
                    }
                }
                else
                {
                    ret = true;
                }
            }

            return(ret);
        }
Пример #14
0
        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)));
        }
Пример #15
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 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));
        }
Пример #17
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));
        }
Пример #18
0
        public List <Products> getProduct(Products product, int pageNumber = 0)
        {
            try
            {
                List <Products> Products = new List <Products>();
                #region Product
                QueryExpression query = new QueryExpression("product");

                query.Criteria.AddCondition("productstructure", ConditionOperator.NotEqual, (int)ProductProductStructure.ProductFamily);
                query.Criteria.AddCondition("statecode", ConditionOperator.Equal, (int)ProductState.Active);

                ConditionExpression condition1 = new ConditionExpression();
                condition1.AttributeName = "name";
                condition1.Operator      = ConditionOperator.Like;


                ConditionExpression condition2 = new ConditionExpression();
                condition2.AttributeName = "mzk_producttype";
                condition2.Operator      = ConditionOperator.Equal;
                if (!string.IsNullOrEmpty(product.Type))
                {
                    condition2.Values.Add(product.Type);
                }

                FilterExpression filter1 = new FilterExpression(LogicalOperator.And);
                FilterExpression filter2 = new FilterExpression();

                if (!string.IsNullOrEmpty(product.Name.ToLower()))
                {
                    if (product.Type == "4")
                    {
                        if (product.Name.Contains(' '))
                        {
                            try
                            {
                                string[] words = product.Name.Split(new Char[] { ' ' });

                                if (words.Length > 1 && words.Length < 3)
                                {
                                    //   filter1 = entityTypeDetails.LinkCriteria.AddFilter(LogicalOperator.Or);

                                    condition1.Values.Add("%" + words[0] + "%");
                                    filter1.Conditions.Add(new ConditionExpression("name", ConditionOperator.Like, "%" + words[1] + "%"));
                                    filter1.Conditions.Add(condition1);
                                }
                                else if (words.Length > 2)
                                {
                                    condition1.Values.Add("%" + words[0] + "%");

                                    filter1.Conditions.Add(condition1);
                                    filter1.Conditions.Add(new ConditionExpression("name", ConditionOperator.Like, "%" + words[1] + "%"));
                                    filter1.Conditions.Add(new ConditionExpression("name", ConditionOperator.Like, "%" + words[2] + "%"));
                                }
                            }
                            catch (Exception ex)
                            {
                                condition1.Values.Add("%" + product.Name + "%");
                                filter1.Conditions.Add(condition1);
                            }
                        }
                        else
                        {
                            condition1.Values.Add("%" + product.Name + "%");
                            filter1.Conditions.Add(condition1);
                        }
                    }
                    else if (product.Type == ((int)Productmzk_ProductType.Lab).ToString())
                    {
                        filter1 = new FilterExpression(LogicalOperator.Or);

                        filter1.AddCondition("name", ConditionOperator.Like, ("%" + product.Name.ToLower() + "%"));
                        filter1.AddCondition("productnumber", ConditionOperator.Like, ("%" + product.Name.ToLower() + "%"));
                    }
                    else
                    {
                        condition1.Values.Add("%" + product.Name + "%");
                        filter1.Conditions.Add(condition1);
                    }
                }
                filter2.Conditions.Add(condition2);

                query.Criteria.AddFilter(filter1);
                query.Criteria.AddFilter(filter2);
                query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet("name", "mzk_dosageid", "productnumber", "productid", "mzk_available", "mzk_diagnosisid", "mzk_frequencyid", "mzk_unitid", "mzk_routeid", "mzk_duration", "mzk_instruction", "parentproductid", "mzk_contrast", "mzk_specimensource", "mzk_axitemid");

                LinkEntity EntityDiagnosis = new LinkEntity("product", "mzk_concept", "mzk_diagnosisid", "mzk_conceptid", JoinOperator.LeftOuter);
                EntityDiagnosis.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_conceptname");

                LinkEntity EntityFrequency = new LinkEntity("product", "mzk_ordersetup", "mzk_frequencyid", "mzk_ordersetupid", JoinOperator.LeftOuter);
                EntityFrequency.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_description");

                LinkEntity EntityRoute = new LinkEntity("product", "mzk_ordersetup", "mzk_routeid", "mzk_ordersetupid", JoinOperator.LeftOuter);
                EntityRoute.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_description");

                LinkEntity EntityUnit = new LinkEntity("product", "mzk_unit", "mzk_unitid", "mzk_unitid", JoinOperator.LeftOuter);
                EntityUnit.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_description");

                LinkEntity EntityDosage = new LinkEntity("product", "mzk_dosageform", "mzk_dosageid", "mzk_dosageformid", JoinOperator.LeftOuter);
                EntityDosage.Columns     = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_dosageformid");
                EntityDosage.EntityAlias = "Dosage";

                LinkEntity EntityUserFavourite;
                if (!string.IsNullOrEmpty(product.filter) && product.filter == "favourite")
                {
                    EntityUserFavourite = new LinkEntity("product", "mzk_userfavourite", "productid", "mzk_productid", JoinOperator.Inner);
                }

                else
                {
                    EntityUserFavourite = new LinkEntity("product", "mzk_userfavourite", "productid", "mzk_productid", JoinOperator.LeftOuter);
                }
                EntityUserFavourite.Columns = new Microsoft.Xrm.Sdk.Query.ColumnSet(true);

                EntityUserFavourite.EntityAlias = "ProductFavourite";



                LinkEntity EntityFamily = new LinkEntity("product", "product", "parentproductid", "productid", JoinOperator.LeftOuter);
                EntityFamily.EntityAlias = "ProductFamily";
                EntityFamily.Columns     = new Microsoft.Xrm.Sdk.Query.ColumnSet("mzk_antibioticmandatory", "mzk_commentsmandatory", "mzk_controlleddrug", "mzk_sedation", "mzk_agefromunit", "mzk_agefromvalue", "mzk_agetounit", "mzk_agetovalue");


                query.LinkEntities.Add(EntityDiagnosis);
                query.LinkEntities.Add(EntityFrequency);
                query.LinkEntities.Add(EntityRoute);
                query.LinkEntities.Add(EntityUnit);
                // query.LinkEntities.Add(EntityImportance);
                query.LinkEntities.Add(EntityFamily);
                query.LinkEntities.Add(EntityDosage);
                if (!string.IsNullOrEmpty(product.UserId))
                {
                    EntityUserFavourite.LinkCriteria.AddCondition("mzk_userid", ConditionOperator.Equal, product.UserId);
                    query.LinkEntities.Add(EntityUserFavourite);
                }

                if (pageNumber > 0)
                {
                    query.PageInfo                        = new PagingInfo();
                    query.PageInfo.Count                  = Convert.ToInt32(AppSettings.GetByKey("PageSize"));
                    query.PageInfo.PageNumber             = product.currentpage;
                    query.PageInfo.PagingCookie           = null;
                    query.PageInfo.ReturnTotalRecordCount = true;
                }

                #endregion
                SoapEntityRepository entityRepository = SoapEntityRepository.GetService();
                EntityCollection     entitycollection = entityRepository.GetEntityCollection(query);

                CaseParameter caseParm      = null;
                List <string> prodExistList = new List <string>();

                if (!string.IsNullOrEmpty(product.EncounterId))
                {
                    caseParm = CaseParameter.getDefaultUrgency(PatientCase.getCaseType(product.EncounterId));

                    query = new QueryExpression(mzk_patientorder.EntityLogicalName);

                    query.ColumnSet = new Microsoft.Xrm.Sdk.Query.ColumnSet(true);
                    query.Criteria.AddCondition("mzk_patientencounterid", ConditionOperator.Equal, product.EncounterId);
                    query.Criteria.AddCondition("mzk_orderstatus", ConditionOperator.Equal, (int)mzk_orderstatus.Ordered);
                    query.Criteria.AddCondition("mzk_productid", ConditionOperator.NotNull);

                    EntityCollection entitycollectionOrders = entityRepository.GetEntityCollection(query);

                    foreach (Entity entity in entitycollectionOrders.Entities)
                    {
                        mzk_patientorder order = (mzk_patientorder)entity;

                        prodExistList.Add(order.mzk_ProductId.Id.ToString());
                    }
                }

                foreach (Entity entity in entitycollection.Entities)
                {
                    Products model = new Products();
                    if (entity.Attributes.Contains("name"))
                    {
                        model.Name = entity.Attributes["name"].ToString();
                    }
                    if (entity.Attributes.Contains("productnumber"))
                    {
                        model.ProductNumber = entity.Attributes["productnumber"].ToString();
                    }
                    if (entity.Attributes.Contains("productid"))
                    {
                        model.ProductId = entity.Id.ToString();
                    }

                    if (entity.Attributes.Contains("mzk_available"))
                    {
                        model.Available = Convert.ToBoolean(entity.Attributes["mzk_available"].ToString());
                    }

                    if (entity.Attributes.Contains("mzk_contrast"))
                    {
                        model.contrastOrder = Convert.ToBoolean(entity.Attributes["mzk_contrast"].ToString());
                    }

                    //Diagnosis
                    if (entity.Attributes.Contains("mzk_diagnosisid"))
                    {
                        model.DiagnosisId = ((EntityReference)entity.Attributes["mzk_diagnosisid"]).Id.ToString();
                    }
                    if (entity.Attributes.Contains("mzk_concept1.mzk_conceptname"))
                    {
                        model.DiagnosisName = (entity.Attributes["mzk_concept1.mzk_conceptname"] as AliasedValue).Value.ToString();
                    }

                    //Frequency
                    if (entity.Attributes.Contains("mzk_frequencyid"))
                    {
                        model.FrequencyId = ((EntityReference)entity.Attributes["mzk_frequencyid"]).Id.ToString();
                    }
                    if (entity.Attributes.Contains("mzk_ordersetup2.mzk_description"))
                    {
                        model.FrequencyName = (entity.Attributes["mzk_ordersetup2.mzk_description"] as AliasedValue).Value.ToString();
                    }

                    //Route
                    if (entity.Attributes.Contains("mzk_routeid"))
                    {
                        model.RouteId = ((EntityReference)entity.Attributes["mzk_routeid"]).Id.ToString();
                    }
                    if (entity.Attributes.Contains("mzk_ordersetup3.mzk_description"))
                    {
                        model.RouteName = (entity.Attributes["mzk_ordersetup3.mzk_description"] as AliasedValue).Value.ToString();
                    }

                    //Unit
                    if (entity.Attributes.Contains("mzk_unitid"))
                    {
                        model.UnitId = ((EntityReference)entity.Attributes["mzk_unitid"]).Id.ToString();
                    }
                    if (entity.Attributes.Contains("mzk_unit4.mzk_description"))
                    {
                        model.UnitName = (entity.Attributes["mzk_unit4.mzk_description"] as AliasedValue).Value.ToString();
                    }

                    if (!string.IsNullOrEmpty(product.EncounterId) && caseParm != null)
                    {
                        model.UrgencyId   = caseParm.urgencyId;
                        model.UrgencyName = caseParm.urgencyName;
                    }

                    //Instruction
                    if (entity.Attributes.Contains("mzk_instruction"))
                    {
                        model.Instruction = entity.Attributes["mzk_instruction"].ToString();
                    }

                    if (entity.Attributes.Contains("mzk_specimensource"))
                    {
                        model.IsSpecimenSource = (bool)entity.Attributes["mzk_specimensource"];
                    }

                    if (model.IsSpecimenSource == false)
                    {
                        if (!string.IsNullOrEmpty(product.EncounterId))
                        {
                            model.isAdded = !prodExistList.Exists(item => item == entity.Id.ToString());
                            //model.isAdded = new PatientEncounter().DuplicateDetection(product.EncounterId, entity.Id.ToString());
                        }
                    }
                    else
                    {
                        model.isAdded = true;
                    }

                    if (entity.Attributes.Contains("ProductFavourite.mzk_userfavouriteid"))
                    {
                        model.FavouriteId = (entity.Attributes["ProductFavourite.mzk_userfavouriteid"] as AliasedValue).Value.ToString();
                    }

                    //Parameters
                    if (entity.Attributes.Contains("ProductFamily.mzk_antibioticmandatory"))
                    {
                        model.antiBioticRequired = (bool)((AliasedValue)entity.Attributes["ProductFamily.mzk_antibioticmandatory"]).Value;
                    }

                    if (entity.Attributes.Contains("ProductFamily.mzk_controlleddrug"))
                    {
                        model.controlledDrugs = (bool)((AliasedValue)entity.Attributes["ProductFamily.mzk_controlleddrug"]).Value;
                    }

                    if (entity.Attributes.Contains("ProductFamily.mzk_commentsmandatory"))
                    {
                        model.commentsRequired = (bool)((AliasedValue)entity.Attributes["ProductFamily.mzk_commentsmandatory"]).Value;
                    }

                    if (entity.Attributes.Contains("ProductFamily.mzk_sedation") && !string.IsNullOrEmpty(product.patientId))
                    {
                        model.sedationOrder = (bool)((AliasedValue)entity.Attributes["ProductFamily.mzk_sedation"]).Value;

                        if (model.sedationOrder)
                        {
                            AgeHelper ageHelper = new AgeHelper(DateTime.Now);
                            DateTime  patientBirthDate;
                            Patient   patient = new Patient();
                            Helper.Enum.DayWeekMthYr ageFromUnit = Helper.Enum.DayWeekMthYr.Days, ageToUnit = Helper.Enum.DayWeekMthYr.Days;
                            int ageFromValue = 0, ageToValue = 0;

                            patientBirthDate = patient.getPatientDetails(product.patientId).Result.dateOfBirth;

                            if (entity.Attributes.Contains("ProductFamily.mzk_agefromunit") && (entity.Attributes["ProductFamily.mzk_agefromunit"] as AliasedValue) != null)
                            {
                                ageFromUnit = (Helper.Enum.DayWeekMthYr)((entity.Attributes["ProductFamily.mzk_agefromunit"] as AliasedValue).Value as OptionSetValue).Value;
                            }

                            if (entity.Attributes.Contains("ProductFamily.mzk_agetounit") && (entity.Attributes["ProductFamily.mzk_agetounit"] as AliasedValue) != null)
                            {
                                ageToUnit = (Helper.Enum.DayWeekMthYr)((entity.Attributes["ProductFamily.mzk_agetounit"] as AliasedValue).Value as OptionSetValue).Value;
                            }

                            if (entity.Attributes.Contains("ProductFamily.mzk_agefromvalue") && (entity.Attributes["ProductFamily.mzk_agefromvalue"] as AliasedValue) != null)
                            {
                                ageFromValue = (int)((entity.Attributes["ProductFamily.mzk_agefromvalue"] as AliasedValue).Value);
                            }

                            if (entity.Attributes.Contains("ProductFamily.mzk_agetovalue") && (entity.Attributes["ProductFamily.mzk_agetovalue"] as AliasedValue) != null)
                            {
                                ageToValue = (int)((entity.Attributes["ProductFamily.mzk_agetovalue"] as AliasedValue).Value);
                            }

                            model.sedationOrder = ageHelper.isAgeMatched(patientBirthDate, ageFromUnit, ageFromValue, ageToUnit, ageToValue);
                        }
                    }

                    if (entity.Attributes.Contains("mzk_dosageid"))
                    {
                        model.Dosage = ((EntityReference)entity.Attributes["mzk_dosageid"]).Id.ToString();
                    }

                    if (AppSettings.GetByKey("OperationsIntegration").ToLower() == true.ToString().ToLower())
                    {
                        if (!string.IsNullOrEmpty(product.clinicId) && entity.Attributes.Contains("mzk_axitemid") && !string.IsNullOrEmpty(entity.Attributes["mzk_axitemid"].ToString()))
                        {
                            CommonRepository comRepo = new CommonRepository();

                            Clinic clinic = new Clinic().getClinicDetails(product.clinicId);

                            Dictionary <int, int> retStock = comRepo.checkItemInStock(entity.Attributes["mzk_axitemid"].ToString(), clinic.mzk_axclinicrefrecid);

                            if (retStock != null && retStock.Count > 0)
                            {
                                int availableValue = 0;

                                if (retStock.TryGetValue(0, out availableValue))
                                {
                                    model.availableForClinic = availableValue == 0 ? false : true;
                                }

                                if (retStock.TryGetValue(1, out availableValue))
                                {
                                    model.availableForPharmacy = availableValue == 0 ? false : true;
                                }
                            }
                        }
                    }

                    Products.Add(model);
                }

                if (pageNumber > 0 && entitycollection != null)
                {
                    Pagination.totalCount = entitycollection.TotalRecordCount;
                }

                return(Products);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }