public async Task <PostcodeAddresses> GetAddresses(string postCode)
        {
            PostcodeAddresses postcodeAddresses = new PostcodeAddresses();

            if (IsConnected)
            {
                var json = await client.GetStringAsync($"api/postcode/addresses/{postCode}");

                postcodeAddresses = await Task.Run(() => JsonConvert.DeserializeObject <PostcodeAddresses>(json));
            }

            return(postcodeAddresses);
        }
        public BinCollectionRequestViewModel()
        {
            PostcodeAddresses      = new PostcodeAddresses();
            UsersPostcodeAddresses = new List <string>();

            CouncilPostcodeRequest = new CouncilPostCodeRequest();

            BinCollectionDays = new List <BinCollectionModel>();

            var response = Task.Run(async() => await GetManchesterCouncils());

            ManchesterCouncils = response.Result;

            LoadAddressesCommand = new Command(async() => await GetAddresses());

            LoadBinCollectionDaysForPostCodeAndAddress = new Command(async() => await GetPostCodeAddressesBinCollectionDays());
        }
Example #3
0
        public async Task <PostcodeAddresses> GetAddressForPostCode(string postCode)
        {
            var editedAddreses = new PostcodeAddresses();

            editedAddreses.addresses = new List <string>();

            var response = await Client.GetAsync($"find/{postCode}/?api-key=");

            response.EnsureSuccessStatusCode();

            var responseStream = await response.Content.ReadAsStreamAsync();

            var result = await JsonSerializer.DeserializeAsync <PostcodeAddresses>(responseStream);

            foreach (var item in result.addresses)
            {
                var itemEdited = item.Replace(',', '-');

                editedAddreses.addresses.Add(itemEdited);
            }

            return(editedAddreses);
        }