/// <summary> /// Thêm comment /// </summary> /// <param name="com">Comment</param> /// <returns>long</returns> public long InsertComment(StudyOnline.Entities.Models.Comment com) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.Comment.Add(com); _db.SaveChanges(); return(com.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Thêm bạn bè /// </summary> /// <param name="friend">FriendUser</param> /// <returns>long</returns> public long InsertFriendUser(StudyOnline.Entities.Models.FriendUser friend) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.FriendUser.Add(friend); _db.SaveChanges(); return(friend.FriendID); } catch (Exception) { return(-1); } } }
/// <summary> /// Tạo 1 loại khóa học /// </summary> /// <param name="course">CourseCategory</param> /// <returns>long</returns> public long CreateCourseCategory(StudyOnline.Entities.Models.CourseCategory course) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.CourseCategory.Add(course); _db.SaveChanges(); return(course.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Tạo câu hỏi /// </summary> /// <param name="ta">TestAnswer</param> /// <returns>long</returns> public long CreateTestAnswer(StudyOnline.Entities.Models.TestAnswer ta) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.TestAnswer.Add(ta); _db.SaveChanges(); return(ta.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Tạo 1 phân học /// </summary> /// <param name="sec">Section</param> /// <returns>long</returns> public long CreateSection(StudyOnline.Entities.Models.Section sec) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.Section.Add(sec); _db.SaveChanges(); return(sec.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Tạo 1 bài học /// </summary> /// <param name="less">Lesson</param> /// <returns>long</returns> public long CreateLesson(StudyOnline.Entities.Models.Lesson less) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.Lesson.Add(less); _db.SaveChanges(); return(less.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Thêm tài liệu /// </summary> /// <param name="am">AttachMent</param> /// <returns>long</returns> public long InsertAttachMent(StudyOnline.Entities.Models.AttachMent am) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.AttachMent.Add(am); _db.SaveChanges(); return(am.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Thêm câu trả lời /// </summary> /// <param name="tq">TestQuestion</param> /// <returns>long</returns> public long CreateTestQuestion(StudyOnline.Entities.Models.TestQuestion tq) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.TestQuestion.Add(tq); _db.SaveChanges(); return(tq.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Xóa comment /// </summary> /// <param name="id">ID</param> /// <returns>bool</returns> public bool DeleteComment(long id) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var com = _db.Comment.Find(id); _db.Comment.Remove(com); _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Thêm video /// </summary> /// <param name="tq">Video</param> /// <returns>long</returns> public long InsertVideo(StudyOnline.Entities.Models.Video tq) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { _db.Video.Add(tq); _db.SaveChanges(); return(tq.ID); } catch (Exception) { return(-1); } } }
/// <summary> /// Xóa câu hỏi /// </summary> /// <param name="id">ID</param> /// <returns>bool</returns> public bool DeleteTestAnswer(long id) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var result = _db.TestAnswer.Find(id); _db.TestAnswer.Remove(result); _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhật câu hỏi /// </summary> /// <param name="ta">TestAnswer</param> /// <returns>bool</returns> public bool UpdateTestAnswer(StudyOnline.Entities.Models.TestAnswer ta) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.TestAnswer.Find(ta.ID); c.Name = ta.Name; //c.TestQuestion = ta.TestQuestion; c.TittleAnswer = ta.TittleAnswer; c.TestQuestionID = ta.TestQuestionID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhật 1 khóa học /// </summary> /// <param name="less">Lesson</param> /// <returns>bool</returns> public bool UpdateLesson(StudyOnline.Entities.Models.Lesson less) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.Lesson.Find(less.ID); c.LessonName = less.LessonName; c.Description = less.Description; c.CreateDate = less.CreateDate; c.Status = less.Status; c.SectionID = less.SectionID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhật bài kiểm tra /// </summary> /// <param name="tes">Test</param> /// <returns>bool</returns> public bool UpdateTest(StudyOnline.Entities.Models.Test tes) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.Test.Find(tes.ID); c.Name = tes.Name; c.TimeTest = tes.TimeTest; c.SectionID = tes.SectionID; c.Point = tes.Point; c.Rank = tes.Rank; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhập phân học /// </summary> /// <param name="sec">Section</param> /// <returns>bool</returns> public bool UpdateSection(StudyOnline.Entities.Models.Section sec) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.Section.Find(sec.ID); c.SectionName = sec.SectionName; c.Title = sec.Title; c.Description = sec.Description; c.CreateDate = sec.CreateDate; c.Status = sec.Status; c.CourseID = sec.CourseID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Sửa tài liệu /// </summary> /// <param name="am">AttachMent</param> /// <returns>bool</returns> public bool UpdateAttachMent(StudyOnline.Entities.Models.AttachMent am) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var a = _db.AttachMent.Find(am.ID); a.FileName = am.FileName; a.Path = am.Path; a.Type = am.Type; a.CreateDate = am.CreateDate; a.Status = am.Status; a.LessonID = am.LessonID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhật video /// </summary> /// <param name="v">Video</param> /// <returns>bool</returns> public bool UpdateVideo(StudyOnline.Entities.Models.Video v) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.Video.Find(v.ID); c.Name = v.Name; c.Link = v.Link; c.Length = v.Length; c.CreateDate = v.CreateDate; c.Description = v.Description; c.Status = v.Status; c.LessonID = v.LessonID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Sửa comment /// </summary> /// <param name="com">Comment</param> /// <returns>bool</returns> public bool UpdateComment(StudyOnline.Entities.Models.Comment com) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var co = _db.Comment.Find(com.ID); co.UserName = com.UserName; co.Content = com.Content; co.CreateDate = com.CreateDate; co.Avatar = com.Avatar; co.Status = com.Status; co.UserID = com.UserID; co.LessonID = com.LessonID; co.ParentID = com.ParentID; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }
/// <summary> /// Cập nhật 1 loại khóa học /// </summary> /// <param name="course">CourseCategory</param> /// <returns>bool</returns> public bool UpdateCourseCategory(StudyOnline.Entities.Models.CourseCategory course) { using (StudyOnline.Entities.Models.StudyOnline _db = new StudyOnline.Entities.Models.StudyOnline()) { try { var c = _db.CourseCategory.Find(course.ID); c.Name = course.Name; c.Descrpition = course.Descrpition; c.ParentID = course.ParentID; c.Link = course.Link; c.Tags = course.Tags; c.MetaTittle = course.MetaTittle; c.CreateDate = course.CreateDate; c.Status = course.Status; _db.SaveChanges(); return(true); } catch (Exception) { return(false); } } }