public async void increaseCapacity(int idIn, string shelterNameIn, int capacityIn, string restrictionsIn, float longitudeIn, float latitudeIn, string addressIn, string phoneNumberIn)
 {
     try {
         ShelterInformation shelterInformation = new ShelterInformation();
         shelterInformation.uniqueKey    = idIn;
         shelterInformation.shelterName  = shelterNameIn;
         shelterInformation.capacity     = capacityIn;
         shelterInformation.restrictions = restrictionsIn;
         shelterInformation.longitude    = longitudeIn;
         shelterInformation.latitude     = latitudeIn;
         shelterInformation.address      = addressIn;
         shelterInformation.phoneNumber  = phoneNumberIn;
         var                 stringContent = new StringContent(JsonConvert.SerializeObject(shelterInformation));
         HttpClient          client        = new HttpClient();
         var                 uri           = $"https://sheltermewebapi.azurewebsites.net/api/increaseCapacity?id={idIn}&shelterName={shelterNameIn}&capacity={capacityIn}&restrictions={restrictionsIn}&longitude={longitudeIn}&latitude={latitudeIn}&address={addressIn}&phoneNumber={phoneNumberIn}";
         HttpResponseMessage response      = await client.PutAsync(uri, stringContent);
     } catch (Exception ex) {
         throw ex;
     }
 }
Ejemplo n.º 2
0
        private async void ListClicked(Object sender, EventArgs e)
        {
            ShelterInformation        shelterNameList  = new ShelterInformation();
            List <ShelterInformation> restrictionsList = new List <ShelterInformation>();
            List <string>             nameList         = new List <string>();
            string restrictionsString = "";

            if (men.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Men";
                }
                else
                {
                    restrictionsString += " Men";
                }
            }
            if (women.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Women";
                }
                else
                {
                    restrictionsString += " Women";
                }
            }
            if (newborns.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Newborns";
                }
                else
                {
                    restrictionsString += " Newborns";
                }
            }
            if (children.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Children";
                }
                else
                {
                    restrictionsString += " Children";
                }
            }
            if (youngAdults.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Young Adults";
                }
                else
                {
                    restrictionsString += " Young Adults";
                }
            }
            if (anyone.Checked)
            {
                if (restrictionsString == "")
                {
                    restrictionsString += "Anyone";
                }
                else
                {
                    restrictionsString += " Anyone";
                }
            }
            Task <ShelterInformation> shelterNameListTask = Task.Run(async() => await agent.getShelterInformation(shelterName.Text));

            shelterNameList = shelterNameListTask.Result;
            Task <List <ShelterInformation> > restrictionsListTask = Task.Run(async() => await agent.getFilteredSheltersByRestrictions(restrictionsString));

            restrictionsList = restrictionsListTask.Result;
            if (shelterNameList == null)
            {
                foreach (ShelterInformation list in restrictionsList)
                {
                    nameList.Add(list.shelterName);
                }
            }
            else if (restrictionsList == null)
            {
                nameList.Add(shelterNameList.shelterName);
            }
            else if (shelterNameList.restrictions.Contains(restrictionsString))
            {
                nameList.Add(shelterNameList.shelterName);
            }
            await Navigation.PushAsync(new FilterOptions(nameList));
        }