/// <summary> /// Load the user's curriculum /// </summary> /// <param name="user">The user to load curriculum for</param> /// <returns></returns> public ObservableCollection<Course> LoadUserCurriculum(LbcUser user, ref ObservableCollection<CoursePermission> coursePermissions, ref ObservableCollection<CourseMeta> metaData) { ObservableCollection<Course> userCourses = new ObservableCollection<Course>(); List<CoursePermission> userPermissions; metaData = new ObservableCollection<CourseMeta>(); coursePermissions = new ObservableCollection<CoursePermission>(); CourseMeta tmpMeta = new CourseMeta(); try { userPermissions = Session.DbContext.CoursePermissions.Where(cp => cp.LbcUser == user).ToList(); foreach (CoursePermission cp in userPermissions) { tmpMeta = new CourseMeta(); userCourses.Add(cp.Course); coursePermissions.Add(cp); tmpMeta.CourseID = cp.CourseID; tmpMeta.Permission = cp.Permission; metaData.Add(tmpMeta); } return userCourses; } catch { //An error occured while loading the curriculum return null; } finally { //Clean up local variables userCourses = null; userPermissions = null; } }
/// <summary> /// Update the user's last login date and time /// </summary> /// <param name="user">The user to update</param> /// <param name="lastLogin">The last login date for the user</param> public void UpdateUserLastLoginDate(LbcUser user, DateTime lastLogin) { user.LastLogin = lastLogin; }
// =============================================== // Static Methods // =============================================== /// <summary> /// Create an Information message greeting the current user /// </summary> /// <param name="usr"></param> /// <returns></returns> public static Information UserGreeting(LbcUser usr) { string _WelcomeHeader = "Welcome Back, " + usr.FirstName; string _WelcomeMessage; if (usr.LastLogin != null) { DateTime _LastLogin = usr.LastLogin.Value; _WelcomeMessage = "Your last login date was: " + _LastLogin.ToString("f"); } else { _WelcomeMessage = "It appears this is your first time logging in."; } return new Information("Login Success",_WelcomeHeader,_WelcomeMessage); }