Ejemplo n.º 1
0
        public async Task <ActionResult <TFC> > PostTFC(TFC tFC)
        {
            _context.TFCs.Add(tFC);
            await _context.SaveChangesAsync();

            return(CreatedAtAction("GetTFC", new { id = tFC.ID }, tFC));
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
        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());
        }
Ejemplo n.º 4
0
        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));
        }