Ejemplo n.º 1
0
        private async void saveFavorite()
        {
            int value;
            ApplicationDataContainer roamingSettings;

            try
            {
                // to get roaming settings.....
                roamingSettings =
                    ApplicationData.Current.RoamingSettings;
                value          = (int)roamingSettings.Values["Favoritef2f"];
                favoriteNumber = value;
            }
            catch (Exception exRoaming)
            {
                // if the value key is not set, then the exception will cause
                // this code to execute, which just sets the value to 0 (default)
                string errMsg = exRoaming.Message;
                favoriteNumber = 0;
            } // end inner try for roaming settings
            Model.Recipef2f recipe        = recipeFinalList[pvtRecipes.SelectedIndex];
            StorageFolder   storageFolder = ApplicationData.Current.RoamingFolder;
            StorageFile     sampleFile;
            string          fileText = "";

            try
            {
                sampleFile = await storageFolder.GetFileAsync("f2f" + favoriteNumber + ".txt");

                fileText = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
            }
            catch (Exception myE)
            {
                string message = myE.Message;
                sampleFile = await storageFolder.CreateFileAsync(("f2f" + favoriteNumber + ".txt"));
            }
            String objectRecipe = "";

            objectRecipe += recipe.ImageUrl + "\n";     // URL of the image
            objectRecipe += recipe.SourceUrl + "\n";    // Original Url of the recipe on the publisher's site
            objectRecipe += recipe.RecipeId + "\n";     // Id used for follow-up request
            objectRecipe += recipe.F2fUrl + "\n";       // Url of the recipe on Food2Fork.com
            objectRecipe += recipe.Title + "\n";        // Title of the recipe
            objectRecipe += recipe.Publisher + "\n";    // Name of the Publisher
            objectRecipe += recipe.PublisherUrl + "\n"; // Base url of the publisher
            objectRecipe += recipe.SocialRank + "\n";   // The Social Ranking of the Recipe (As determined by f2f Ranking Algorithm)
            objectRecipe += recipe.IngredientsList + "\n";

            await Windows.Storage.FileIO.WriteTextAsync(sampleFile, objectRecipe);

            favoriteNumber++;
            roamingSettings =
                ApplicationData.Current.RoamingSettings;
            roamingSettings.Values["Favoritef2f"] = favoriteNumber;
        }
Ejemplo n.º 2
0
 private async void Recipiestxtblck_Tapped(object sender, TappedRoutedEventArgs e)
 {
     this.loadingModal();
     Responsef2f response = new Responsef2f();
     Bussiness.Recipef2f responseRecipe = new Bussiness.Recipef2f();
     String responseString = await response.getData(1);
     List<Model.ResponseRecipef2f> recipeList;
     List<Model.Recipef2f> recipeFinalList = new List<Model.Recipef2f>();
     recipeList = response.parseResponse(responseString);
     foreach (Model.ResponseRecipef2f recipe in recipeList)
     {
         Model.Recipef2f recipeModel = new Model.Recipef2f();
         recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);
         recipeFinalList.Add(recipeModel);
     }
     this.ReloadScreen();
     Frame.Navigate(typeof(ShowRecipies), recipeFinalList);
 }
Ejemplo n.º 3
0
        private async void pvtRecipes_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if ((pvtRecipes.SelectedIndex + 27) % 10 == 0)
            {
                page++;
                Bussiness.Responsef2f response       = new Bussiness.Responsef2f();
                Bussiness.Recipef2f   responseRecipe = new Bussiness.Recipef2f();
                String responseString = await response.getData(page);

                List <Model.ResponseRecipef2f> recipeList;
                //List<Model.Recipef2f> recipeFinalList = new List<Model.Recipef2f>();
                recipeList = response.parseResponse(responseString);
                foreach (Model.ResponseRecipef2f recipe in recipeList)
                {
                    Model.Recipef2f recipeModel = new Model.Recipef2f();
                    recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);

                    recipeFinalList.Add(recipeModel);
                }
                this.populateRecipes();
            }
        }
Ejemplo n.º 4
0
        private async void Searchblck_Tapped(object sender, TappedRoutedEventArgs e)
        {
            string query = "&q=";

            for (int i = 0; i <= numIngredients; i++)
            {
                var myTextBox = (TextBox)this.FindName("Ingredient" + i.ToString());
                if (myTextBox.Text != null)
                {
                    if (i == numIngredients)
                    {
                        query += myTextBox.Text;
                    }
                    else
                    {
                        query += myTextBox.Text + ",";
                    }
                }
            }
            this.loadingModal();
            Bussiness.Responsef2f response = new Bussiness.Responsef2f();
            response.StringUri = response.StringUri + query;
            Bussiness.Recipef2f responseRecipe = new Bussiness.Recipef2f();
            String responseString = await response.getData(1);

            List <Model.ResponseRecipef2f> recipeList;
            List <Model.Recipef2f>         recipeFinalList = new List <Model.Recipef2f>();

            recipeList = response.parseResponse(responseString);
            foreach (Model.ResponseRecipef2f recipe in recipeList)
            {
                Model.Recipef2f recipeModel = new Model.Recipef2f();
                recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);

                recipeFinalList.Add(recipeModel);
            }
            this.reloadScreen();
            Frame.Navigate(typeof(ShowRecipies), recipeFinalList);
        }
