public JObject GetAllScores()
        {
            var JObject = new JObject();

            try
            {
                var entity = repositorio.GetAll();

                if (entity != null)
                {
                    var json   = JsonConvert.SerializeObject(entity);
                    var arrayr = JArray.Parse(json);
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = arrayr;
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "No existen notas actualmente.";
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var CodigoError = new ErrorCode();
                var error       = CodigoError.Error(e.ToString());
                JObject["Codigo"]      = error;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject CreateScore(Notas notas)
        {
            var JObject = new JObject();

            try
            {
                var score = new Notas
                {
                    IdEstudiante = notas.IdEstudiante,
                    IdMateria    = notas.IdMateria,
                    Nota         = notas.Nota,
                    Descripcion  = notas.Descripcion
                };
                repositorio.Insert(score);
                repositorio.Save();
                JObject["Codigo"]      = "0000";
                JObject["Descripcion"] = "Nota registrada correctamente" + notas.IdNota;
                return(JObject);
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject DeleteScore(Notas notas)
        {
            var JObject = new JObject();

            try
            {
                var score = repositorio.GetByID(notas.IdNota);
                if (score != null)
                {
                    var idScore = notas.IdNota;
                    repositorio.Delete(score);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = idScore;
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "No existen notas";
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var CodigoError = new ErrorCode();
                var error       = CodigoError.Error(e.ToString());
                JObject["Codigo"]      = error;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject DeleteStudent(Alumno alumno)
        {
            var JObject = new JObject();

            try
            {
                var student = repositorio.GetByID(alumno.IdAlumno);
                if (student != null)
                {
                    var idStudent = alumno.IdAlumno;
                    repositorio.Delete(student);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = idStudent;
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "No se encontro alumno";
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var CodigoError = new ErrorCode();
                var error       = CodigoError.Error(e.ToString());
                JObject["Codigo"]      = error;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject UpdateScore(Notas notas)
        {
            var JObject = new JObject();

            try
            {
                var score = repositorio.GetByID(notas.IdNota);
                if (score != null)
                {
                    score.IdEstudiante = notas.IdEstudiante;
                    score.IdMateria    = notas.IdMateria;
                    score.Nota         = notas.Nota;
                    score.Descripcion  = notas.Descripcion;
                    repositorio.Update(score);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = "Registro modificado correctamente";
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "La nota no existe" + notas.IdNota + notas.Nota;
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject CreateStudent(Alumno alumno)
        {
            var JObject = new JObject();

            try
            {
                var student = new Alumno

                {
                    Nombres        = alumno.Nombres,
                    Apellidos      = alumno.Apellidos,
                    Identificacion = alumno.Identificacion,
                    Telefono       = alumno.Telefono,
                    Correo         = alumno.Correo,
                };
                repositorio.Insert(student);
                repositorio.Save();
                JObject["Codigo"]      = "0000";
                JObject["Descripcion"] = "Alumno Creado Correctamente" + student.IdAlumno;
                return(JObject);
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
示例#7
0
        public JObject DeleteSubject(Materia materia)
        {
            var JObject = new JObject();

            try
            {
                var matter = repositorio.GetByID(materia.IdMateria);
                if (matter != null)
                {
                    var idMatter = materia.IdMateria;
                    repositorio.Delete(matter);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = idMatter;
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "La materia no existe";
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var CodigoError = new ErrorCode();
                var error       = CodigoError.Error(e.ToString());
                JObject["Codigo"]      = error;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
示例#8
0
        public JObject CreateSubject(Materia materia)
        {
            var JObject = new JObject();

            try
            {
                var matter = new Materia
                {
                    Nombres     = materia.Nombres,
                    Codigo      = materia.Codigo,
                    Docente     = materia.Docente,
                    Descripcion = materia.Descripcion
                };
                repositorio.Insert(matter);
                repositorio.Save();
                JObject["Codigo"]      = "0000";
                JObject["Descripcion"] = "Materia Creada Correctamente" + matter.IdMateria;
                return(JObject);
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
示例#9
0
        public JObject UpdateSubject(Materia materia)
        {
            var JObject = new JObject();

            try
            {
                var matter = repositorio.GetByID(materia.IdMateria);
                if (matter != null)
                {
                    matter.Nombres     = materia.Nombres;
                    matter.Docente     = materia.Docente;
                    matter.Codigo      = materia.Codigo;
                    matter.Descripcion = materia.Descripcion;
                    repositorio.Update(matter);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = "Registro modificado correctamente";
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "La materia no existe" + materia.IdMateria + materia.Nombres;
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }
        public JObject UpdateStudent(Alumno alumno)
        {
            var JObject = new JObject();

            try
            {
                var student = repositorio.GetByID(alumno.IdAlumno);
                if (student != null)
                {
                    student.Nombres        = alumno.Nombres;
                    student.Apellidos      = alumno.Apellidos;
                    student.Identificacion = alumno.Identificacion;
                    student.Telefono       = alumno.Telefono;
                    student.Correo         = alumno.Correo;
                    repositorio.Update(student);
                    repositorio.Save();
                    JObject["Codigo"]      = "0000";
                    JObject["Descripcion"] = "Registro modificado correctamente";
                    return(JObject);
                }
                else
                {
                    JObject["Codigo"]      = "0100";
                    JObject["Descripcion"] = "El alumno no existe" + student.IdAlumno;
                    return(JObject);
                }
            }
            catch (Exception e)
            {
                var cod         = new ErrorCode();
                var codigoError = cod.Error(e.ToString());
                JObject["Codigo"]      = codigoError;
                JObject["Descripcion"] = e.ToString();
                return(JObject);
            }
        }