public async Task<ActionResult> Inbox() { /*Mailer.GmailUsername = "******"; Mailer.GmailPassword = "******"; Mailer mailer = new Mailer(); mailer.ToEmail = "*****@*****.**"; mailer.Subject = "New Question Posted on MezoExperts.com"; mailer.Body = "New question posted on Mezoexperts.com"; mailer.IsHtml = true; mailer.Send();*/ var user = new Guid(User.Identity.GetUserId()); var MineSessions = db.Questions.Where(c => c.StudentID == user).ToList(); List<StudentInbox> list = new List<StudentInbox>(); foreach (var question in MineSessions) { foreach (var session in question.Sessions) { StudentInbox obj = new StudentInbox(); obj.SenderName = session.tutor.Username; obj.SenderProfile = session.tutor.ProfileImage; var lastreply = session.Replies.OrderBy(c => c.PostedTime); obj.PostedTime = lastreply.LastOrDefault().PostedTime; obj.SessionId = session.SessionID; obj.Status = session.Status; obj.newMessage = session.NewMessageStudent; obj.LastMessage = lastreply.LastOrDefault().Details; list.Add(obj); } } return View(list); }
public ActionResult Index() { var user = new Guid(User.Identity.GetUserId()); var MineSessions = db.Questions.Where(c => c.StudentID == user).ToList(); List<StudentInbox> list = new List<StudentInbox>(); var onlineusers = db.online.Where(c => c.Status == true).ToList(); foreach (var question in MineSessions) { var hiredSession = question.Sessions.Where(c => c.Status == Status.Hired || c.Status== Status.Conflict); foreach (var session in hiredSession) { StudentInbox obj = new StudentInbox(); obj.SenderName = session.tutor.Username; obj.SenderProfile = session.tutor.ProfileImage; var online = onlineusers.Where(c => c.Username == obj.SenderName).FirstOrDefault(); obj.onlineStatus = online == null ? false : online.Status; var lastreply = session.Replies.OrderBy(c => c.PostedTime); obj.PostedTime = lastreply.LastOrDefault().PostedTime; obj.SessionId = session.SessionID; obj.Status = session.Status; obj.LastMessage = lastreply.LastOrDefault().Details; obj.newMessage = session.NewMessageStudent; list.Add(obj); } } StudentHomeModel model = new StudentHomeModel(); model.obj = list; model.questions= MineSessions.OrderBy(c => c.PostedTime).ToList(); Session["noticounter"] = db.notifications.Where(c => c.UserName == User.Identity.Name && c.isRead == false).Count(); var result = db.notifications.Where(c => c.UserName == User.Identity.Name).OrderByDescending(c => c.postedTime).Take(5); Session["notifications"] = result.ToList(); return View(model); }
public ActionResult Index() { var user = new Guid(User.Identity.GetUserId()); var MineSessions = db.Questions.Where(c => c.StudentID == user).ToList(); List<StudentInbox> list = new List<StudentInbox>(); foreach (var question in MineSessions) { var hiredSession = question.Sessions.Where(c => c.Status == Status.Hired || c.Status== Status.Conflict); foreach (var session in hiredSession) { StudentInbox obj = new StudentInbox(); obj.SenderName = session.tutor.Username; obj.SenderProfile = session.tutor.ProfileImage; var lastreply = session.Replies.OrderBy(c => c.PostedTime); obj.PostedTime = lastreply.LastOrDefault().PostedTime; obj.SessionId = session.SessionID; obj.Status = session.Status; obj.LastMessage = lastreply.LastOrDefault().Details; obj.newMessage = session.NewMessageStudent; list.Add(obj); } } StudentHomeModel model = new StudentHomeModel(); model.obj = list; model.questions= MineSessions.OrderBy(c => c.PostedTime).ToList(); return View(model); }
public async Task<ActionResult> Inbox() { var user = new Guid(User.Identity.GetUserId()); var MineSessions = db.Questions.Where(c => c.StudentID == user).ToList(); List<StudentInbox> list = new List<StudentInbox>(); var onlineusers = db.online.Where(c => c.Status == true).ToList(); foreach (var question in MineSessions) { foreach (var session in question.Sessions.Where(c=>c.isStudentDelete== false)) { StudentInbox obj = new StudentInbox(); obj.SenderName = session.tutor.Username; var online= onlineusers.Where(c => c.Username == obj.SenderName).FirstOrDefault(); obj.onlineStatus = online == null ? false : online.Status; obj.SenderProfile = session.tutor.ProfileImage; var lastreply = session.Replies.OrderBy(c => c.PostedTime); obj.PostedTime = lastreply.LastOrDefault().PostedTime; obj.SessionId = session.SessionID; obj.Status = session.Status; obj.newMessage = session.NewMessageStudent; obj.LastMessage = lastreply.LastOrDefault().Details; list.Add(obj); } } return View(list); }