Пример #1
0
        private void ClearCategorySelection_Click(object sender, RoutedEventArgs e)
        {
            RecipeListViewModel vm = DataContext as RecipeListViewModel;

            vm.SelectedCategory = null;
            //ExecuteSearch();
        }
        public UIElement GetListView()
        {
            RecipeListViewModel viewModel = new RecipeListViewModel(factory, this);
            RecipeListView      view      = new RecipeListView(viewModel);

            return(view);
        }
Пример #3
0
        public IActionResult Index(int?page, string sortBy, string searchTerm, string searchFilter)
        {
            var recipes = _recipeData.GetRecipeBy(searchFilter, searchTerm).ToList();


            if (!page.HasValue)
            {
                page = 1;
            }


            if (string.IsNullOrWhiteSpace(sortBy))
            {
                sortBy = "name";
            }

            var viewModel = new RecipeListViewModel
            {
                Recipes = recipes,
                Page    = page.Value,
                SortBy  = sortBy
            };

            return(View(viewModel));
        }
Пример #4
0
 private void RemoveRecipe_Click(object sender, RoutedEventArgs e)
 {
     if (sender is Button button && button.DataContext is Recipe recipe)
     {
         RecipeListViewModel vm = DataContext as RecipeListViewModel;
         vm.SelectedRecipeForDeletion = recipe;
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="ProducersAndMaterialsTabItemViewModel"/> class.
 /// </summary>
 /// <param name="modalDialogProvider">The modal dialog service.</param>
 /// <param name="serviceFactory">The service factory.</param>
 public RecipesTabItemViewModel(IMainViewModel mainViewModel, IModalDialogProvider modalDialogProvider, IServiceFactory serviceFactory)
     : base(mainViewModel, modalDialogProvider, serviceFactory)
 {
     RecipeDetailsViewModel = new RecipeDetailsViewModel(MainViewModel, ModalDialogProvider, ServiceFactory);
       RecipeListViewModel = new RecipeListViewModel(MainViewModel, RecipeDetailsViewModel, ModalDialogProvider, ServiceFactory);
       RecipeComponentDetailsViewModel = new RecipeComponentDetailsViewModel(MainViewModel, ModalDialogProvider, ServiceFactory);
       RecipeComponentListViewModel = new RecipeComponentListViewModel(MainViewModel, RecipeComponentDetailsViewModel, ModalDialogProvider, ServiceFactory);
 }
Пример #6
0
 private void Recipes_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sender is ListView recipeList)
     {
         RecipeListViewModel vm = DataContext as RecipeListViewModel;
         vm.SelectedRecipes = recipeList.SelectedItems.Cast <Recipe>().ToList();
     }
 }
 public void SetUp()
 {
     _recipeSizeWidth = 220;
     _model           = Substitute.For <IRecipeListModel>();
     _foodplan        = Substitute.For <IFoodplanModel>();
     _shoppingList    = Substitute.For <IShoppingListModel>();
     _uut             = new RecipeListViewModel(_model, _recipeSizeWidth, _foodplan, _shoppingList);
 }
Пример #8
0
 private void Chip_DeleteClick(object sender, RoutedEventArgs e)
 {
     if (sender is Chip chip && chip.DataContext is FilterObject ingredient)
     {
         RecipeListViewModel vm = DataContext as RecipeListViewModel;
         vm.SelectedIngredients.Remove(ingredient);
         ExecuteSearch();
     }
 }
Пример #9
0
        private void ConfirmRemoveRecipe_Click(object sender, RoutedEventArgs e)
        {
            RecipeListViewModel vm = DataContext as RecipeListViewModel;

            vm.SelectedRecipeForDeletion.Delete();
            App.AvailableRecipes.Remove(vm.SelectedRecipeForDeletion);
            App.LoadHistory();
            ReloadList();
        }
Пример #10
0
 public RecipeListView(
     Task <List <Recipe> > loadTask,
     LocalDataManager localDataManager,
     string titleString,
     string noResultsString,
     bool containsSavedItems = false)
 {
     InitializeComponent();
     BindingContext = new RecipeListViewModel(loadTask, localDataManager, Navigation, titleString, noResultsString, containsSavedItems);
 }
Пример #11
0
        // GET: Recipe
        public ActionResult Index()
        {
            var model        = new RecipeListViewModel();
            var recipeDoms   = this.manager.GetAll();
            var modelRecipes = recipeDoms.Select(r => new RecipeViewModel(r));

            model.Recipes = modelRecipes.ToList();

            return(View(model));
        }
