}// Student Assignment Submission public ActionResult SaveCommentHead(int LessonID, string Title, string Body) { var id = User.Identity.GetUserId(); AspnetComment_Head commentHead = new AspnetComment_Head(); //Comment_Head commentHead = new Comment_Head(); commentHead.Comment_Head = Title; commentHead.CommentBody = Body; commentHead.LessonId = LessonID; commentHead.CreatedBy = id; commentHead.CreationDate = GetLocalDateTime.GetLocalDateTimeFunction(); db.AspnetComment_Head.Add(commentHead); db.SaveChanges(); return(Json("", JsonRequestBehavior.AllowGet)); }
}// Student Assignment Submission public ActionResult SaveCommentHead(int LessonID, string Title, string Body) { var id = User.Identity.GetUserId(); AspnetComment_Head commentHead = new AspnetComment_Head(); string EncrID = LessonID + Title + Body + id; commentHead.EncryptedID = Encrpt.Encrypt(EncrID, true); var newString = Regex.Replace(commentHead.EncryptedID, @"[^0-9a-zA-Z]+", "s"); string str = newString.Substring(0, 32); commentHead.EncryptedID = str; //Comment_Head commentHead = new Comment_Head(); commentHead.Comment_Head = Title; commentHead.CommentBody = Body; commentHead.LessonId = LessonID; commentHead.CreatedBy = id; commentHead.CreationDate = GetLocalDateTime.GetLocalDateTimeFunction(); db.AspnetComment_Head.Add(commentHead); db.SaveChanges(); var UserId = User.Identity.GetUserId(); var UserName = db.AspNetUsers.Where(x => x.Id == UserId).FirstOrDefault().Name; var NotificationObj = new AspNetNotification(); NotificationObj.Description = UserName + " asked a Question"; NotificationObj.Subject = "Student Comment "; NotificationObj.SenderID = UserId; NotificationObj.Time = GetLocalDateTime.GetLocalDateTimeFunction(); NotificationObj.Url = "/TeacherCommentsOnCourses/CommentsPage1/" + commentHead.Id; db.AspNetNotifications.Add(NotificationObj); db.SaveChanges(); int?TopicId = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId; int?SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId; var AllTeachers = db.Teacher_GenericSubjects.Where(x => x.SubjectId == SubjectId).Select(x => x.TeacherId); var UnionTeachers = AllTeachers.Distinct(); var AllEmployeesUserId = from employee in db.AspNetEmployees where AllTeachers.Contains(employee.Id) select new { employee.UserId, }; SEA_DatabaseEntities db2 = new SEA_DatabaseEntities(); foreach (var receiver in AllEmployeesUserId) { var notificationRecieve = new AspNetNotification_User(); notificationRecieve.NotificationID = NotificationObj.Id; notificationRecieve.UserID = Convert.ToString(receiver.UserId); notificationRecieve.Seen = false; db2.AspNetNotification_User.Add(notificationRecieve); try { db2.SaveChanges(); } catch (Exception ex) { var Msg = ex.Message; } } return(Json("", JsonRequestBehavior.AllowGet)); }