Example #1
0
 public override void Start()
 {
     base.Start();
     try
     {
         SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
         SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
         SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);
     }
     catch { }
 }
        /// <summary>
        /// Lookups the county by fips.
        /// </summary>
        /// <param name="countyFIPS">The county fips.</param>
        /// <param name="stateFIPS">The state fips.</param>
        /// <returns></returns>
        private static County LookupCountyByFIPS(string countyFIPS, string stateFIPS)
        {
            int cFips;

            if (int.TryParse(countyFIPS, out cFips))
            {
                int sFips;
                if (int.TryParse(stateFIPS, out sFips))
                {
                    string countyCode = String.Format("{0:D2}{1:D3}", sFips, cFips);
                    return(Counties.FirstOrDefault(c => c.CountyFIPS.Equals(countyCode)));
                }
            }
            return(null);
        }
        public override void LoadFromStore(VMStore modelStore)
        {
            try
            {
                ContactAddress = JsonConvert.DeserializeObject <ClientContactAddressDTO>(modelStore.Store);
                PersonId       = ContactAddress.PersonId;
                Downloaded     = ContactAddress.Downloaded;
                Telephone      = ContactAddress.Phone;
                Landmark       = ContactAddress.Landmark;
                ContactId      = ContactAddress.ContactId;
                AddressId      = ContactAddress.AddressId;

                SelectedCounty    = Counties.FirstOrDefault(x => x.Id == 0);
                SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == 0);
                SelectedWard      = Wards.FirstOrDefault(x => x.Id == 0);

                if (ContactAddress.CountyId.HasValue && ContactAddress.CountyId.Value > 0)
                {
                    SelectedCounty = Counties.FirstOrDefault(x => x.Id == ContactAddress.CountyId);
                    GetSubCounties();
                }

                if (ContactAddress.SubCountyId.HasValue && ContactAddress.SubCountyId.Value > 0)
                {
                    SelectedSubCounty = SubCounties.FirstOrDefault(x => x.Id == ContactAddress.SubCountyId);
                    GetWards();
                }

                if (ContactAddress.WardId.HasValue && ContactAddress.WardId.Value > 0)
                {
                    SelectedWard = Wards.FirstOrDefault(x => x.Id == ContactAddress.WardId);
                }
            }
            catch (Exception e)
            {
                Mvx.Error(e.Message);
            }
        }
 public string GetAddress() => StringUtil.ConcatNonEmpties(", ", Address_Line1, Address_Line2, Address_Line3, Address_Locality, Address_CityOrTown, Counties.FirstOrDefault(x => x.Value == Address_CountyId?.ToString())?.Text, Address_PostCode);