Example #1
0
        public IQueryable <ComboBoxResult> GetCustomProducts(int Id, string term)
        {
            var SaleEnquiry = new SaleEnquiryHeaderService(_unitOfWork).Find(Id);

            var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(SaleEnquiry.DocTypeId, SaleEnquiry.DivisionId, SaleEnquiry.SiteId);

            string[] ProductTypes = null;
            if (!string.IsNullOrEmpty(settings.filterProductTypes))
            {
                ProductTypes = settings.filterProductTypes.Split(",".ToCharArray());
            }
            else
            {
                ProductTypes = new string[] { "NA" };
            }

            string[] Products = null;
            if (!string.IsNullOrEmpty(settings.filterProducts))
            {
                Products = settings.filterProducts.Split(",".ToCharArray());
            }
            else
            {
                Products = new string[] { "NA" };
            }

            string[] ProductGroups = null;
            if (!string.IsNullOrEmpty(settings.filterProductGroups))
            {
                ProductGroups = settings.filterProductGroups.Split(",".ToCharArray());
            }
            else
            {
                ProductGroups = new string[] { "NA" };
            }

            return(from pb in db.ViewProductBuyer
                   join Pt in db.Product on pb.ProductId equals Pt.ProductId into ProductTable from ProductTab in ProductTable.DefaultIfEmpty()
                   where (string.IsNullOrEmpty(settings.filterProductTypes) ? 1 == 1 : ProductTypes.Contains(ProductTab.ProductGroup.ProductTypeId.ToString())) &&
                   (string.IsNullOrEmpty(settings.filterProducts) ? 1 == 1 : Products.Contains(ProductTab.ProductId.ToString())) &&
                   (string.IsNullOrEmpty(settings.filterProductGroups) ? 1 == 1 : ProductGroups.Contains(ProductTab.ProductGroupId.ToString())) &&
                   (string.IsNullOrEmpty(term) ? 1 == 1 : pb.ProductName.ToLower().Contains(term.ToLower())) &&
                   pb.BuyerId == SaleEnquiry.SaleToBuyerId
                   orderby pb.ProductName
                   select new ComboBoxResult
            {
                id = pb.ProductId.ToString(),
                text = pb.ProductName,
                AProp1 = pb.BuyerSpecification,
                AProp2 = pb.BuyerSpecification1,
                TextProp1 = pb.BuyerSpecification2,
                TextProp2 = pb.BuyerSpecification3
            });
        }
Example #2
0
        public IQueryable <ComboBoxResult> GetCustomPerson(int Id, string term)
        {
            int DocTypeId  = Id;
            int SiteId     = (int)System.Web.HttpContext.Current.Session["SiteId"];
            int DivisionId = (int)System.Web.HttpContext.Current.Session["DivisionId"];

            var settings = new SaleEnquirySettingsService(_unitOfWork).GetSaleEnquirySettingsForDucument(DocTypeId, DivisionId, SiteId);

            string[] PersonRoles = null;
            if (!string.IsNullOrEmpty(settings.filterPersonRoles))
            {
                PersonRoles = settings.filterPersonRoles.Split(",".ToCharArray());
            }
            else
            {
                PersonRoles = new string[] { "NA" };
            }

            string DivIdStr  = "|" + DivisionId.ToString() + "|";
            string SiteIdStr = "|" + SiteId.ToString() + "|";

            var list = (from p in db.Persons
                        join bus in db.BusinessEntity on p.PersonID equals bus.PersonID into BusinessEntityTable
                        from BusinessEntityTab in BusinessEntityTable.DefaultIfEmpty()
                        join pp in db.PersonProcess on p.PersonID equals pp.PersonId into PersonProcessTable
                        from PersonProcessTab in PersonProcessTable.DefaultIfEmpty()
                        join pr in db.PersonRole on p.PersonID equals pr.PersonId into PersonRoleTable
                        from PersonRoleTab in PersonRoleTable.DefaultIfEmpty()
                        where PersonProcessTab.ProcessId == settings.ProcessId &&
                        (string.IsNullOrEmpty(term) ? 1 == 1 : (p.Name.ToLower().Contains(term.ToLower()) || p.Code.ToLower().Contains(term.ToLower()))) &&
                        (string.IsNullOrEmpty(settings.filterPersonRoles) ? 1 == 1 : PersonRoles.Contains(PersonRoleTab.RoleDocTypeId.ToString())) &&
                        BusinessEntityTab.DivisionIds.IndexOf(DivIdStr) != -1 &&
                        BusinessEntityTab.SiteIds.IndexOf(SiteIdStr) != -1 &&
                        (p.IsActive == null ? 1 == 1 : p.IsActive == true)
                        group new { p } by new { p.PersonID } into Result
                        orderby Result.Max(m => m.p.Name)
                        select new ComboBoxResult
            {
                id = Result.Key.PersonID.ToString(),
                text = Result.Max(m => m.p.Name + ", " + m.p.Suffix + " [" + m.p.Code + "]"),
            }
                        );

            return(list);
        }