コード例 #1
0
 // GET: Admin
 public ActionResult Index(AclUserFilter filter, int?page)
 {
     try
     {
         using (var dataContext = new HuntingEntities())
         {
             int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID];
             var userName   = User.Identity.Name;
             var user       = AclUserContext.GetDetail(dataContext, userName);
             if (user.AccountTypeEx != AccountTypeEnum.Admin)
             {
                 ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED);
                 return(RedirectToAction("Index", "Home"));
             }
             filter.PrepareFilter(languageId);
             int pageIndex     = page ?? 0;
             var itemList      = AclUserContext.GetList(dataContext, filter, pageIndex);
             var itemListModel = new AclUserListModel(itemList, pageIndex);
             var model         = new AclUserPageModel(itemListModel, filter);
             return(View(model));
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception, "AdminController");
         return(RedirectToAction("Index", "Home"));
     }
 }