Esempio n. 1
0
        public void OnGet(int id)
        {
            Product p = TempData.ContainsKey("product")
                        ? JsonSerializer.Deserialize <Product>(TempData["product"] as string)
                        : _productRepository.Get(id);

            ProducFormViewModel = ProductFormViewModelFactory.Edit(p, Categories);
        }
Esempio n. 2
0
        public IActionResult OnPost([FromForm] Product product)
        {
            if (ModelState.IsValid)
            {
                _productRepository.Edit(product);
                return(RedirectToPage("/Index"));
            }

            ProducFormViewModel = ProductFormViewModelFactory.Edit(product, Categories);
            return(Page());
        }