Пример #1
0
        private async Task GetRecipesAsync()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                string jsonRecipes = await Client.GetStringAsync("http://www.croustipeze.com/ressources/recipesdata.json");

                Recipe[] recipes = JsonConvert.DeserializeObject <Recipe[]>(jsonRecipes, Converter.Settings);

                Recipes.Clear();
                foreach (var recipe in recipes)
                {
                    Recipes.Add(recipe);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine($"Unable to get recipes: {ex.Message}");
                await Application.Current.MainPage.DisplayAlert("Error!", ex.Message, "OK");
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #2
0
        private async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Recipes.Clear();
                var items = await DataStore.GetItemsAsync();

                foreach (var item in items)
                {
                    Recipes.Add(item);
                    Console.WriteLine(item.Title);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #3
0
        private async Task ExecuteGetItemsCommand(string ingredients)
        {
            Recipes.Clear();
            var items = await GetItemsAsync(ingredients);

            Recipes.ReplaceRange(items);
        }
Пример #4
0
        void CreateRadomRecipes()
        {
            Recipes.Clear();
            foreach (var name in names)
            {
                var    NewRecipe = new Recipe(name);
                var    value     = new Random().Next(3);
                string img       = value == 0 ? "default.jpg" : $"{value}.jpg";
                NewRecipe.Thumbnail = img;

                Recipes.Add(NewRecipe);
                RecipeDetailsController.CreateRandomDetails(_storageService, NewRecipe);

                _storageService.Delete(NewRecipe.ID);

                FileStream thumbnail = File.OpenRead($"Resources/Images/Thumbnails/{NewRecipe.Thumbnail}");
                thumbnail.Position = 0;
                _storageService.UploadPicture(thumbnail, NewRecipe.ID, NewRecipe.Thumbnail);
                thumbnail.Close();
            }

            Stream        recipe     = new MemoryStream();
            XmlSerializer serializer = new XmlSerializer(typeof(List <Recipe>));

            serializer.Serialize(recipe, Recipes);

            recipe.Position = 0;
            _storageService.UploadRecipe(recipe);

            recipe.Dispose();
        }
Пример #5
0
        async Task ExecuteLoadRecipesCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Recipes.Clear();
                var recipes = await DataStore.GetAllRecipesAsync(true);

                foreach (var recipe in recipes)
                {
                    Recipes.Add(recipe);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #6
0
    /// Handles the response of the GetRecipeMetaData call to ChilliConnect.
    /// Loads the returned objects to a list of Recipe definitions and notifies listeners
    ///
    private void RenderRecipeList(GetMetadataDefinitionsResponse response)
    {
        Recipes.Clear();

        foreach (MetadataDefinition metadataItem in response.Items)
        {
            var recipeName     = metadataItem.Name;
            var recipeKey      = metadataItem.Key;
            var itemCustomData = metadataItem.CustomData;
            var minLvlRange    = itemCustomData.AsDictionary().GetInt("AttributesMin");
            var maxLvlRange    = itemCustomData.AsDictionary().GetInt("AttributesMax");
            var coinCost       = itemCustomData.AsDictionary().GetInt("Cost");

            var recipe = new Recipe();
            recipe.RecipeName    = recipeName;
            recipe.RecipeKey     = recipeKey;
            recipe.LevelRangeMin = minLvlRange;
            recipe.LevelRangeMax = maxLvlRange;
            recipe.CoinCost      = coinCost;
            Recipes.Add(recipe);
        }
        ;

        OnRecipeListPopulate(Recipes);
    }
Пример #7
0
 public void getPatientHistory()
 {
     try
     {
         if (TypeSelected == ShowData.מידע_עדכני)
         {
             Recipes.Clear();
             foreach (Recipe item in AddDoctorVisitM.getPatientHistory(Patient.PatientId, true))
             {
                 Recipes.Add(item);
             }
         }
         if (TypeSelected == ShowData.כל_המידע)
         {
             Recipes.Clear();
             foreach (Recipe item in AddDoctorVisitM.getPatientHistory(Patient.PatientId))
             {
                 Recipes.Add(item);
             }
         }
     }
     catch (Exception e)
     {
         (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString();
     }
 }
Пример #8
0
        public async Task ExecutePerformSearchCommand(string search, Category category = null, string sorter = null)
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Recipes.Clear();
                IEnumerable <Recipe> recipes;
                if (category != null)
                {
                    recipes = await DataStore.GetItemsByTagByCategoryAsync(search, category.CategoryId, sorter);
                }
                else
                {
                    recipes = await DataStore.GetItemsByTagsAsync(search, sorter);
                }
                foreach (var recipe in recipes)
                {
                    Recipes.Add(recipe);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Пример #9
0
        public override void Load()
        {
            Recipes.Clear();
            var recipes = recipesRepository.GetAll();

            Recipes.AddRange(recipes);
        }
Пример #10
0
 private void Accelerometer_ShakeDetected(object sender, EventArgs e)
 {
     MainThread.BeginInvokeOnMainThread(() =>
     {
         Recipes.Clear();
         GetRandomRecipes();
     });
 }
Пример #11
0
 private void FillRecipeNames()
 {
     _recipeList = _ctxDB.Recipes.ToList().FindAll(x => x.UserId == UserId);
     Recipes.Clear();
     for (int i = 0; i < _recipeList.Count(); i++)
     {
         Recipes.Add(_recipeList[i].RecipeName.ToString());
     }
 }
Пример #12
0
        private async Task ExecuteInit()
        {
            List <Models.Recipe.Recipe> entries = await RecipeRepository.GetRecipes();

            Recipes.Clear();

            entries.ForEach(r => Recipes.Add(r));
            Initialized = true;
        }
Пример #13
0
        private void BindRecipes()
        {
            Recipes.Clear();

            foreach (var item in _recipeService.Recipes(Query))
            {
                Recipes.Add(item);
            }
        }
Пример #14
0
 //Methods
 public void ClearList()
 {
     FoodPlanItems.Clear();
     Ingredients.Clear();
     Recipes.Clear();
     ShoppingListItems.Clear();
     Units.Clear();
     UnitTranslations.Clear();
     EvaluateMaxIDs();
 }
Пример #15
0
        public override async void OnNavigatedTo(NavigatedToEventArgs e, Dictionary <string, object> viewModelState)
        {
            base.OnNavigatedTo(e, viewModelState);

            Recipes.Clear();

            foreach (var recipe in await _RecipesFacade.GetAllRecipesAsync())
            {
                Recipes.Add(recipe);
            }
        }
Пример #16
0
        public void LoadRecipes()
        {
            var @params     = SelectedIngredients.Select(i => i.Id).ToList();
            var recipesList = Api.WczytajPrzepisyZeSkladnikow(@params);

            Recipes.Clear();
            foreach (var r in recipesList)
            {
                Recipes.Add(r);
            }
        }
Пример #17
0
        // Private methods
        private async Task LoadRecipes()
        {
            var result = await _recipeService.GetRecipesAsync(_nextPage);

            if (string.IsNullOrEmpty(_nextPage))
            {
                Recipes.Clear();
            }
            Recipes.AddRange(result.Results);

            _nextPage = result.Next;
        }
Пример #18
0
        public async void LoadDataAsync()
        {
            IsReloading = true;
            Recipes.Clear();
            var items = await _recipeService.GetRecipeAsync();

            foreach (var item in items)
            {
                Recipes.Add(item);
            }
            IsReloading = false;
        }
Пример #19
0
        private async void MainPage_Appearing(object sender, EventArgs e)
        {
            if (Source != null)
            {
                Source.Cancel();
            }
            Source = new CancellationTokenSource();

            Recipes.Clear();

            await LoadRecipes($"https://api.edamam.com/search?q={FindString.Text}&app_id={App.AppId}&app_key={App.AppKey}&diet={ChoosedFilter}");
        }
Пример #20
0
        private ObservableCollection <string> RealTimeSearch(string SearchItem)
        {
            Recipes.Clear();
            for (int i = 0; i < _recipeList.Count(); i++)
            {
                if (_recipeList[i].RecipeName.ToString().ToLower().Contains(SearchItem.ToLower()))
                {
                    Recipes.Add(_recipeList[i].RecipeName.ToString());
                }
            }

            return(Recipes);
        }
Пример #21
0
        public async Task Load()
        {
            IsRefreshing = true;
            Recipes.Clear();
            var items = await _cookBookClient.GetRecipes();

            foreach (var item in items)
            {
                Recipes.Add(item);
                await Task.Delay(300);
            }
            IsRefreshing = false;
        }
Пример #22
0
        /*********
        ** Private Methods
        *********/
        /// <summary>Invoked when the player loads a save.</summary>
        /// <param name="sender">The event sender.</param>
        /// <param name="e">The event data.</param>
        /// <remarks>This is used to load the content packs.</remarks>
        private void OnSaveLoaded(object sender, SaveLoadedEventArgs e)
        {
            // clear all old recipes as to not duplicate
            Recipes.Clear();
            LoadDefaultRecipes();

            // load content packs
            foreach (var contentPack in this.Helper.ContentPacks.GetOwned())
            {
                try
                {
                    this.Monitor.Log($"Loading content pack: {contentPack.Manifest.Name}", LogLevel.Info);

                    // ensure content.json exists
                    var contentFile = Path.Combine(contentPack.DirectoryPath, "content.json");
                    if (!File.Exists(contentFile))
                    {
                        this.Monitor.Log($"Couldn't find content.json file, skipping", LogLevel.Error);
                        continue;
                    }

                    // load recipes
                    var recipes = contentPack.ReadJsonFile <List <ParsedRecipe> >("content.json") ?? new List <ParsedRecipe>();
                    foreach (var recipe in recipes)
                    {
                        // resolve and validate input and ouput items
                        var inputId  = ResolveToken(recipe.InputId);
                        var outputId = ResolveToken(recipe.Output?.Id ?? "-1");
                        if (inputId == -1 || outputId == -1)
                        {
                            this.Monitor.Log($"Cannot load recipe: {recipe} as the input or output was invalid, this recipe will be skipped", LogLevel.Error);
                            continue;
                        }

                        // ensure no recipes with this input id already exist
                        if (Recipes.Any(r => r.InputId == inputId))
                        {
                            this.Monitor.Log($"A recipe with an input product id of: {inputId} has already been added, this recipe will be skipped", LogLevel.Warn);
                            continue;
                        }

                        Recipes.Add(new Recipe(inputId, new Output(outputId, recipe.Output.Amount)));
                    }
                }
                catch (Exception ex)
                {
                    this.Monitor.Log($"Failed to load content pack: {ex}", LogLevel.Error);
                }
            }
        }
Пример #23
0
        private void RefreshRecipes(object obj)
        {
            Recipes.Clear();
            SelectedRecipeName   = "";
            SelectedRecipeNumber = "";
            Segments.Clear();


            using (OracleConnection connection = new OracleConnection(connectionString))
            {
                string        queryString = "SELECT * from RECIPES";
                OracleCommand command     = new OracleCommand(queryString, connection);
                connection.Open();
                OracleDataReader reader = command.ExecuteReader();
                try
                {
                    using (OracleDataReader da = command.ExecuteReader())
                    {
                        DataTable dataTable = new DataTable();
                        dataTable.Load(reader);
                        foreach (DataRow dataRow in dataTable.Rows)
                        {
                            foreach (var item in dataRow.ItemArray)
                            {
                                Console.WriteLine(item);
                            }
                        }

                        for (int i = 0; i < dataTable.Rows.Count; ++i)
                        {
                            Recipes.Add(new Recipe_Details
                            {
                                Recipe_ID     = Convert.ToInt32(dataTable.Rows[i][0]),
                                Recipe_Name   = dataTable.Rows[i][1].ToString(),
                                Recipe_Number = dataTable.Rows[i][2].ToString(),
                            });
                        }
                    }
                }
                catch (Exception Ex)
                {
                    MessageBox.Show(Ex.Message);
                }
                finally
                {
                    reader.Close();
                }
            }
        }
        /// <summary>
        /// Method to search for recipes asynchronously
        /// </summary>
        private async void SearchForRecipeAsync()
        {
            // Clear the list view and display refreshing symbol
            Recipes.Clear();
            RecipeListView.IsRefreshing = true;

            // Get the data
            var result = await App.MasterController.EdamamApiHelper.QueryAsync(RecipeFilterText.Trim());

            edamamResponse = result;

            // Populate the list view
            RecipeListView.IsRefreshing = false;
            result.Hits.ForEach(hit => Recipes.Add(hit.Recipe));
        }
        public void Update()
        {
            Recipes.Clear();

            using (IRecipeController controller = factory.CreateRecipeController())
            {
                DataControllerMessage <IEnumerable <RecipeDisplayDTO> > controllerMessage = controller.GetAll();
                if (controllerMessage.IsSuccess)
                {
                    foreach (RecipeDisplayDTO recipe in controllerMessage.Data)
                    {
                        Recipes.Add(recipe);
                    }
                }
            }
        }
Пример #26
0
        internal void ExecuteVeganAndVegetarianFilter()
        {
            ObservableCollection <Recipe> newList = new ObservableCollection <Recipe>();

            foreach (Recipe r in Recipes)
            {
                if (r.IsVegan && r.IsVegetarian)
                {
                    newList.Add(r);
                }
            }
            Recipes.Clear();
            foreach (Recipe r in newList)
            {
                Recipes.Add(r);
            }
        }
Пример #27
0
        private void LoadRecipes()
        {
            if (!File.Exists(filePathMeal))
            {
                return;
            }

            Recipes.Clear();

            var conten = File.ReadAllText(filePathMeal, Encoding.UTF8);
            var list   = JsonConvert.DeserializeObject <List <MealSaveModel> >(conten);

            Dictionary <String, ConsumableViewModel> foods = new Dictionary <string, ConsumableViewModel>();

            foreach (ConsumableViewModel x in mainViewModel.Consumables.Consumables)
            {
                foods.Add(x.Id, x);
            }

            foreach (MealSaveModel mealSaveModel in list)
            {
                RecipeViewModel mealViewModel = new RecipeViewModel()
                {
                    Id   = mealSaveModel.Id,
                    Name = mealSaveModel.Name
                };
                foreach (MealSaveModel.MealItemSaveModel mealItemSaveModel in mealSaveModel.Items)
                {
                    if (!foods.ContainsKey(mealItemSaveModel.FoodId))
                    {
                        continue;
                    }
                    var food = foods[mealItemSaveModel.FoodId];
                    mealViewModel.FoodItems.Add(new RecipeItemViewModel()
                    {
                        Consumable = food,
                        Quantity   = mealItemSaveModel.Quantity
                    });
                }
                if (mealViewModel.FoodItems.Count > 0)
                {
                    Recipes.Add(mealViewModel);
                }
            }
        }
Пример #28
0
        public async void SearchRecipe()
        {
            Recipes.Clear();
            IEnumerable <Recipe> data;

            if (_currentRecipeType == RecipeType.Cooking)
            {
                data = BdoDataService.GetCookingRecipeByName(SearchStr);
                await Task.CompletedTask;
            }
            else
            {
                data = BdoDataService.GetAlchemyRecipeByName(SearchStr);
                await Task.CompletedTask;
            }

            Recipes.AddRange(data);
            NotifyOfPropertyChange(() => Recipes);
        }
Пример #29
0
 public void getPatientHistoryByDrug()
 {
     try
     {
         Recipes.Clear();
         string medicineId = null;
         if (MedicineSelected != null)
         {
             medicineId = StatisticsM.GetMedicineId(MedicineSelected);
         }
         foreach (var item in StatisticsM.getPatientHistoryByDrug(DateStart, DateFinish, PatientSelected, medicineId))
         {
             Recipes.Add(item);
         }
     }
     catch (Exception e)
     {
         (App.Current as App).navigation.MainWindows.comments.Text = e.Message.ToString();
     }
 }
        public void Init(RecipeDetailedListParameters parameters)
        {
            Recipes.Clear();
            _query = new RecipeQuery
            {
                CategoryId   = parameters.CategorySelected ? parameters.CategoryId : (int?)null,
                OnlyFavorite = parameters.IsFavoriteSelected,
                SearchTerm   = parameters.SearchTerm
            };
            var recipes = _recipeService.SearchRecipesAsync(_query).Result;

            foreach (var recipe in recipes)
            {
                Recipes.Add(recipe.ToRecipeDisplayViewModel());
            }
            var selected = Recipes.First(x => x.Id == parameters.RecipeId);
            var index    = Recipes.IndexOf(selected);

            SelectedRecipeIndex = index;
        }