public IHttpActionResult TerritoryList() { try { using (var dataContext = new HuntingEntities()) { var session = GetSession(); if (session == null) { return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE)); } var userSession = AclUserContext.GetUserSession(dataContext, session); if (userSession == null) { return(Content(HttpStatusCode.Unauthorized, SESSION_INVALID_MESSAGE)); } var territoryList = TerritoryContext.GetListForUser(dataContext, userSession.AclUser); var model = new TerritoryListModel(territoryList, userSession.AclUser); return(Ok(model)); } } catch (Exception exception) { logger.Error(exception, "MobileController"); return(InternalServerError()); } }
//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")); } }