public ActionResult ShowMessages2() // Meddelandefunktion ny vy { MessageListViewModel viewmodel = new MessageListViewModel(); var curentuserid = User.Identity.GetUserId(); User currentuser = db.Users.Single(x => x.Id == curentuserid); foreach (Message item in currentuser.Messages) { MessageViewModel itemet = new MessageViewModel(); itemet.messageid = item.id; itemet.Message = item.messagestring; itemet.Sender = item.sender; itemet.TimeReceived = item.time; if (item.displayed == true) { viewmodel.ReadMessages.Add(itemet); } else { viewmodel.UnreadMessaegs.Add(itemet); } } ViewBag.messagecontroller = TempData["Message"]; return View(viewmodel); }
public MessageViewModel CreateMessage(string userid) { MessageViewModel view = new MessageViewModel(); view.users = db.Users.ToList(); if (RoleValues.Adminuser == true) { view.userisadmin = true; view.classlist = db.Classes.ToList(); } return view; }
public MessageListViewModel ViewMessagesInBox(string userid) { MessageListViewModel viewmodel = new MessageListViewModel(); User currentuser = db.Users.Single(x => x.Id == userid); foreach (Message item in currentuser.Messages) { MessageViewModel itemet = new MessageViewModel(); itemet.messageid = item.id; itemet.Message = item.messagestring; itemet.Sender = item.sender; itemet.TimeReceived = item.time; if (item.displayed == true) { viewmodel.ReadMessages.Add(itemet); } else { viewmodel.UnreadMessaegs.Add(itemet); } } viewmodel.CurrentUserName = currentuser.UserName; SetUnreadMessages(userid); return viewmodel; }
public ActionResult Create(MessageViewModel model) { try { var userid = User.Identity.GetUserId(); if (model.userid != null) { repo.SendMessage(model.Message, model.userid,userid); TempData["Message"] = "Message sent !"; } else if (model.classid != 0) { repo.SendClassMessage(model.Message, model.classid,userid); TempData["Message"] = "Class message sent !"; } else { TempData["Message"] = "Some thing went wrong"; } return RedirectToAction("Index"); } catch { TempData["Message"] = "Some thing went wrong"; return RedirectToAction("Index"); } }
// GET: Message/Create public ActionResult Create() { MessageViewModel view = new MessageViewModel(); var userid = User.Identity.GetUserId(); view = repo.CreateMessage(userid); return View(view); }
//Filemanager repo start public void MessageFunction(User currentuser, MessageListSectionModel MessageListSection) // alex meddelandefunktion { foreach (Message messages in currentuser.Messages) { MessageViewModel MessageList = new MessageViewModel(); MessageList.messageid = messages.id; MessageList.Message = messages.messagestring; MessageList.Sender = messages.sender; MessageList.TimeReceived = messages.time; if (messages.displayed == true) { MessageListSection.ReadMessages.Add(MessageList); } else { MessageListSection.UnreadMessages.Add(MessageList); } } }