Пример #12
0
        public async Task <IActionResult> List()
        {
            var recipes = await _recipeFacade.GetAllAsync();

            var recipeListViewModel = new RecipeListViewModel
            {
                Recipes = recipes
            };

            return(View(recipeListViewModel));
        }
Пример #13
0
        public ActionResult Index()
        {
            var dbcon = new Db();

            var recipes = dbcon.GetAllRecipe();
            var model   = new RecipeListViewModel {
                Recipes = recipes
            };

            return(View(model));
        }
Пример #14
0
        public void SetCategoryFilter(Category category)
        {
            RecipeListViewModel vm = DataContext as RecipeListViewModel;

            if (!vm.SearchByCategory)
            {
                vm.SearchByCategory = true;
            }
            vm.SelectedCategory = vm.AvailableCategories.FirstOrDefault(x => x.Name == category.Name);
            ExecuteSearch();
        }
Пример #15
0
        public RecipesListViewModelTests()
        {
            _recipeRepositoryMock = new Mock <IRecipeRepository>();
            _mediatorMock         = new Mock <Mediator> {
                CallBase = true
            };

            _recipeRepositoryMock.Setup(repository => repository.GetAll())
            .Returns(() => new List <RecipeListModel>());

            _recipeListViewModelSUT = new RecipeListViewModel(_recipeRepositoryMock.Object, _mediatorMock.Object);
        }
Пример #16
0
        public static RecipeListViewModel GetFavourites()
        {
            var favourites = new RecipeListViewModel();

            foreach (var r in recipes)
            {
                if (r.IsFavourite)
                {
                    favourites.Add(r);
                }
            }
            return(favourites);
        }
Пример #17
0
 private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (sender is ComboBox ingredients && ingredients.SelectedItem is FilterObject ingredient)
     {
         RecipeListViewModel vm = DataContext as RecipeListViewModel;
         if (!vm.SelectedIngredients.Contains(ingredient))
         {
             vm.SelectedIngredients.Add(ingredient);
         }
         ingredients.SelectedItem = null;
         ExecuteSearch();
     }
 }
        public IActionResult All(int id = 1)
        {
            const int ItemPerPage = 12;

            var viewModel = new RecipeListViewModel
            {
                ItemPerPage  = ItemPerPage,
                PageNumber   = id,
                RecipesCount = this.recipesService.GetCount(),
                Recipes      = this.recipesService.GetAll(id, ItemPerPage),
            };

            return(this.View(viewModel));
        }
Пример #19
0
        public ViewResult List()
        {
            IEnumerable <Recipe>   reipes;
            IEnumerable <Category> categories;

            //categories = _categoyRepository.GetFavoriteCategories();

            reipes = _recipeRepository.Recipies;
            RecipeListViewModel vm = new RecipeListViewModel();


            vm.Recipes        = reipes;
            vm.RecipeCategory = "Break Fast";
            return(View(vm));
        }
        public ViewResult List()
        {
            var vm = new RecipeListViewModel {
                Recipes = data.Recipes.List(new QueryOptions <Recipe> {
                    OrderBy = r => r.RecipeName
                }),
                Ingredients = data.Ingredients.List(new QueryOptions <Ingredient> {
                    OrderBy = i => i.IngredientName
                }),
                RecipeCategorys = data.RecipeCategorys.List(new QueryOptions <RecipeCategory> {
                    OrderBy = c => c.RecipeCategoryName
                })
            };

            return(View(vm));
        }
Пример #21
0
        private List <RecipeListViewModel> CreateRecipeList(List <Ingredient> selectedIngredients)
        {
            List <RecipeListViewModel> recipeListViewModel = new List <RecipeListViewModel>();

            List <Recipe> recipeList = _context.RecipeIngredients
                                       .Where(ri => selectedIngredients.Contains(ri.Ingredient))
                                       .Include(ri => ri.Recipe)
                                       .ThenInclude(r => r.RecipeIngredients)
                                       .ThenInclude(i => i.Ingredient)
                                       .Select(ri => ri.Recipe)
                                       .Distinct()
                                       .ToList();

            if (recipeList.Count < 1)
            {
                TempData["NoRecipiesError"] = "NO RECIPIES WERE FOUND THAT HAD THE INGREDIENTS YOU SELECTED.";
            }
            foreach (var recipe in recipeList)
            {
                RecipeListViewModel recipeToAdd = new RecipeListViewModel();

                recipeToAdd.RecipeId    = recipe.RecipeId;
                recipeToAdd.Name        = recipe.Name;
                recipeToAdd.Picture     = recipe.Picture;
                recipeToAdd.Ingredients = recipe.RecipeIngredients.Select(i => i.Ingredient);

                var ingredientsInRecipeCount         = recipeToAdd.Ingredients.Count();
                var selectedIngredientsInRecipeCount = 0;

                foreach (Ingredient ingredient in recipeToAdd.Ingredients)
                {
                    foreach (Ingredient selectedIngredient in selectedIngredients)
                    {
                        if (ingredient.IngredientNameId == selectedIngredient.IngredientNameId)
                        {
                            selectedIngredientsInRecipeCount++;
                        }
                    }
                }

                recipeToAdd.PercentIngredientMatch = selectedIngredientsInRecipeCount / (double)ingredientsInRecipeCount;

                recipeListViewModel.Add(recipeToAdd);
            }

            return(recipeListViewModel.OrderByDescending(r => r.PercentIngredientMatch).ToList());
        }
