示例#1
0
        static void Main(string[] args)
        {
            #region Day #9 C#

            /*
             * // Day 9 C# : C# to SQL ------------------------------------------------------
             *
             * var sql = new EducDbLib();
             * sql.Connect("EdDb");
             * Console.WriteLine("Connection successful");
             * sql.ExecSelect();
             * sql.Disconnect();
             */
            #endregion
            #region Day #10 C#

            /*
             * // Day 10 C# : Contd. C# to SQL ------------------------------------------------
             *
             * var conn = new Connection();
             * conn.Connect("EdDb");
             * var studentController = new StudentsController(conn);
             *
             * // ------------- Update() -------------------
             * var updateStudent = new Student
             * {
             *   Id = 74,
             *   Firstname = "Jane",
             *   Lastname = "Doe",
             *   StateCode = "DE",
             *   SAT = 500,
             *   GPA = 1.5m,
             *   Major = null
             * };
             * var success = studentController.Change(updateStudent);
             *
             * // ------------- Create() -------------------
             *
             * //var newStudent = new Student
             * //{
             * //    Id = 0,
             * //    Firstname = "John",
             * //    Lastname = "Doe",
             * //    StateCode = "DE",
             * //    SAT = 0,
             * //    GPA = 1.2m,
             * //    Major = null
             * //};
             * //var success = studentController.Create(newStudent);
             *
             * // -------------- GetByPK() -----------------
             *
             * var student = studentController.GetByPK(74);
             * Console.WriteLine($"{student.Id} | {student.Firstname} {student.Lastname}");
             *
             * // -------------- Remove() ------------------
             *
             * success = studentController.Remove(75);
             * Console.WriteLine($"Remove worked! {success}");
             *
             * // ------------- GetAll() ------------------
             *
             * var students = studentController.GetAll();
             * foreach (var s in students)
             * {
             *   Console.WriteLine($"{s.Id} | {s.Firstname} {s.Lastname} | {s.Major}");
             * }
             */
            #endregion
            #region Day #11 C#

            /*
             * // Day #11 C# to SQL contd. --------------------------------------------------------
             *
             * var conn = new Connection();
             * conn.Connect("EdDb");
             * var majorsController = new MajorsController(conn);
             *
             * // ------------- Create() ------------------------
             * //var major = new Major { Code = "BAR", Description = "Bar Critic", MinSAT = 800 };
             * //var rc = majorsController.Create(major);
             * //Console.WriteLine($"Create worked: {rc}");
             *
             * // ------------- Update() ------------------------
             *
             *
             *
             * // ------------- GetAll() ------------------------
             *
             * var majors = majorsController.GetAll();
             * foreach(var m in majors)
             * {
             *  Console.WriteLine($"{m.Code} | {m.Description} | MinSAT: {m.MinSAT}");
             * }
             * conn.Disconnect();
             */
            #endregion

            #region Day #12 C#

            var conn = new Connection();
            conn.Connect("EdDb");

            var sctrl    = new StudentsController(conn);
            var students = sctrl.GetAll();

            var mctrl  = new MajorsController(conn);
            var majors = mctrl.GetAll();

            var sm = from s in students
                     join m in majors
                     on s.MajorId equals m.Id
                     select new
            {
                s.Id,
                Name  = s.Firstname + " " + s.Lastname,
                Major = m.Description
            };
            foreach (var s in sm)
            {
                Console.WriteLine($"{s.Id} | {s.Name} | {s.Major}");
            }

            conn.Disconnect();

            #endregion
        }
示例#2
0
        static void Main(string[] args)
        {
            var conn = new Connection();

            conn.Connect("EdDb");
            Console.WriteLine("Connection was succesful!");

            var sctrl    = new StudentsController(conn);
            var students = sctrl.GetAll();

            var mcrtl  = new MajorsController(conn);
            var majors = mcrtl.GetAll();


            var sm = from s in students
                     join m in majors
                     on s.MajoId equals m.Id
                     select new
            {
                s.Id,
                Name  = s.Firstname + " " + s.Lastname,
                Major = m.Description
            };

            foreach (var s in sm)
            {
                Console.WriteLine($"{s.Id} | {s.Name} | {s.Major}");
            }


            conn.Disconnect();
            Console.WriteLine("Disconnect was succesful!");



            // var studentController = new ClassController(conn);
            // var klasses = studentController.GetAll();
            // foreach( var c in klasses)
            // {
            //     Console.WriteLine($"{c.code} | {c.subject} | {c.section} | {c.}");
            // }



            // //var studentController = new StudentsController(conn);       // using the sql connection in the controller to use the same connection for the class

            // //var newStudent = new Student
            // //{
            // //    Id = 0,
            // //    Firstname = "Joesph",
            // //    Lastname = "Biden",
            // //    Statecode = "DC",
            // //    SAT = 1300,
            // //    GPA = 3.2m,
            // //    Major = null
            // //};
            // //var success = studentController.Create(newStudent);

            // //newStudent.Id = 63;
            // //var success = studentController.Change(newStudent);

            // //var student = studentController.GetbyPK(54);
            // //Console.WriteLine($"{student.Id} {student.Firstname} {student.Lastname}");

            // //success = studentController.Remove(61);
            // //Console.WriteLine($"Remove worked? {success}");

            // //success = studentController.RemoveRange(62, 63, 64, 65);

            // //var students = studentController.GetAll();
            // //foreach( var s in students)
            // //{
            // //    Console.WriteLine($"{s.Id} {s.Firstname} {s.Lastname} | {s.Major}");
            // //}



            //// var sql = new EducDbLib();
            //// var sql2 = new EducDbLib();
            //// sql.Connect("EdDb");
            //// Console.WriteLine("Connected successfully!");

            //// //sql.SelectAllStudents();
            //// //sql2.SelectAllMajors();
            //// sql.SelectAllClasses();
            //// sql.Disconnect();
            //// Console.WriteLine("Disconnected successfully!");
        }
