public ActionResult CommentReply(int CommentHeadId, string UserComment)
        {
            var id = User.Identity.GetUserId();

            int           count      = db.AspnetComments.Count();
            AspnetComment commentobj = new AspnetComment();

            if (count == 0)
            {
                commentobj.ParentCommentId = null;
                commentobj.Comment         = UserComment;
                commentobj.CreationDate    = GetLocalDateTime.GetLocalDateTimeFunction();
                commentobj.HeadId          = CommentHeadId;
                commentobj.CreatedBy       = id;
                db.AspnetComments.Add(commentobj);
                db.SaveChanges();
            }
            else
            {
                int LastId = db.AspnetComments.OrderByDescending(o => o.Id).FirstOrDefault().Id;
                commentobj.ParentCommentId = LastId;
                commentobj.Comment         = UserComment;
                commentobj.CreationDate    = GetLocalDateTime.GetLocalDateTimeFunction();
                commentobj.HeadId          = CommentHeadId;
                commentobj.CreatedBy       = id;

                db.AspnetComments.Add(commentobj);
                db.SaveChanges();
            }


            return(Json("", JsonRequestBehavior.AllowGet));
        }
        public ActionResult CommentReply(int CommentHeadId, string UserComment)
        {
            var id = User.Identity.GetUserId();

            int           count      = db.AspnetComments.Count();
            AspnetComment commentobj = new AspnetComment();

            if (count == 0)
            {
                commentobj.ParentCommentId = null;
                commentobj.Comment         = UserComment;
                commentobj.CreationDate    = GetLocalDateTime.GetLocalDateTimeFunction();
                commentobj.HeadId          = CommentHeadId;
                commentobj.CreatedBy       = id;
                db.AspnetComments.Add(commentobj);
                db.SaveChanges();
            }
            else
            {
                int LastId = db.AspnetComments.OrderByDescending(o => o.Id).FirstOrDefault().Id;
                commentobj.ParentCommentId = LastId;
                commentobj.Comment         = UserComment;
                commentobj.CreationDate    = GetLocalDateTime.GetLocalDateTimeFunction();
                commentobj.HeadId          = CommentHeadId;
                commentobj.CreatedBy       = id;

                db.AspnetComments.Add(commentobj);
                db.SaveChanges();
            }


            var        UserNameLog = User.Identity.Name;
            AspNetUser currentUser = db.AspNetUsers.First(x => x.UserName == UserNameLog);

            var UserId          = User.Identity.GetUserId();
            var UserName        = db.AspNetUsers.Where(x => x.Id == UserId).FirstOrDefault().Name;
            var NotificationObj = new AspNetNotification();

            NotificationObj.Description = "Teacher " + UserName + " Replied";
            NotificationObj.Subject     = "Reply To Student Comment";
            NotificationObj.SenderID    = UserId;
            NotificationObj.Time        = GetLocalDateTime.GetLocalDateTimeFunction();
            NotificationObj.Url         = "/StudentCourses/CommentsPage1/" + CommentHeadId;

            db.AspNetNotifications.Add(NotificationObj);
            db.SaveChanges();

            //int? LessonID = db.AspnetComment_Head.Where(x => x.Id == CommentHeadId).FirstOrDefault().LessonId;
            //int? TopicId = db.AspnetLessons.Where(x => x.Id == LessonID).FirstOrDefault().TopicId;
            //int? SubjectId = db.AspnetSubjectTopics.Where(x => x.Id == TopicId).FirstOrDefault().SubjectId;


            //var AllStudents = db.Student_GenericSubjects.Where(x => x.GenericSubjectId == SubjectId).Select(x => x.StudentId);

            //var DistinctStudents = AllStudents.Distinct();

            //foreach (var receiver in DistinctStudents)
            //{
            var receiver = db.AspnetComment_Head.Where(x => x.Id == CommentHeadId).Select(x => x.CreatedBy).FirstOrDefault();

            SEA_DatabaseEntities db2 = new SEA_DatabaseEntities();


            var notificationRecieve = new AspNetNotification_User();

            notificationRecieve.NotificationID = NotificationObj.Id;
            notificationRecieve.UserID         = Convert.ToString(receiver);
            notificationRecieve.Seen           = false;
            db2.AspNetNotification_User.Add(notificationRecieve);
            db2.SaveChanges();


            // }

            return(Json("", JsonRequestBehavior.AllowGet));
        }