Ejemplo n.º 1
0
        public async Task <IActionResult> Edit(int id, [Bind("DaDepartamentoid,DaAtendenteid")] DepartamentoAtendente departamentoAtendente)
        {
            if (id != departamentoAtendente.DaDepartamentoid)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(departamentoAtendente);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DepartamentoAtendenteExists(departamentoAtendente.DaDepartamentoid))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DaAtendenteid"]    = new SelectList(_context.Atendente, "AteId", "AteId", departamentoAtendente.DaAtendenteid);
            ViewData["DaDepartamentoid"] = new SelectList(_context.Departamento, "DepId", "DepEmail", departamentoAtendente.DaDepartamentoid);
            return(View(departamentoAtendente));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create([Bind("DaDepartamentoid,DaAtendenteid")] DepartamentoAtendente departamentoAtendente)
        {
            if (ModelState.IsValid)
            {
                _context.Add(departamentoAtendente);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["DaAtendenteid"]    = new SelectList(_context.Atendente, "AteId", "AteId", departamentoAtendente.DaAtendenteid);
            ViewData["DaDepartamentoid"] = new SelectList(_context.Departamento, "DepId", "DepEmail", departamentoAtendente.DaDepartamentoid);
            return(View(departamentoAtendente));
        }