Esempio n. 1
0
        public async Task <Boolean> PutCursos(Cursos curso)
        {
            _context.Entry(curso).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }
Esempio n. 2
0
        public async Task <Boolean> PutProfesores(Profesores profesor)
        {
            _context.Entry(profesor).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }
Esempio n. 3
0
        public async Task <Boolean> PutAsignaciones(Asignaciones asignacion)
        {
            _context.Entry(asignacion).State = EntityState.Modified;
            await _context.SaveChangesAsync();

            return(await Task.FromResult(true));
        }
Esempio n. 4
0
 public async Task <Boolean> EditarEstudiante(Estudiantes estudiante)
 {
     try
     {
         context.Entry(estudiante).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 5
0
 public async Task <Boolean> EditarGrupo(Grupos grupo)
 {
     try
     {
         context.Entry(grupo).State = EntityState.Modified;
         await context.SaveChangesAsync();
     }
     catch (DbUpdateConcurrencyException)
     {
         return(false);
     }
     return(true);
 }
Esempio n. 6
0
        public async Task <IActionResult> PutProfesores(int id, Profesores profesores)
        {
            Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context);

            if (profesor == null && profesor.Administrador)
            {
                return(BadRequest());
            }

            if (id != profesores.Id)
            {
                return(BadRequest());
            }

            if (profesor.Id == profesores.Id)
            {
                // Se realiza de esta manera, ya que habría conflicto con la entidad entrante (son iguales),
                // por lo que se modifica la ultima retornada por el ef
                profesor.Cedula          = profesores.Cedula;
                profesor.Nombre          = profesores.Nombre;
                profesor.PrimerApellido  = profesores.PrimerApellido;
                profesor.SegundoApellido = profesores.SegundoApellido;
                profesor.Correo          = profesores.Correo;
                profesor.Contrasenia     = profesores.Contrasenia;

                _context.Entry(profesor).State = EntityState.Modified;
            }
            else
            {
                _context.Entry(profesores).State = EntityState.Modified;
            }

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!ProfesoresExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 7
0
        public async Task <IActionResult> PutCursos(int id, Cursos cursos)
        {
            Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context);

            if (profesor == null)
            {
                return(BadRequest());
            }

            if (id != cursos.Id)
            {
                return(BadRequest());
            }

            _context.Entry(cursos).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!CursosExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
Esempio n. 8
0
        public async Task <IActionResult> PutGrupos(Grupos grupos)
        {
            try
            {
                Profesores profesor = await ComprobacionSesion.ComprobarInicioSesion(HttpContext.Request.Headers, _context);

                if (profesor == null)
                {
                    return(BadRequest());
                }
                _context.Entry(grupos).State = EntityState.Modified;
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                return(BadRequest());
            }

            return(NoContent());
        }