Exemplo n.º 1
0
        private void CalculateAgeDiff()
        {
            DateTime Now          = DateTime.Now;
            var      splittedDate = DOB.Split('/');
            DateTime itemdateTime = new DateTime(Convert.ToInt32(splittedDate[2]), Convert.ToInt32(splittedDate[0]), Convert.ToInt32(splittedDate[1]));
            int      Years        = new DateTime(DateTime.Now.Subtract(itemdateTime).Ticks).Year - 1;
            DateTime PastYearDate = itemdateTime.AddYears(Years);
            int      Months       = 0;

            for (int i = 1; i <= 12; i++)
            {
                if (PastYearDate.AddMonths(i) == Now)
                {
                    Months = i;
                    break;
                }
                else if (PastYearDate.AddMonths(i) >= Now)
                {
                    Months = i - 1;
                    break;
                }
            }
            TotalAgeinMonths = Months + (Years * 12);
            _commonDataService.TotalAgeinMonths = TotalAgeinMonths;
            if (Years > 0)
            {
                Age = Years + " years, " + Months + " months";
            }
            else
            {
                Age = Months + " months";
            }
        }
        public void OnNavigatedTo(INavigationParameters parameters)
        {
            if (parameters.ContainsKey("ProfileData"))
            {
                profiledata = (UserModel)parameters["ProfileData"];

                try
                {
                    if (profiledata != null)
                    {
                        Profiledata = profiledata;
                        Name        = Profiledata.name;
                        Email       = Profiledata.email;
                        DOB         = profiledata.dob;
                        UserPic     = Common.IsImagesValid(profiledata.profile_pic);
                        PhoneNumber = profiledata.phone_number;
                        CurrentJob  = profiledata.current_job;
                        Street      = !string.IsNullOrEmpty(profiledata.street) && !string.IsNullOrWhiteSpace(profiledata.street) ? profiledata.street : AppResource.cyp_StreetPlaceholder;
                        if (!string.IsNullOrEmpty(DOB) && !string.IsNullOrWhiteSpace(DOB))
                        {
                            var dobdata = DOB.Split('/');

                            DOBDatePickerSelectedindex  = DOBDateList.IndexOf(dobdata[0]);
                            DOBMonthPickerSelectedindex = DOBMonthList.IndexOf(dobdata[1]);
                            DOBYearPickerSelectedindex  = DOBYearList.IndexOf(dobdata[2]);
                        }



                        if (profiledata.longitude.HasValue && profiledata.latitude.HasValue)
                        {
                            AddressPositionfromGPS = new Position(profiledata.latitude.Value, profiledata.longitude.Value);
                            location = new Plugin.Geolocator.Abstractions.Position(profiledata.latitude.Value, profiledata.longitude.Value);
                        }
                        Location = profiledata.description_location;

                        if (profiledata.martial_status.HasValue)
                        {
                            switch (profiledata.martial_status.Value)
                            {
                            case 1:
                                MaritalStatusPickerSelectedindex = 0;
                                break;

                            case 2:
                                MaritalStatusPickerSelectedindex = 1;
                                break;

                            case 3:
                                MaritalStatusPickerSelectedindex = 2;
                                break;

                            case 4:
                                MaritalStatusPickerSelectedindex = 3;
                                break;

                            case 5:
                                MaritalStatusPickerSelectedindex = 4;
                                break;

                            case 6:
                                MaritalStatusPickerSelectedindex = 5;
                                break;

                            case 7:
                                MaritalStatusPickerSelectedindex = 6;
                                break;

                            default:
                                MaritalStatusPickerSelectedindex = -1;
                                break;
                            }
                        }
                        if (profiledata.province.HasValue)
                        {
                            ProviencePickerSelectedindex = ProvinceList.IndexOf(ProvinceList.Where(x => x.province_id == (int)profiledata.province.Value).ToList().FirstOrDefault());
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }