Exemplo n.º 1
0
        public async Task <IActionResult> PutCategoria(int id, Categoria categoria)
        {
            if (id != categoria.Id)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 2
0
        public async Task <IActionResult> PutGrado(int id, Grado grado)
        {
            if (id != grado.IdGrado)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 3
0
        public async Task <IActionResult> PutEmpresa(int id, Empresa empresa)
        {
            if (empresa.NombreEmpresa.Length < 1)
            {
                return(NotFound("El nombre del empresa no puede estar en blanco"));
            }
            else
            {
                if (id != empresa.IdEmpresa)
                {
                    return(BadRequest());
                }

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

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


            return(NoContent());
        }
Exemplo n.º 4
0
        public async Task <IActionResult> PutResidencial(int id, Residencial residencial)
        {
            if (id != residencial.IdResidencial)
            {
                return(BadRequest());
            }

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

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

            return(NoContent());
        }
Exemplo n.º 5
0
        public async Task <IActionResult> PutCourse(int id, Course course)
        {
            if (course.NombreCourse.Length < 1)
            {
                return(NotFound("El nombre del curso no puede estar en blanco"));
            }
            else
            {
                if (id != course.IdCourse)
                {
                    return(BadRequest());
                }

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

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

            return(NoContent());
        }
Exemplo n.º 6
0
        public async Task <ActionResult <StudentCourse> > PostStudentCourse(StudentCourse studentCourse)
        {
            Student student = await _context.Students.FirstOrDefaultAsync(q => q.IdStudent == studentCourse.IdStudentCourse);


            if (StudentExists(studentCourse.IdStudent) == false)
            {
                return(NotFound("El estudiante debe de existir"));
            }
            else if (CourseExists(studentCourse.IdCourse) == false)
            {
                return(NotFound("La clase debe de existir"));
            }/*
              * else if (student.EstadoStudent != "activo")
              * {
              * return NotFound("El estudiante debe de estar activo");
              * }*/
            if (CountCourses(studentCourse.IdStudent) > 4)
            {
                return(NotFound("El estudiante ha llegado al maximo de clases"));
            }
            else
            {
                _context.StudentCourses.Add(studentCourse);
                await _context.SaveChangesAsync();
            }

            return(NoContent());
        }
Exemplo n.º 7
0
        public async Task <IActionResult> PutProfesional(int id, Profesional profesional)
        {
            if (EmpresaExists(profesional.IdEmpresa) == false)
            {
                return(NotFound("La empresa debe de existir"));
            }
            else
            {
                if (id != profesional.IdProfesional)
                {
                    return(BadRequest());
                }

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

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


            return(NoContent());
        }
Exemplo n.º 8
0
        public async Task <IActionResult> PutStudent(int id, Student student)
        {
            if (student.NombreStudent.Length < 1)
            {
                return(NotFound("El nombre del alumno no puede estar en blanco"));
            }
            else if (student.EdadStudent < 18)
            {
                return(NotFound("El alumno debe ser mayor de 18 años para poder matricularse"));
            }
            else
            {
                if (id != student.IdStudent)
                {
                    return(BadRequest());
                }

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

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


            return(NoContent());
        }