コード例 #1
0
 //GET: Territory/List
 public ActionResult List(TerritoryFilter filter, int?page)
 {
     try
     {
         using (var dataContext = new HuntingEntities())
         {
             int languageId = (int)Session[LocalizationAttribute.SESSION_LANGUAGE_ID];
             var user       = AclUserContext.GetDetail(dataContext, User.Identity.Name);
             if (user == null)
             {
                 ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED);
                 return(RedirectToAction("Index", "Home"));
             }
             if (user.AccountTypeEx == AccountTypeEnum.Demo)
             {
                 ContextUtils.CreateActionStateCookie(Response, ActionTypeEnum.Warning, GlobalRes.ERROR_NOT_ALLOWED);
                 return(RedirectToAction("Index", "Home"));
             }
             filter.PrepareFilter(languageId);
             filter.IsContact = true;
             int pageIndex     = page ?? 0;
             var itemList      = TerritoryContext.GetList(dataContext, filter, pageIndex, user.Id);
             var itemListModel = new TerritoryListModel(itemList, pageIndex);
             var model         = new TerritoryPageModel(itemListModel, filter);
             return(View(model));
         }
     }
     catch (Exception exception)
     {
         logger.Error(exception, "TerritoryController");
         return(RedirectToAction("Index", "Home"));
     }
 }