//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")); } }
public static int GetTotalCount(HuntingEntities context, TerritoryFilter filter, int userId) { try { var generator = new TerritoryListGenerator(filter, userId); var totalCount = QueryGenerator.GetTotalCount(context, generator); return(totalCount); } catch (Exception exception) { logger.Error(exception, "GetTotalCount"); return(0); } }
public IActionResult Territories([FromQuery] TerritoryFilter filter) => Ok(dbContext.Territories.ApplyFilter(filter));
public TerritoryPageModel(TerritoryListModel itemListModel, TerritoryFilter filter) { this.ListModel = itemListModel; this.Pager = FilterUtils.GetPager(itemListModel.PageCount, itemListModel.PageIndex); this.Filter = filter; }
public static ItemListHolder <TerritoryListItem> GetList(HuntingEntities context, TerritoryFilter filter, int pageIndex, int userId) { try { var generator = new TerritoryListGenerator(filter, userId); var list = QueryGenerator.ReadPagedList <TerritoryListItem>(context, generator, pageIndex, Constants.DEFAULT_LIST_PAGE_SIZE); var itemHolder = new ItemListHolder <TerritoryListItem>(list); itemHolder.TotalCount = GetTotalCount(context, filter, userId); return(itemHolder); } catch (Exception exception) { logger.Error(exception, "GetList"); return(new ItemListHolder <TerritoryListItem>()); } }