Ejemplo n.º 1
0
        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);
        }
Ejemplo n.º 2
0
 // GET: Message
 public ActionResult Index()
 {
     var userid = User.Identity.GetUserId();
     MessageListViewModel viewmodel = new MessageListViewModel();
     viewmodel = repo.ViewMessagesInBox(userid);
    
     ViewBag.messagecontroller = TempData["Message"];
     return View(viewmodel);
 }
Ejemplo n.º 3
0
 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;
 }