예제 #1
0
        public async Task <IActionResult> Edit(int id, [Bind("Id_Chefia,Nome,Cpf,Rg,Setor")] Chefia chefia)
        {
            if (id != chefia.Id_Chefia)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(chefia);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!ChefiaExists(chefia.Id_Chefia))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(chefia));
        }
        public async Task <ActionResult> Put(Chefia chefia)
        {
            context.Entry(chefia).State = EntityState.Modified;
            await context.SaveChangesAsync();

            return(NoContent());
        }
        public async Task <ActionResult> Criar(Chefia chefia)
        {
            context.Add(chefia);
            await context.SaveChangesAsync();

            return(Ok(chefia.ChefiaId));
        }
예제 #4
0
        public async Task <IActionResult> Create([Bind("Id_Chefia,Nome,Cpf,Rg,Setor")] Chefia chefia)
        {
            if (ModelState.IsValid)
            {
                _context.Add(chefia);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(chefia));
        }