Beispiel #1
0
        public void CallAPIsyncMyMenu()
        {
            HttpClient      client   = new HttpClient();
            SimpleLoginPage usercito = new SimpleLoginPage();
            User            user     = usercito.GetUser();
            var             recet    = new Recet
            {
                name = RecipeName.Text,
            };
            var           json     = JsonConvert.SerializeObject(recet);
            StringContent content  = new StringContent(json, Encoding.UTF8, "application/json");
            var           response = client.PostAsync($"http://192.168.1.102:8080/cooktime1/api/services/postUserMyMenuList?email={user.email}&newRecipe={recet.name}", content).Result;

            if (response.IsSuccessStatusCode)
            {
                {
                    act = true;
                }
            }
            else
            {
                act = false;
            }
        }
Beispiel #2
0
        public void CallAPIsync()
        {
            HttpClient      client   = new HttpClient();
            SimpleLoginPage usercito = new SimpleLoginPage();
            User            user     = usercito.GetUser();
            var             recet    = new Recet
            {
                author       = RecipeAuthor.Text,
                name         = RecipeName.Text,
                calification = "2",
                steps        = PreparationSteps.Text,
                time         = DishType.Text,
                type         = FoodType.Text,
                dietTag      = RecipeTags.Text,
                price        = Price.Text,
                portions     = Servings.Text,
                duration     = PreparationTime.Text,
                ingredients  = RecipeIngredients.Text,
                photo        = recetsImages[x],
                publication  = "20/07/2020",
                difficulty   = DifficultyFactor.Text
            };
            var           json     = JsonConvert.SerializeObject(recet);
            StringContent content  = new StringContent(json, Encoding.UTF8, "application/json");
            var           response = client.PostAsync($"http://192.168.1.102:8080/cooktime1/api/services/postRecipe?name={recet.name}&author={recet.author}&type={recet.type}&portions={recet.portions}&duration={recet.duration}&time={recet.time}&difficulty={recet.difficulty}&dietTag={recet.dietTag}&photo={recet.photo}&ingredients={recet.ingredients}&steps={recet.steps}&price={recet.price}&calification={recet.calification}&publication={recet.publication}", content).Result;

            if (response.IsSuccessStatusCode)
            {
                acc = true;
                x++;
            }
            else
            {
                acc = false;
            }
        }