Exemple #1
0
        public List <Alumno> Select(Campo campo, string value)
        {
            Filtro fl;

            switch ((TypeFormat)Enum.Parse(typeof(TypeFormat), UtilsConfiguration.GetFormatConfig()))
            {
            case TypeFormat.txt:
                var txt = new StudentTxt <Alumno>();
                fl = new Filtro(txt.ReadAll());
                return(fl.Select(campo, value));

            case TypeFormat.json:
                fl = new Filtro(SingletonJson <Alumno> .Instance.GetList());
                return(fl.Select(campo, value));

            case TypeFormat.xml:
                fl = new Filtro(SingletonXml <Alumno> .Instance.GetList());
                return(fl.Select(campo, value));

            case TypeFormat.sql:
                var sql = new StudentSql <Alumno>();
                fl = new Filtro(sql.ReadAll());
                return(fl.Select(campo, value));

            default:
                var df = new StudentTxt <Alumno>();
                fl = new Filtro(df.ReadAll());
                return(fl.Select(campo, value));
            }
        }
        public void GetStudentsByLnameTest1()
        {
            string lname = "InsertStudentTest1, lname1";

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.GetStudentsByLname(lname));
        }
        public void GetStudentsByFnameTest1()
        {
            string fname = "InsertStudentTest1, happy_path 1";

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.GetStudentsByFname(fname));
        }
        public void GetStudentsByIdTest1()
        {
            int id = 1;

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.GetStudentsById(id));
        }
        public void FindStudentByIdTest1()
        {
            int id = 1;

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.FindStudentById(id));
        }
        public void InsertStudentTest1()
        {
            string fname = "InsertStudentTest1, happy_path 1";
            string lname = "InsertStudentTest1, lname1";

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.InsertStudent(fname, lname));
        }
        public void UpdateStudentTest1()
        {
            int    id    = 1;
            string fname = "UpdateStudentTest1, happy_path 1";
            string lname = "new last name";

            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.UpdateStudent(id, fname, lname));
        }
        public void DeleteStudentTest1()
        {
            StudentSql studentSql = new StudentSql();

            Console.WriteLine(studentSql.DeleteStudent(1)); // requires manual confirmation of valid id.
        }