// <summary> /// ขอข้อมูลการขอเป็นเพื่อนจากรหัสบัญชีผู้ใช้ /// </summary> /// <param name="userprofileId">รหัสบัญชีผู้ใช้ที่ต้องการขอข้อมูล</param> public IEnumerable <FriendRequest> GetFriendRequestByUserProfileId(string userprofileId) { var qry = _mongoUtil.GetCollection <FriendRequest>(TableName) .Find(it => !it.DeletedDate.HasValue && it.FromUserProfileId == userprofileId) .ToEnumerable(); return(qry); }
/// <summary> /// ขอข้อมูลการ like comment จากรหัส comment /// </summary> /// <param name="commentId">รหัส comment ที่ต้องการขอข้อมูล</param> public IEnumerable <LikeComment> GetLikeCommentByCommentId(string commentId) { var qry = _mongoUtil.GetCollection <LikeComment>(TableName) .Find(it => !it.DeletedDate.HasValue && it.CommentId == commentId) .ToEnumerable(); return(qry); }
/// <summary> /// ขอข้อมูล course catalog จากรหัส /// </summary> /// <param name="courseCatalogId">รหัส course catalog ที่ต้องการข้อมูล</param> public IEnumerable <CourseCatalog> GetAvailableCourses() { var qry = _mongoUtil.GetCollection <CourseCatalog>(TableName) .Find(it => !it.DeletedDate.HasValue) .ToEnumerable(); return(qry); }
/// <summary> /// ขอข้อมูล notification จากรหัสผู้ใช้และ class room /// </summary> /// <param name="userprofileId">ชื่อผู้ใช้ที่ต้องการค้นหาข้อมูล</param> /// <param name="classRoomId">Class room id</param> public IEnumerable <Notification> GetNotificationByUserIdAndClassRoomId(string userprofileId, string classRoomId) { var qry = _mongoUtil.GetCollection <Notification>(TableName) .Find(it => !it.HideDate.HasValue && it.ClassRoomId == classRoomId && it.ToUserProfileId == userprofileId) .ToEnumerable(); return(qry); }
/// <summary> /// ขอรายการ Like lesson จากรหัส lesson /// </summary> /// <param name="lessonId">รหัส lesson ที่ต้องการขอข้อมูล</param> public IEnumerable <LikeLesson> GetLikeLessonsByLessonId(string lessonId) { var qry = _mongoUtil.GetCollection <LikeLesson>(TableName) .Find(it => !it.DeletedDate.HasValue && it.LessonId == lessonId) .ToEnumerable(); return(qry); }
/// <summary> /// ขอข้อมูล like discussion จากรหัส discussion /// </summary> /// <param name="discussionId">รหัส discussion ที่ต้องการขอข้อมูล</param> public IEnumerable <LikeDiscussion> GetLikeDiscussionByDiscusionId(string discussionId) { var qry = _mongoUtil.GetCollection <LikeDiscussion>(TableName) .Find(it => !it.DeletedDate.HasValue && it.DiscussionId == discussionId) .ToEnumerable(); return(qry); }
public LessonTestResult GetTestedResult(string classRoomId, string lessonId, string username) { var result = _mongoUtil.GetCollection <LessonTestResult>(TableName) .Find(it => it.ClassRoomId == classRoomId && it.LessonId == lessonId && it.UserProfileId == username) .ToEnumerable() .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูล Class room จากรหัส /// </summary> /// <param name="classRoomId">รหัส Class room ที่ต้องการขอ</param> public ClassRoom GetClassRoomById(string classRoomId) { var result = _mongoUtil.GetCollection <ClassRoom>(TableName) .Find(it => !it.DeletedDate.HasValue && it.id == classRoomId) .ToEnumerable() .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูลกิจกรรมต่างๆที่ผู้ใช้ทำกับ class room /// </summary> /// <param name="userprofile">รหัสบัญชีผู้ใช้ที่ต้องการข้อมูล</param> /// <param name="classRoomId">รหัส class room</param> public UserActivity GetUserActivityByUserProfileIdAndClassRoomId(string userprofile, string classRoomId) { var result = _mongoUtil.GetCollection <UserActivity>(TableName) .Find(it => !it.DeletedDate.HasValue && it.UserProfileId == userprofile && it.ClassRoomId == classRoomId) .ToEnumerable() .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูล User profile จากรหัส /// </summary> /// <param name="userprofileId">รหัส User profile ที่จะทำการขอข้อมูล</param> public UserProfile GetUserProfileById(string userprofileId) { var result = _mongoUtil.GetCollection <UserProfile>(TableName) .Find(it => !it.DeletedDate.HasValue && it.id == userprofileId) .ToEnumerable() .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูล Student key ที่สามารถใช้ได้จากรหัส class room /// </summary> /// <param name="classRoomId">รหัส class room ที่ต้องการขอข้อมูล</param> public StudentKey GetStudentKeyByClassRoomId(string classRoomId) { var result = _mongoUtil.GetCollection <StudentKey>(TableName) .Find(it => !it.DeletedDate.HasValue && it.ClassRoomId == classRoomId) .ToEnumerable() .OrderByDescending(it => it.CreatedDate) .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูล Lesson catalog จากรหัส /// </summary> /// <param name="lessonCatalogId">รหัส Lesson catalog ที่ต้องการ</param> public LessonCatalog GetLessonCatalogById(string lessonCatalogId) { var result = _mongoUtil.GetCollection <LessonCatalog>(TableName) .Find(it => !it.DeletedDate.HasValue && it.id == lessonCatalogId) .ToEnumerable() .OrderByDescending(it => it.CreatedDate) .FirstOrDefault(); return(result); }
/// <summary> /// ขอรายการ comment จากรหัสผู้ใช้ที่เกี่ยวข้อง /// </summary> /// <param name="userprofileId"></param> /// <returns></returns> public async Task<IEnumerable<Comment>> GetCommentByRelatedUserProfileId(string userprofileId) { var mongoUtil = new MongoAccess.MongoUtil(PrimaryConnectionString, PrimaryDatabaseName); var qry = (await mongoUtil.GetCollection<Comment>(TableName) .FindAsync(it => !it.DeletedDate.HasValue && (it.CreatedByUserProfileId == userprofileId || it.Discussions.Any(d => !d.DeletedDate.HasValue && d.CreatedByUserProfileId == userprofileId)))) .ToEnumerable(); return qry; }
/// <summary> /// ขอรายการ comment จากรหัสผู้ใช้ที่เกี่ยวข้อง /// </summary> /// <param name="userprofileId"></param> /// <returns></returns> public async Task <IEnumerable <Comment> > GetCommentByRelatedUserProfileId(string userprofileId) { var mongoUtil = new MongoAccess.MongoUtil(PrimaryConnectionString, PrimaryDatabaseName); var qry = (await mongoUtil.GetCollection <Comment>(TableName) .FindAsync(it => !it.DeletedDate.HasValue && (it.CreatedByUserProfileId == userprofileId || it.Discussions.Any(d => !d.DeletedDate.HasValue && d.CreatedByUserProfileId == userprofileId)))) .ToEnumerable(); return(qry); }
/// <summary> /// อัพเดท comment /// </summary> /// <param name="data">Comment ที่จะทำการอัพเดท</param> public async Task UpdateComment(Comment data) { var mongoUtil = new MongoAccess.MongoUtil(PrimaryConnectionString, PrimaryDatabaseName); var filter = Builders<Comment>.Filter.Eq(it => it.id, data.id); var update = Builders<Comment>.Update .Set(it => it.CreatorDisplayName, data.CreatorDisplayName) .Set(it => it.CreatorImageUrl, data.CreatorImageUrl) .Set(it => it.Discussions, data.Discussions); await mongoUtil.GetCollection<Comment>(TableName).UpdateOneAsync(filter, update); }
/// <summary> /// ขอข้อมูล comment จากรหัส lesson และผู้สร้าง comment /// </summary> /// <param name="lessonId">รหัส lesson ที่ต้องการขอข้อมูล</param> /// <param name="creatorProfiles">รายชื่อผู้สร้าง comment ที่ต้องการ</param> public Comment GetCommentById(string commentId) { var result = _mongoUtil.GetCollection <Comment>(TableName) .Find(it => !it.DeletedDate.HasValue && it.id == commentId) .ToEnumerable() .FirstOrDefault(); return(result); }
/// <summary> /// อัพเดท comment /// </summary> /// <param name="data">Comment ที่จะทำการอัพเดท</param> public async Task UpdateComment(Comment data) { var mongoUtil = new MongoAccess.MongoUtil(PrimaryConnectionString, PrimaryDatabaseName); var filter = Builders <Comment> .Filter.Eq(it => it.id, data.id); var update = Builders <Comment> .Update .Set(it => it.CreatorDisplayName, data.CreatorDisplayName) .Set(it => it.CreatorImageUrl, data.CreatorImageUrl) .Set(it => it.Discussions, data.Discussions); await mongoUtil.GetCollection <Comment>(TableName).UpdateOneAsync(filter, update); }
/// <summary> /// ขอข้อมูล contract จากรหัส teacher และ grade ที่ระบุ /// </summary> /// <param name="teacherCode">รหัส teacher ที่ต้องการค้นหา</param> /// <param name="grade">Grade</param> public async Task <Contract> GetContractsByTeacherCode(string teacherCode, string grade) { var result = (await _mongoUtil.GetCollection <Contract>(TableName).FindAsync(it => !it.DeletedDate.HasValue)) .ToEnumerable() .Where(contract => contract.Licenses .Where(it => !it.DeletedDate.HasValue) .SelectMany(it => it.TeacherKeys) .Where(it => !it.DeletedDate.HasValue) .Any(it => it.Code == teacherCode && it.Grade == grade)) .FirstOrDefault(); return(result); }
/// <summary> /// ขอข้อมูล Class calendar จากรหัส Class calendar /// </summary> /// <param name="classCalendarId">รหัส Class calendar ที่ต้องการขอข้อมูล</param> public async Task <ClassCalendar> GetClassCalendarById(string classCalendarId) { var result = await _mongoUtil.GetCollection <ClassCalendar>(TableName) .Find(it => !it.DeletedDate.HasValue && it.id == classCalendarId) .FirstOrDefaultAsync(); return(result); }
/// <summary> /// เพิ่ม payment ใหม่ /// </summary> /// <param name="data">ข้อมูลที่ต้องการเพิ่ม</param> public async Task CreateNewPayment(Payment data) { var collection = _mongoUtil.GetCollection <Payment>(TableName); await collection.InsertOneAsync(data); }