Beispiel #1
0
        public IActionResult ManagePOST(StylesViewModel stylesViewModel)
        {
            if (ModelState.IsValid)
            {
                Style style = new Style
                {
                    IdStyle = (stylesViewModel.IdStyle != 0) ? stylesViewModel.IdStyle : 0,
                    Libelle = stylesViewModel.Libelle
                };

                if (stylesViewModel.IdStyle != 0)
                {
                    _styleRepository.Update(style);
                }
                else
                {
                    _styleRepository.Add(style);
                }

                return(RedirectToAction(nameof(StylesController.Index), "Styles", new { area = "Administration" }));
            }
            else
            {
                return(this.View(nameof(StylesController.Manage), stylesViewModel));
            }
        }
Beispiel #2
0
        public IActionResult Manage(int?id, string fonction)
        {
            if ((fonction == "Create" && !id.HasValue) || (fonction == "Edit" && id.HasValue))
            {
                try
                {
                    Style = new StylesViewModel();
                    if (id.HasValue)
                    {
                        Style style = _styleRepository?.Find((int)id);
                        Style = new StylesViewModel
                        {
                            IdStyle = style.IdStyle,
                            Libelle = style.Libelle,
                        };
                    }

                    return(this.View(nameof(StylesController.Manage), Style));
                }
                catch (NullReferenceException e)
                {
                    return(RedirectToAction(nameof(StylesController.Index), "Styles", new { area = "Administration" }));
                }
            }
            else
            {
                return(new StatusCodeResult(404));
            }
        }
        protected override void OnAppearing()
        {
            base.OnAppearing();
            StylesViewModel viewModel = BindingContext as StylesViewModel;

            if (viewModel != null && viewModel.Styles.Count == 0)
            {
                viewModel.ReloadStylesCommand.Execute(null);
            }
        }
        public async Task <ActionResult> Styles()
        {
            var styles = await _homebrewApiService.GetAllStyles();

            var viewModel = new StylesViewModel {
                Styles = styles
            };

            return(View(viewModel));
        }
Beispiel #5
0
 public IActionResult Delete(int id)
 {
     try
     {
         Style           style = _styleRepository.Find(id);
         StylesViewModel vm    = new StylesViewModel
         {
             IdStyle = style.IdStyle,
             Libelle = style.Libelle
         };
         return(this.View(nameof(StylesController.Delete), vm));
     }
     catch (NullReferenceException e)
     {
         return(RedirectToAction(nameof(StylesController.Index), "Styles", new { area = "Administration" }));
     }
 }
Beispiel #6
0
 public IViewComponentResult Invoke(StylesViewModel style)
 {
     return(View(style));
 }
 public StylesPage()
 {
     InitializeComponent();
     BindingContext = new StylesViewModel();
 }