Exemplo n.º 1
0
        public ActionResult getOrganizedMessages()
        {
            MessagesModel message = new MessagesModel();
            var messages = message.RecieveMessages(User.Identity.Name);
            List<string> Recipients = new List<string>();
            List<List<MessagesModel>> organizedMessages = new List<List<MessagesModel>>();
            for (int i = 0; i < messages.Count(); i++)
            {
                if (messages[i].From != User.Identity.Name && !Recipients.Contains(messages[i].From))
                {
                    Recipients.Add(messages[i].From);
                }
                if (messages[i].To != User.Identity.Name && !Recipients.Contains(messages[i].To))
                {
                    Recipients.Add(messages[i].To);
                }
            }
            foreach (var recipient in Recipients)
            {
                List<MessagesModel> item = new List<MessagesModel>();
                for (int i = 0; i < messages.Count(); i++)
                {
                    if (messages[i].From.Contains(recipient) || messages[i].To.Contains(recipient))
                    {
                        item.Add(messages[i]);
                    }
                }
                organizedMessages.Add(item);
            }
            User userlist = new User();
            var listUsers = userlist.AllUsers();
            List<SelectListItem> obj = new List<SelectListItem>();
            int count = 0;
            foreach (var item in listUsers)
            {
                if (User.Identity.Name != item.UserName)
                {
                    obj.Add(new SelectListItem { Text = item.UserName, Value = count.ToString() });
                    count++;
                }
            }
            ViewBag.data = obj;
            MessagePageModel m = new MessagePageModel();
            m.organizedMessages = organizedMessages;

            return PartialView(m);
        }
Exemplo n.º 2
0
 public ActionResult Messages()
 {
     if (User.Identity.IsAuthenticated)
     {
         User userlist = new User();
         var listUsers = userlist.AllUsers();
         List<SelectListItem> obj = new List<SelectListItem>();
         int count = 0;
         foreach (var item in listUsers)
         {
             if (User.Identity.Name != item.UserName)
             {
                 obj.Add(new SelectListItem { Text = item.UserName, Value = count.ToString() });
                 count++;
             }
         }
         ViewBag.data = obj;
         return View();
     }
     return RedirectToAction("Login", "Account");
 }