public async Task <IActionResult> Create([Bind("Id,Name,Price")] Product product) { if (ModelState.IsValid) { _context.Add(product); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } return(View(product)); }
public async Task <IActionResult> Create([Bind("IdProduct,Tails")] Foxes foxes) { if (ModelState.IsValid) { _context.Add(foxes); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdProduct"] = new SelectList(_context.Product, "Id", "Id", foxes.IdProduct); return(View(foxes)); }
public async Task <IActionResult> Create([Bind("Sharpness")] Katanas katanas, [Bind("Name,IdProductNavigation.Price")] Product product) { if (ModelState.IsValid) { katanas.IdProductNavigation = new Product() { }; _context.Add(product); await _context.SaveChangesAsync(); katanas.IdProduct = product.Id; _context.Add(katanas); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["IdProduct"] = new SelectList(_context.Product, "Id", "Id", katanas.IdProduct); return(View(katanas)); }