Ejemplo n.º 5
0
        private async void Recipiestxtblck_Tapped(object sender, TappedRoutedEventArgs e)
        {
            this.loadingModal();
            Responsef2f response = new Responsef2f();

            Bussiness.Recipef2f responseRecipe = new Bussiness.Recipef2f();
            String responseString = await response.getData(1);

            List <Model.ResponseRecipef2f> recipeList;
            List <Model.Recipef2f>         recipeFinalList = new List <Model.Recipef2f>();

            recipeList = response.parseResponse(responseString);
            foreach (Model.ResponseRecipef2f recipe in recipeList)
            {
                Model.Recipef2f recipeModel = new Model.Recipef2f();
                recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);

                recipeFinalList.Add(recipeModel);
            }
            this.ReloadScreen();
            Frame.Navigate(typeof(ShowRecipies), recipeFinalList);
        }
Ejemplo n.º 6
0
        private async Task <int> readf2fFiles(int f2fFavorites)
        {
            StorageFolder storageFolder = ApplicationData.Current.RoamingFolder;
            // List<Model.ResponseYummly> listRecipe = new List<Model.ResponseYummly>();

            StorageFile sampleFile;

            for (int i = 0; i < f2fFavorites; i++)
            {
                string fileText = "";
                try
                {
                    sampleFile = await storageFolder.GetFileAsync("f2f" + i + ".txt");

                    fileText = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);
                }
                catch (Exception myE)
                {
                    string message = myE.Message;
                    continue;
                }
                Model.Recipef2f recipe = new Model.Recipef2f();
                String[]        tokens = fileText.Split('\n');
                recipe.ImageUrl        = tokens[0];                // URL of the image
                recipe.SourceUrl       = tokens[1];;               // Original Url of the recipe on the publisher's site
                recipe.RecipeId        = tokens[2];;               // Id used for follow-up request
                recipe.F2fUrl          = tokens[3];;               // Url of the recipe on Food2Fork.com
                recipe.Title           = tokens[4];;               // Title of the recipe
                recipe.Publisher       = tokens[5];;               // Name of the Publisher
                recipe.PublisherUrl    = tokens[6];;               // Base url of the publisher
                recipe.SocialRank      = Double.Parse(tokens[7]);; // The Social Ranking of the Recipe (As determined by f2f Ranking Algorithm)
                recipe.IngredientsList = tokens[8];;
                listf2fRecipe.Add(recipe);
            }
            return(1);
        }
 private async void pvtRecipes_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if((pvtRecipes.SelectedIndex+27) % 10 == 0)
     {
         page++;
         Bussiness.Responsef2f response = new Bussiness.Responsef2f();
         Bussiness.Recipef2f responseRecipe = new Bussiness.Recipef2f();
         String responseString = await response.getData(page);
         List<Model.ResponseRecipef2f> recipeList;
         //List<Model.Recipef2f> recipeFinalList = new List<Model.Recipef2f>();
         recipeList = response.parseResponse(responseString);
         foreach (Model.ResponseRecipef2f recipe in recipeList)
         {
             Model.Recipef2f recipeModel = new Model.Recipef2f();
             recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);
             recipeFinalList.Add(recipeModel);
         }
         this.populateRecipes();
     }
 }
Ejemplo n.º 8
0
        private async Task<int> readf2fFiles(int f2fFavorites)
        {
            StorageFolder storageFolder = ApplicationData.Current.RoamingFolder;
            // List<Model.ResponseYummly> listRecipe = new List<Model.ResponseYummly>();

            StorageFile sampleFile;
            for (int i = 0; i < f2fFavorites; i++)
            {
                string fileText = "";
                try
                {
                    sampleFile = await storageFolder.GetFileAsync("f2f" + i + ".txt");
                    fileText = await Windows.Storage.FileIO.ReadTextAsync(sampleFile);

                }
                catch (Exception myE)
                {
                    string message = myE.Message;
                    continue;
                }
                Model.Recipef2f recipe = new Model.Recipef2f();
                String[] tokens = fileText.Split('\n');
                recipe.ImageUrl = tokens[0]; // URL of the image
                recipe.SourceUrl = tokens[1]; ; // Original Url of the recipe on the publisher's site
                recipe.RecipeId = tokens[2]; ; // Id used for follow-up request
                recipe.F2fUrl = tokens[3]; ; // Url of the recipe on Food2Fork.com
                recipe.Title = tokens[4]; ; // Title of the recipe
                recipe.Publisher = tokens[5]; ; // Name of the Publisher
                recipe.PublisherUrl = tokens[6]; ; // Base url of the publisher
                recipe.SocialRank = Double.Parse(tokens[7]); ; // The Social Ranking of the Recipe (As determined by f2f Ranking Algorithm)
                recipe.IngredientsList = tokens[8]; ;
                listf2fRecipe.Add(recipe);
            }
            return 1;
        }
 private async void Searchblck_Tapped(object sender, TappedRoutedEventArgs e)
 {
     string query = "&q=";
     for(int i = 0; i <= numIngredients; i++)
     {
         var myTextBox = (TextBox)this.FindName("Ingredient" + i.ToString());
         if(myTextBox.Text != null)
         {
             if (i == numIngredients)
                 query += myTextBox.Text;
             else
                 query += myTextBox.Text + ",";
         }
     }
     this.loadingModal();
     Bussiness.Responsef2f response = new Bussiness.Responsef2f();
     response.StringUri = response.StringUri + query;
     Bussiness.Recipef2f responseRecipe = new Bussiness.Recipef2f();
     String responseString = await response.getData(1);
     List<Model.ResponseRecipef2f> recipeList;
     List<Model.Recipef2f> recipeFinalList = new List<Model.Recipef2f>();
     recipeList = response.parseResponse(responseString);
     foreach (Model.ResponseRecipef2f recipe in recipeList)
     {
         Model.Recipef2f recipeModel = new Model.Recipef2f();
         recipeModel = await responseRecipe.getRecipe(recipe.RecipeId);
         recipeFinalList.Add(recipeModel);
     }
     this.reloadScreen();
     Frame.Navigate(typeof(ShowRecipies), recipeFinalList);
 }