Exemplo n.º 1
0
        public void OnGet()
        {
            Product p = TempData.ContainsKey("product")
                        ? JsonSerializer.Deserialize <Product>(TempData["product"] as string)
                        : new Product();

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

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