Example #1
0
        public async Task <IActionResult> Edit(int id, [Bind("HorarioId,DisciplinaId")] HorarioDisciplina horarioDisciplina)
        {
            if (id != horarioDisciplina.HorarioId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(horarioDisciplina);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!HorarioDisciplinaExists(horarioDisciplina.HorarioId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HorarioId"]    = new SelectList(_context.Disciplina, "DisciplinaId", "DisciplinaId", horarioDisciplina.HorarioId);
            ViewData["DisciplinaId"] = new SelectList(_context.Horario, "HorarioId", "HorarioId", horarioDisciplina.DisciplinaId);
            return(View(horarioDisciplina));
        }
Example #2
0
        public async Task <IActionResult> Create([Bind("HorarioId,DisciplinaId")] HorarioDisciplina horarioDisciplina)
        {
            if (ModelState.IsValid)
            {
                _context.Add(horarioDisciplina);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["HorarioId"]    = new SelectList(_context.Disciplina, "DisciplinaId", "DisciplinaId", horarioDisciplina.HorarioId);
            ViewData["DisciplinaId"] = new SelectList(_context.Horario, "HorarioId", "HorarioId", horarioDisciplina.DisciplinaId);
            return(View(horarioDisciplina));
        }