public IActionResult Delete(int recipeComponentId)
        {
            var recipeComponent = _recipeComponentData.GetById(recipeComponentId);
            var viewModel       = new RecipeComponentViewModel {
                RecipeComponent = recipeComponent
            };

            return(View(viewModel));
        }
        public IActionResult Edit(int?recipeComponentId)
        {
            var recipeComponent = new RecipeComponent();

            if (recipeComponentId.HasValue)
            {
                recipeComponent = _recipeComponentData.GetById(recipeComponentId.Value);
            }

            var viewModel = new RecipeComponentViewModel {
                RecipeComponent = recipeComponent
            };

            return(View(viewModel));
        }
        public IActionResult Edit(RecipeComponent recipeComponent)
        {
            if (!ModelState.IsValid)
            {
                var viewModel = new RecipeComponentViewModel {
                    RecipeComponent = recipeComponent
                };
                return(View(viewModel));
            }

            if (recipeComponent.Id > 0)
            {
                _recipeComponentData.Update(recipeComponent);
            }
            else
            {
                _recipeComponentData.Add(recipeComponent);
            }
            _recipeComponentData.Commit();
            return(RedirectToAction("Detail", new { recipeComponentId = recipeComponent.Id }));
        }
 public GroupedComponentsPage(bool isEditMode, RecipeViewModel recipeViewModel, RecipeComponentViewModel recipeComponentViewModel)
 {
     InitializeComponent();
     BindingContext = new GroupedComponentsViewModel(isEditMode, recipeViewModel, recipeComponentViewModel);
 }
Example #5
0
 public RecipeComponentPage(RecipeComponentViewModel viewModel)
 {
     InitializeComponent();
     ViewModel      = viewModel;
     BindingContext = ViewModel;
 }