Ejemplo n.º 1
0
 public async Task <ActionResult <Pertence> > Edit([FromBody] Pertence pertence)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(pertence);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             return(NotFound());
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(pertence);
 }
Ejemplo n.º 2
0
 public async Task <ActionResult <Ofertar_Turma_Disciplina_Sala> > Edit([FromBody] Ofertar_Turma_Disciplina_Sala ofertar)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(ofertar);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             return(NotFound());
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(ofertar);
 }
Ejemplo n.º 3
0
 public async Task <ActionResult <Curso> > Edit([FromBody] Curso curso)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(curso);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!CursoExists(curso.Id_Curso))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(curso);
 }
 public async Task <ActionResult <Professor> > Edit([FromBody] Professor professor)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(professor);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!ProfessorExists(professor.Id_Professor))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(professor);
 }
Ejemplo n.º 5
0
        public async Task <ActionResult <Turma> > Edit([FromBody] Turma turma)
        {
            if (ModelState.IsValid)
            {
                try
                {
                    await _context.Pertence.FromSqlRaw($"select * from pertence where fk_Turma_Id_Turma = {turma.Id_Turma}")
                    .ForEachAsync(v => _context.Pertence.Remove(v));

                    await _context.Lecionar.FromSqlRaw($"select * from lecionar where fk_Turma_Id_Turma = {turma.Id_Turma}")
                    .ForEachAsync(v => _context.Remove(v));

                    await _context.Ofertar_Turma_Disciplina_Sala.FromSqlRaw($"select * from ofertar_turma_disciplina_sala where fk_Turma_Id_Turma = {turma.Id_Turma}")
                    .ForEachAsync(v => _context.Remove(v));

                    _context.Add(turma.lecionar.FirstOrDefault());
                    _context.Add(turma.ofertar_Turma_Disciplina_Sala.FirstOrDefault());
                    _context.Add(turma.pertence.FirstOrDefault());
                    _context.Update(turma);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!TurmaExists(turma.Id_Turma))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(turma);
        }
 public async Task <ActionResult <Disciplina> > Edit([FromBody] Disciplina disciplina)
 {
     if (ModelState.IsValid)
     {
         try
         {
             _context.Update(disciplina);
             await _context.SaveChangesAsync();
         }
         catch (DbUpdateConcurrencyException)
         {
             if (!DisciplinaExists(disciplina.Id_Materia))
             {
                 return(NotFound());
             }
             else
             {
                 throw;
             }
         }
         return(RedirectToAction(nameof(Index)));
     }
     return(disciplina);
 }