// GET: Messages public ActionResult ProjectMessage(int id) { MessageListVm Mvm = new MessageListVm(); Mvm = _adapter.GetMessagesByProject(id); return(View(Mvm)); }
public MessageListVm GetMessagesByProject(int id) { MessageListVm Mvm = new MessageListVm(); using (ApplicationDbContext db = new ApplicationDbContext()) { Mvm.MessagesByProject = db.MessageProjects.Where(p => p.ProjectId == id).Select(m => new MessageVm { SenderName = m.Message.SenderName, Location = m.Message.Location, MessageBody = m.Message.MessageBody, MessageId = m.Message.MessageId, }).Take(10).ToList(); } return(Mvm); }