Пример #1
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());
        }
Пример #2
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());
        }
Пример #3
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());
        }
Пример #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());
        }
Пример #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());
        }
Пример #6
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());
        }
Пример #7
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());
        }