Пример #22
0
        protected override void OnAppearing()
        {
            try
            {
                var viewModel = new RecipeListViewModel();

                BindingContext                = viewModel;
                btnSearch.Command             = viewModel.SearchCommand;
                ListViewRecipes.ItemSelected += ListView_ItemSelected;
            }
            catch (Exception exc)
            {
                DisplayAlert("Refeições Planejadas", "Ocorreu um problema ao obter as receitas", "Ok");
            }

            base.OnAppearing();
        }
Пример #23
0
 /// <summary>
 /// Sets upp all the ViewModels and Models
 /// </summary>
 public ViewModelLocator()
 {
     _messageBoxService = new MessageBoxService();
     _loginModel        = new LoginModel(new UserHttpCollector(5));
     _foodplanCollector = new FoodplanHttpCollector();
     _loginViewModel    = new LoginViewModel(_loginModel, _messageBoxService, new WindowOpeningService());
     _recipeListModel   = new RecipeListModel(new RecipeHTTPCollector());
     _shoppingListModel = new ScheduledShoppingListModel
                              (new ItemHttpCollector(), new TimerScheduler(60), _loginModel);
     _shoppingListViewModel = new ShoppingListViewModel(_shoppingListModel);
     _foodplanModel         = new FoodplanModel
                                  (_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _messageBoxService);
     _recipeViewModel          = new RecipeListViewModel(_recipeListModel, 300, _foodplanModel, _messageBoxService);
     _addRecipeWindowViewModel = new AddRecipeWindowViewModel(_recipeListModel, new DialogImageChooser());
     _foodplanViewModel        = new FoodplanViewModel(_foodplanModel);
     _mwmvvm = new MainWindowViewModel();
 }
Пример #24
0
        public static RecipeListViewModel Search(string text, string categoryId)
        {
            var category = categories.FirstOrDefault(c => c.Id.ToString().Equals(categoryId));

            var matches = new RecipeListViewModel();

            foreach (var r in category.RelatedRecipes)
            {
                // check Name and Description
                var isMatch = r.Name.Contains(text) || r.Description.Contains(text);
                if (!isMatch)
                {
                    r.LoadDetails();
                    // check Ingredients
                    foreach (var ingredient in r.Ingredients)
                    {
                        if (ingredient.Name.Contains(text) || ingredient.Unit.Contains(text))
                        {
                            isMatch = true;
                            break;
                        }
                    }

                    if (!isMatch)
                    {
                        // check Steps
                        foreach (var step in r.Steps)
                        {
                            if (step.Step.Contains(text))
                            {
                                isMatch = true;
                                break;
                            }
                        }
                    }
                }

                if (isMatch)
                {
                    matches.Add(r);
                }
            }

            return(matches);
        }
Пример #25
0
        public static RecipeListViewModel Search(string text)
        {
            var matches = new RecipeListViewModel();

            foreach (var r in recipes)
            {
                // check Name and Description
                var isMatch = r.Name.Contains(text) || r.Description.Contains(text);
                if (!isMatch)
                {
                    r.LoadDetails();
                    // check Ingredients
                    foreach (var ingredient in r.Ingredients)
                    {
                        if (ingredient.Name.Contains(text) || ingredient.Unit.Contains(text))
                        {
                            isMatch = true;
                            break;
                        }
                    }

                    if (!isMatch)
                    {
                        // check Steps
                        foreach (var step in r.Steps)
                        {
                            if (step.Step.Contains(text))
                            {
                                isMatch = true;
                                break;
                            }
                        }
                    }
                }

                if (isMatch)
                {
                    matches.Add(r);
                }
            }

            return(matches);
        }
