public async Task <ActionResult <TFC> > PostTFC(TFC tFC) { _context.TFCs.Add(tFC); await _context.SaveChangesAsync(); return(CreatedAtAction("GetTFC", new { id = tFC.ID }, tFC)); }
public async Task <IActionResult> Edit(int id, [Bind("TFCId,CargoID,FuncionarioId,TarefaId")] TFC tFC) { if (id != tFC.TFCId) { return(NotFound()); } if (ModelState.IsValid) { try { _context.Update(tFC); await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TFCExists(tFC.TFCId)) { return(NotFound()); } else { throw; } } return(RedirectToAction(nameof(Index))); } ViewData["CargoID"] = new SelectList(_context.Cargo, "CargoId", "NomeCargo", tFC.CargoID); ViewData["FuncionarioId"] = new SelectList(_context.Funcionario, "FuncionarioId", "Nome", tFC.FuncionarioId); ViewData["TarefaId"] = new SelectList(_context.Tarefa, "TarefaId", "NomeTarefa", tFC.TarefaId); return(View(tFC)); }
public async Task <IActionResult> PutTFC(int id, TFC tFC) { if (id != tFC.ID) { return(BadRequest()); } _context.Entry(tFC).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!TFCExists(id)) { return(NotFound()); } else { throw; } } return(NoContent()); }
public async Task <IActionResult> Create([Bind("TFCId,CargoID,FuncionarioId,TarefaId")] TFC tFC) { if (ModelState.IsValid) { _context.Add(tFC); await _context.SaveChangesAsync(); return(RedirectToAction(nameof(Index))); } ViewData["CargoID"] = new SelectList(_context.Cargo, "CargoId", "NomeCargo", tFC.CargoID); ViewData["FuncionarioId"] = new SelectList(_context.Funcionario, "FuncionarioId", "Nome", tFC.FuncionarioId); ViewData["TarefaId"] = new SelectList(_context.Tarefa, "TarefaId", "NomeTarefa", tFC.TarefaId); return(View(tFC)); }