示例#3
0
        static void Main(string[] args)
        {
            var conn = new Connection();

            conn.Connect("EdDb");

            var sctrl    = new StudentsController(conn);
            var students = sctrl.GetAll();
            var mctrl    = new MajorsController(conn);
            var majors   = mctrl.GetAll();

            var sm = from s in students
                     join m in majors
                     on s.MajorId equals m.Id
                     select new {
                s.Id,
                Name = s.Firstname + " " + s.Lastname,
                m.Description
            };

            foreach (var s in sm)
            {
                Console.WriteLine($"{s.Id}\t{s.Name}\t{s.Description}");
            }


            #region hide

            // var studentController = new StudentsController(conn);
            // var majorController = new MajorsController(conn);
            // var classController = new ClassesController(conn);



            /*
             *
             * var majors = majorController.GetAll();
             * foreach (var m in majors) {
             *      Console.WriteLine($"{m.Id}:\t {m.Description}\t {m.MinSAT}");
             * }
             *
             * var newMajor = new Major {
             *      Id = 0,
             *      Code = "CRP",
             *      Description = "City and Regional Planning",
             *      MinSAT = 1200
             * };
             *
             * var major = majorController.GetByPKey(6);
             * Console.WriteLine($"{major.Id}:\t {major.Code}\t {major.Description}\t {major.MinSAT}");
             *
             *
             *
             * var newStudent = new Student {
             *      Id = 0,
             *      Firstname = "Joseph",
             *      Lastname = "Biden",
             *      GPA = 3.5m,
             *      Major = null,
             *      SAT = 1300,
             *      StateCode = "PA"
             * };
             *
             *
             * /*
             * var newClass = new Class {
             *      Id = 0,
             *      Code = "MAT151",
             *      Subject = "Math",
             *      Section = 151,
             *      InstructorId = 8
             * };
             *
             * var insert = classController.Create(newClass);
             * newClass.Id = 38;
             * var success = classController.Update(newClass);
             *
             * var classes = classController.ReadAll();
             * foreach (var c in classes) {
             *      Console.WriteLine($"{ c.Id}:\t {c.Code}, {c.Section}\t {c.InstructorId}\t {c.Subject}");
             * }
             *
             * /*
             * var insert = studentController.Create(newStudent);
             * newStudent.Id = 61;
             * var success = studentController.Update(newStudent);
             *
             * var cl = classController.GetByPKey(40);
             * Console.WriteLine($"{ cl.Id}:\t {cl.Code}, {cl.Section}\t {cl.InstructorId}\t {cl.Subject}");
             *
             */

            /*
             *
             * success = studentController.Delete(61);
             * Console.WriteLine($"Remove Success: {success}");
             *
             * success = studentController.DeleteRange(59,60);
             * Console.WriteLine($"Remove Success: {success}");
             */


            /*
             *
             * var students = studentController.GetAll();
             * foreach (var s in students) {
             *      Console.WriteLine($"{ s.Id}:\t {s.Lastname}\t {s.Major}");
             * }
             *
             */

            conn.Disconnect();

            /*
             * var sql = new EduDbLib();
             * sql.Connect("EdDb");
             * Console.WriteLine("Con...\n   nect..\n\t.ion is..\n\t\t weak.\n\t\t\t...J/k the connection is fine.");
             * sql.SelectStudent();
             * // sql.SelectClass();
             * sql.Disconnect();
             */

            #endregion
            var xxcvbnm = 1;
        }
