예제 #1
0
        public async Task <IActionResult> Create(ProductViewModel model)
        {
            if (ModelState.IsValid)
            {
                var newProduct = new Product
                {
                    Description = model.Description,
                    Type        = model.Type,
                    Category    = model.Category
                };

                await _iProductApp.Add(newProduct);

                var newStockProducts = new StockProducts
                {
                    ProductID = newProduct.ID
                };

                await _iStockProductApp.Add(newStockProducts);

                return(RedirectToAction(nameof(Index),
                                        routeValues: new { stockID = 1, type = model.Type }));
            }
            return(View(model));
        }
예제 #2
0
        public async Task <IActionResult> Create([Bind("Preco,Ativo,Id,Nome")] Product product)
        {
            if (ModelState.IsValid)
            {
                await _productApp.Add(product);

                return(RedirectToAction(nameof(Index)));
            }
            return(View(product));
        }
예제 #3
0
 public async Task <long> Add(NewProduct model)
 {
     return(await productApp.Add(model));
 }