public async Task <IActionResult> Create([Bind("ConfeccaoId,RoupaId,Horario")] Confeccao confeccao) { if (ModelState.IsValid) { _context.Add(confeccao); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["RoupaId"] = new SelectList(_context.Roupa, "RoupaId", "RoupaId", confeccao.RoupaId); return(View(confeccao)); }
public async Task <IActionResult> Create([Bind("RoupaId,Tipos,Quantidade")] Roupa roupa) { if (ModelState.IsValid) { _context.Add(roupa); await _context.SaveChangesAsync(); //return RedirectToAction(nameof(Index)); } if (roupa.Quantidade == 0) { Confeccao c = new Confeccao(); c.Horario = DateTime.Now; c.RoupaId = roupa.RoupaId; _context.Confeccao.Add(c); } await _context.SaveChangesAsync(); return(RedirectToAction("Index", "Roupas")); }