Beispiel #1
0
        // GET: Messages
        //[Authorize(Roles = "admin")]
        //[Authorize(Roles = "manager")]
        public ActionResult Index(string sortOrder, string searchString)
        {
            string nameSetting = "MessageGen";
            string messageG    = SettingBL.FindSettingValueByName(nameSetting);

            ViewBag.messageG = int.Parse(messageG);
            int lang      = LanguageBL.CheckLanguageSession();
            var messagesT = db.SPP_MessageTransDistinct(lang).ToList();

            ViewBag.NameSortParam = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            if (!String.IsNullOrEmpty((searchString)))
            {
                messagesT = messagesT.Where(s => s.title.ToLower().StartsWith(searchString.ToLower())).ToList();
            }
            switch (sortOrder)
            {
            case "name_desc":
                messagesT = messagesT.OrderByDescending(d => d.title).ToList();
                break;

            default:
                messagesT = messagesT.OrderBy(d => d.title).ToList();
                break;
            }

            return(View(messagesT));
        }