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)); }
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); }