示例#1
0
        public IEnumerable <Contract> GetApprovedContractWithEditions(ContractFilterCriteria contractFilterCriteria)
        {
            var sorting   = new ContractSortingResolver().CreateSorting(contractFilterCriteria);
            var predicate = new ContractsFilter().ComposeFilter(contractFilterCriteria);

            var contracts = _unitOfWork.GetRepository <Contract>()
                            .GetMany(predicate, sorting, null, null, i => i.Editions, i => i.Publisher, i => i.Genres);

            if (contracts != null)
            {
                contracts = contracts.Where(x => x.Editions.Count > 0);
            }

            return(contracts);
        }
示例#2
0
        private void SetFilter()
        {
            string orgID = null;

            if (contractsFilter == null)
            {
                contractsFilter = new ContractsFilter();
            }
            else
            {
                contractsFilter.Number = contractsFilter.Number ?? "all";
                contractsFilter.Code   = contractsFilter.Code ?? "all";
                orgID = contractsFilter.OrganizationID.ToString();
            }
            //пoлучаем значение фильтров из куков
            contractsFilter.Number = GetFromCookie(contractsFilter.Number, "ContractNumder");
            contractsFilter.Code   = GetFromCookie(contractsFilter.Code, "ContractCode");

            orgID = GetFromCookie(orgID, "ContractOrganizationID");

            if (orgID == "all")
            {
                contractsFilter.OrganizationID = 0;
            }
            else
            {
                contractsFilter.OrganizationID = long.Parse(orgID);
            }


            string sql = "select Distinct  o.OrganizationId, o.ShortName from Organization o " +
                         "inner join[Contract] c on c.ClientId = o.OrganizationId and c.ContractId > 1000 order by ShortName";

            Organizations = _context.Organizations.FromSqlRaw(sql).AsNoTracking().ToList();
            Organizations.Add(new Organization {
                OrganizationID = 0, ShortName = "All"
            });

            ViewData["OrganizationID"] = new SelectList(Organizations.OrderBy(e => e.ShortName), "OrganizationID", "ShortName");
        }