public ActionResult messenger() { // list of all message List<MessageView> msglist = new List<MessageView>(); var message = (from msg in db.Messages where msg.ToMPAdmin == true orderby msg.DateSend descending select msg); foreach (var temp in message) { MessageView l = new MessageView(); l.date = temp.DateSend; l.TextDisplay = temp.Message1; l.reference = temp.UserId; // this is userid to follow the chat msglist.Add(l); } var chatbox = (from chat in db.ChatBoxes orderby chat.DateSend descending select chat); foreach (var temp in chatbox) { MessageView l = new MessageView(); l.date = temp.DateSend.Value; l.reference = temp.WebmasterId.ToString();// truong hop gui cho webmaster l.TextDisplay = temp.Message; msglist.Add(l); } TransactionLogViewModel.AddLog(User.Identity.Name + " has just go to Pacific Messenger!" , DateTime.Now); AdminIndexViewModel model = new AdminIndexViewModel() {listMessage = msglist }; return View(model); }
public ActionResult Index() { // 10 of newest order //10 of newest problem //10 of newest webmaster // 10 of newest added websites var order = from o in db.WebsiteOrders orderby o.Date descending select o; var webmaster = (from w in db.Webmasters orderby w.Id descending select w).Take(10); var website = (from ws in db.Websites orderby ws.DateJoin descending select ws).Take(10); // list of all message List<MessageView> msglist = new List<MessageView>(); var message = (from msg in db.Messages where msg.ToMPAdmin == true orderby msg.DateSend descending select msg).Take(5); foreach(var temp in message) { MessageView l = new MessageView(); l.date = temp.DateSend; l.TextDisplay = temp.Message1; l.reference = temp.UserId; // this is userid to follow the chat msglist.Add(l); } var chatbox = (from chat in db.ChatBoxes orderby chat.DateSend descending select chat).Take(5); foreach (var temp in chatbox) { MessageView l = new MessageView(); l.date = temp.DateSend.Value; l.reference = temp.WebmasterId.ToString();// truong hop gui cho webmaster l.TextDisplay = temp.Message; msglist.Add(l); } TransactionLogViewModel.AddLog(User.Identity.Name + " has just go to Money Pacific Admin - Home!", DateTime.Now); AdminIndexViewModel model = new AdminIndexViewModel() { listOrder = order.ToList(), listWebmaster = webmaster.ToList(), listWebsite = website.ToList(),listMessage = msglist}; return View(model); }