示例#1
0
 // GET: Notifications
 public ActionResult Index(string searchString)
 {
     if (!String.IsNullOrEmpty(searchString))
     {
         SearchController s = new SearchController();
         return(s.SearchOnDatabase(searchString));
     }
     else
     {
         if (AccountController.CheckPermission("Notification-Index"))
         {
             List <NotificationViewModel> n = new List <NotificationViewModel>();
             ReceiveEmail(n);
             //if (n.Count > 1)
             //{
             //    listNotification.Sort((x, y) => y.CreatedDate.CompareTo(x.CreatedDate));
             //}
             foreach (var item in n.ToList())
             {
                 if (item.Message.Length >= 30)
                 {
                     item.Message = item.Message.Substring(0, 30) + "...";
                 }
             }
             ViewBag.Count = n.Count;
             return(View(n));
         }
         else if (AccountController.CheckPermission("Notification-Sent"))
         {
             return(RedirectToAction("Sent"));
         }
         else
         {
             return(RedirectToAction("Index", "Home"));
         }
     }
 }