Exemple #1
0
        public bool Insert(Student student, string MajorCode)
        {
            var majorCtrl = new MajorsController(this.Connection);
            var major     = majorCtrl.GetByCode(MajorCode);

            student.MajorId = major?.Id;
            return(Insert(student));
        }
        public bool Insert(Student student, string MajorCode)
        {
            var majorCtrl = new MajorsController(this.Connection);
            //this.connection is for using the already initialized connection
            var major = majorCtrl.GetByCode(MajorCode);

            student.MajorId = major?.Id; /* <--if major is null, add it as major id?*/
            return(Insert(student));
        }
Exemple #3
0
        public IEnumerable <StudentAndMajor> GetStudentWithMajor()
        {
            var majCtrl  = new MajorsController(Connection);
            var students = from s in GetAll()
                           join m in majCtrl.GetAll()
                           on s.MajorId equals m.Id into sm
                           from s2 in sm.DefaultIfEmpty()
                           select new StudentAndMajor {
                Id       = s.Id,
                Fullname = $"{s.Firstname} {s.Lastname}",
                Major    = s2?.Description ?? "Undeclared"
            };

            return(students);
        }
        public IEnumerable <StudentAndMajor> GetStudentWithMajor()
        {
            var students     = GetAll();
            var majorCtrl    = new MajorsController(Connection);
            var studentMajor = from s in students
                               join m in majorCtrl.GetAll()
                               on s.MajorId equals m.Id
                               select new StudentAndMajor
            {
                Id       = s.Id,
                Fullname = $"{s.Firstname} {s.Lastname}",
                Major    = m.Description
            };

            return(studentMajor);
        }