Пример #26
0
        public ActionResult Index(string Category = null)
        {
            List <Recipe>         recipes;
            List <RecipeCategory> categories = recipeCategories.Collection().ToList();

            if (Category == null)
            {
                recipes = context.Collection().ToList();
            }
            else
            {
                recipes = context.Collection().Where(p => p.Category == Category).ToList();
            }

            RecipeListViewModel model = new RecipeListViewModel();

            model.recipes          = recipes;
            model.recipeCategories = categories;
            return(View(model));
        }
Пример #27
0
        public void SetUp()
        {
            _recipeSizeWidth = 220;
            //Setup mocks
            _foodplanCollector = Substitute.For <IFoodplanCollector>();
            _recipeCollector   = Substitute.For <IRecipeCollector>();
            _msgService        = Substitute.For <IMessageBoxService>();
            _itemCollector     = Substitute.For <IItemCollector>();
            _userCollector     = Substitute.For <IUserCollector>();
            _shoppingListModel = Substitute.For <IShoppingListModel>();

            //Setup reals
            _loginModel      = new LoginModel(_userCollector);
            _recipeListModel = new RecipeListModel(_recipeCollector);
            _foodplanModel   = new FoodplanModel(_foodplanCollector, _shoppingListModel, _recipeListModel, _loginModel, _msgService);
            _foodplanModel.Foodplan.RecipeList = new List <Tuple <Recipe, DateTime> >();
            _sut = new RecipeListViewModel(_recipeListModel, _recipeSizeWidth, _foodplanModel, _msgService);

            //Login with Henrik
            _userCollector.DoesUserExist("", "").ReturnsForAnyArgs(true);
            _loginModel.Login("Henrik", "secret");
        }
Пример #28
0
        public ActionResult All(int page = 1)
        {
            int totalRecipes = this.recipes.GetAll().Count();
            int totalPages   = (int)Math.Ceiling(totalRecipes / (decimal)3);

            var recipesResult = this.Cache.Get(
                RecipeChacheKey + page.ToString(),
                () => this.recipes
                .Get(page)
                .ProjectTo <RecipeViewModel>()
                .ToList(),
                1 * 60);

            RecipeListViewModel viewModel = new RecipeListViewModel()
            {
                CurrentPage = page,
                TotalPages  = totalPages,
                Recipes     = recipesResult
            };

            return(this.View(viewModel));
        }
Пример #29
0
        public InventoryModule()
        {
            ListInventoryItemsCommand = new CategoryCommand<string>(Resources.InventoryItems, Resources.Products, OnListInventoryItems) { Order = 26 };
            ListRecipesCommand = new CategoryCommand<string>(Resources.Recipes, Resources.Products, OnListRecipes) { Order = 27 };
            ListTransactionsCommand = new CategoryCommand<string>(Resources.Transactions, Resources.Products, OnListTransactions) { Order = 28 };
            ListPeriodicConsumptionsCommand = new CategoryCommand<string>(Resources.EndOfDayRecords, Resources.Products, OnListPeriodicConsumptions) { Order = 29 };

            EventServiceFactory.EventService.GetEvent<GenericEvent<VisibleViewModelBase>>().Subscribe(s =>
            {
                if (s.Topic == EventTopicNames.ViewClosed)
                {
                    if (s.Value == _inventoryItemListViewModel)
                        _inventoryItemListViewModel = null;
                    if (s.Value == _recipeListViewModel)
                        _recipeListViewModel = null;
                    if (s.Value == _transactionListViewModel)
                        _transactionListViewModel = null;
                    if (s.Value == _periodicConsumptionListViewModel)
                        _periodicConsumptionListViewModel = null;
                }
            });

            EventServiceFactory.EventService.GetEvent<GenericEvent<WorkPeriod>>().Subscribe(OnWorkperiodStatusChanged);
        }
Пример #30
0
 public RecipeListView(RecipeListViewModel recipeListViewModel)
     : base(recipeListViewModel)
 {
     InitializeComponent();
 }
Пример #31
0
 private void OnListRecipes(string obj)
 {
     if (_recipeListViewModel == null)
         _recipeListViewModel = new RecipeListViewModel();
     CommonEventPublisher.PublishViewAddedEvent(_recipeListViewModel);
 }
Пример #32
0
 public RecipeListView(RecipeListViewModel viewModel)
 {
     InitializeComponent();
     this.DataContext = viewModel;
 }
Пример #33
0
 public RecipeListView()
 {
     InitializeComponent();
     BindingContext = new RecipeListViewModel(Navigation);
 }