示例#4
0
        static void Main(string[] args)
        {
            var conn = new Connection();

            conn.Connect("EdDb");
            // new things added as of 2/25 thursday

            var sctrl    = new StudentsController(conn);
            var students = sctrl.GetAll();

            var mctrl  = new MajorsController(conn);
            var majors = mctrl.GetAll();

            var sm = from s in students
                     join m in majors
                     on s.MajorId equals m.Id
                     select new {
                s.Id, Name = s.Firstname + " " + s.Lastname, Major = m.Description
            };

            foreach (var s in sm)
            {
                Console.WriteLine($"{s.Id} | {s.Name} | {s.Major}");
            }

            conn.Disconnect();

            //var majorController = new MajorsController(conn);

            //var newMajor = new Major {
            // Code = "UWB2", Description = $"Under Water Basket Weaving2", MinSat = 1200
            //};


            //var success = majorController.Create(newMajor);
            //Console.WriteLine($"{success}");

            //var majorsList = majorController.GetAll();
            //foreach(Major m in majorsList) {
            //    Console.WriteLine($"{m.Code}, {m.Description}, {m.MinSat}");
            //}

            // here we are creating a connection that allows us to connect and view all the tables without having to multipleclass connections for more tables, we are breaking things up to make it more neat
            //var conn = new Connection();
            //conn.Connect("EdDb");
            //var studentController = new StudentsController(conn);

            //this is for the insert I think?
            //var newStudent = new Student {
            //    Id = 0, Firstname = "Joseph", Lastname = "Biden", StateCode = "DC", SAT = 1300, GPA = 3.2m, Major = null
            //};
            //var success = studentController.Create(newStudent); // commented these out so it stops adding more joes

            //newStudent.Id = 61;
            //var success = studentController.Change(newStudent);


            //var student = studentController.GetByPk(61); // have becaa explain this
            //Console.WriteLine($"{student.Id}|{student.Firstname} {student.Lastname}|");

            //success = studentController.Remove(61);
            //Console.WriteLine($"Remove worked? {success}");

            //success = studentController.RemovedRanage(63, 64, 65);

            //var students = studentController.GetAll();
            //foreach(var s in students) {
            //    Console.WriteLine($"{s.Id}|{s.Firstname} {s.Lastname}|{s.Major}");
            //} // commented these out so it stops adding more joes



            // format before we started moding it, this is the simple version.
            //var sql = new Edlib();
            //sql.Connect("EdDb");
            //Console.WriteLine("connected successfully!");
            //sql.execSelect();
            //sql.majorSelect(); // my attempt at making a method select from major, just copied what I had already
            //sql.classSelect(); // in class assignment to pull from class
            //sql.Disconnect();
        }
示例#5
0
        static void Main(string[] args)
        {
            var conn = new Connection();

            conn.Connect("EdDb");

            var sctrl    = new StudentsController(conn);
            var students = sctrl.GetAll();

            var mctrl  = new MajorsController(conn);
            var majors = mctrl.GetAll();

            var sm = from s in students
                     join m in majors
                     on s.MajorId equals m.Id
                     select new {
                s.Id, Name = s.Firstname + " " + s.Lastname, Major = m.Description
            };

            foreach (var s in sm)
            {
                Console.WriteLine($"{s.Id} | {s.Name} | {s.Major}");
            }


            conn.Disconnect();

            #region MajorsController
            //var majorsController = new MajorsController(conn);

            //var major = new Major { Code = "BAR", Description = "Bar Critic", MinSAT = 800 };
            //var rc = majorsController.Create(major);
            //Console.WriteLine($"Create Worked - {rc}");
            //major.Id = 15;
            //major.Description = "Advanced Bar Critic";
            //major.MinSAT = 1590;
            //rc = majorsController.Change(major);
            //Console.WriteLine($"Changed Worked - {rc}");
            //major = majorsController.GetByPK(major.Id);
            //Console.WriteLine($"GetByPK Worked - {major != null}");
            //var majors = majorsController.GetAll();
            //foreach(var m in majors) {
            //    Console.WriteLine($"{m.Id}|{m.Description}|{m.MinSAT}");
            //}
            //rc = majorsController.Remove(major.Id);
            //Console.WriteLine($"Remove Worked - {rc}");
            #endregion
            #region StudentsController Testing
            //var studentController = new StudentsController(conn);

            //var newStudent = new Student {
            //    Id = 0, Firstname = "Joseph", Lastname = "Biden", StateCode = "DC",
            //    SAT = 1350, GPA = 3.7m, Major = null
            //};
            //var success = studentController.Create(newStudent);

            //newStudent.Id = 61;
            //var success = studentController.Change(newStudent);

            //var student = studentController.GetByPK(61);
            //Console.WriteLine($"{student.Id}|{student.Firstname} {student.Lastname}");

            //success = studentController.Remove(61);
            //Console.WriteLine($"Remove worked? {success}");

            //success = studentController.RemoveRange(59, 60, 62);

            //var students = studentController.GetAll();
            //foreach(var s in students) {
            //    Console.WriteLine($"{s.Id}|{s.Firstname} {s.Lastname}|{s.Major}");
            //}

            #endregion
        }