public async Task <List <UserLecture> > GetStudentLecturesByUserId(int userId) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.UserLectures.Where(ul => ul.user_id == userId).ToListAsync()); } }
public async Task <List <Lecture> > GetAllLectures() { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Lectures.ToListAsync()); } }
public async Task <List <Lecture> > GetInstructorLecturesById(int userId) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Lectures.Where(l => l.instructor_id == userId).ToListAsync()); } }
public async Task <User> GetUserById(int id) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Users.FirstOrDefaultAsync(u => u.id == id)); } }
public async Task <Lecture> GetLectureByCode(string code) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Lectures.FirstOrDefaultAsync(l => l.code == code)); } }
public async Task <User> GetUserByNo(string no) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Users.FirstOrDefaultAsync(u => u.no == no && u.no != null)); } }
public async Task CreateFaceInfo(FaceInfo faceInfo) { using (var imHereDbContext = new ImHereDbContext()) { imHereDbContext.FaceInfos.Add(faceInfo); await imHereDbContext.SaveChangesAsync(); } }
public async Task CreateUser(User user) { using (var imHereDbContext = new ImHereDbContext()) { imHereDbContext.Users.Add(user); await imHereDbContext.SaveChangesAsync(); } }
public async Task AddAttendenceImage(AttendenceImage attendenceImage) { using (var imHereDbContext = new ImHereDbContext()) { await imHereDbContext.AddAsync(attendenceImage); await imHereDbContext.SaveChangesAsync(); } }
public async Task <UserInfoDto> GetUserInfoById(int id) { using (var imHereDbContext = new ImHereDbContext()) { User user = await imHereDbContext.Users.FirstOrDefaultAsync(u => u.id == id); return(new UserInfoDto(user)); } }
public async Task <AttendenceImage> GetAttendenceImage(string lectureCode, int week) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext .AttendenceImages .FirstOrDefaultAsync(ai => ai.lectureCode == lectureCode && ai.week == week)); } }
public async Task <User> GetUserByEmail(string email) { using (var imHereDbContext = new ImHereDbContext()) { var user = await imHereDbContext.Users.FirstOrDefaultAsync( u => u.email == email); return(user); } }
public async Task <bool> AddAttendence(List <Attendence> attendences) { using (var imHereDbContext = new ImHereDbContext()) { await imHereDbContext.AddRangeAsync(attendences); int numOfChanges = await imHereDbContext.SaveChangesAsync(); return(numOfChanges > 0); } }
public async Task SetIsSelectedLectures(int userId, bool isSelected) { using (var imHereDbContext = new ImHereDbContext()) { User user = await GetUserById(userId); user.isSelectedLecture = isSelected; imHereDbContext.Users.Update(user); await imHereDbContext.SaveChangesAsync(); } }
public async Task <List <Attendence> > GetAttendencesInfo(int userId, string lectureCode) { using (var imHereDbContext = new ImHereDbContext()) { return(await imHereDbContext.Attendences.Where(a => a.user_id == userId && a.lecture_code == lectureCode) .OrderBy(a => a.week) .ToListAsync()); } }
public async Task <bool> IsUserLectureExists(int userId, string lectureCode) { using (var imHereDbContext = new ImHereDbContext()) { List <UserLecture> list = await imHereDbContext.UserLectures .Where(ul => ul.user_id == userId && ul.lecture_code == lectureCode) .ToListAsync(); return(list.Count != 0); } }
public async Task <List <FaceInfo> > GetFaceInfos(string lectureCode) { using (var imHereDbContext = new ImHereDbContext()) { List <int> userIds = await(from userLectures in imHereDbContext.UserLectures where userLectures.lecture_code == lectureCode select userLectures.user_id).ToListAsync(); return(await imHereDbContext.FaceInfos .Where(fi => userIds.Contains(fi.user_id)) .ToListAsync()); } }
public async Task <List <int> > GetCompletedAttendenceWeekInfo(string lectureCode) { using (var imHereDbContext = new ImHereDbContext()) { var weeks = await imHereDbContext.Attendences .Where(a => a.lecture_code == lectureCode) .Select(a => a.week) .Distinct() .ToListAsync(); return(weeks); } }
public async Task <bool> AddUserLectures(int userId, List <string> lectureCodes) { using (var imHereDbContext = new ImHereDbContext()) { foreach (string lectureCode in lectureCodes) { UserLecture userLecture = new UserLecture(); userLecture.lecture_code = lectureCode; userLecture.user_id = userId; imHereDbContext.UserLectures.Add(userLecture); } int numOfObjects = await imHereDbContext.SaveChangesAsync(); return(numOfObjects > 0); } }
public async Task <List <UserInfoDto> > GetStudentsByLecture(string lectureCode) { using (var imHereDbContext = new ImHereDbContext()) { var students = await(from userLectures in imHereDbContext.UserLectures join user in imHereDbContext.Users on userLectures.user_id equals user.id where userLectures.lecture_code == lectureCode select new UserInfoDto( user.id, user.no, user.email, user.name, user.surname, user.role, user.image_url, user.isSelectedLecture)).ToListAsync(); return(students); } }