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 }); }
public string GetBuyerSKU(int ProductId, int SaleEnquiryHEaderId) { int BuyerID = new SaleEnquiryHeaderService(_unitOfWork).Find(SaleEnquiryHEaderId).SaleToBuyerId; string BuyerSku = (from p in db.ProductBuyer where p.BuyerId == BuyerID && p.ProductId == ProductId select p.BuyerSku ).FirstOrDefault(); if (BuyerSku == null) { BuyerSku = ""; } return(BuyerSku); }