Example #1
0
        public ActionResult Index(int?page, string sortOrder, string searchString)
        {
            int noPage = (page ?? 1) - 1;

            var cvm = new ContractsViewModel
            {
                Portfolios = portfolioRepository.GetPortfoliosByUserScope((long)Session["id"])
            };

            if (searchString != null)
            {
                page = 1;
            }

            var contracts = contractRepository.Pagination(c => c.Name, noPage, 10, out int total);

            contracts = zoneRepository.GetAll().Include("Contracts").Where(z => z.Label.ToLower().Contains(searchString.ToLower())).SelectMany(z => z.Contracts);

            if (contracts.Count() == 0)
            {
                cvm.IsListEmpty = true;
                return(View(cvm));
            }

            if (!string.IsNullOrEmpty(searchString))
            {
                contracts = contractRepository.GetByFilter(c => c.Name.ToLower().Contains(searchString.ToLower()));
            }

            cvm.Contracts = new StaticPagedList <Contract>(contracts, noPage + 1, Utils.Constants.ITEMS_PER_PAGE, total);

            return(View(cvm));
        }
Example #2
0
        public ActionResult Contracts(long id, int?page, string sortOrder, string searchString)
        {
            int noPage = (page ?? 1) - 1;
            var contractsViewModels = new ContractsViewModel
            {
                Portfolio = portfolioRepository.GetById(id)
            };

            if (searchString != null)
            {
                page = 1;
            }

            var contracts = contractRepository.Pagination(p => p.PortfolioId == id, c => c.Name, noPage, Constants.ITEMS_PER_PAGE, out int total);

            contractsViewModels.Portfolio.Scope = scopeRepository.GetScopeByPortfolio(id) ? "Initial" : "Extent";

            string zoneUser = (string)Session["zone"];

            contracts = zoneRepository.GetAll().Include("Contracts").Where(z => z.Label == zoneUser).SelectMany(z => z.Contracts).Where(c => c.PortfolioId == id);

            if (contracts.Count() == 0)
            {
                contractsViewModels.IsListEmpty = true;
                return(View(contractsViewModels));
            }

            if (!string.IsNullOrEmpty(searchString))
            {
                contracts = contracts.Where(c => c.Name.ToLower().Contains(searchString.ToLower()));
            }

            contractsViewModels.Contracts = new StaticPagedList <Contract>(contracts, noPage + 1, Constants.ITEMS_PER_PAGE, total);

            return(View(contractsViewModels));
        }