public ActionResult _ForOrder(int id, int sid)
        {
            SaleOrderAmendmentFilterViewModel vm = new SaleOrderAmendmentFilterViewModel();

            vm.SaleOrderAmendmentHeaderId = id;
            vm.BuyerId = sid;
            return(PartialView("_Filters", vm));
        }
        public ActionResult _FilterPost(SaleOrderAmendmentFilterViewModel vm)
        {
            List <SaleOrderQtyAmendmentLineViewModel> temp = _SaleOrderQtyAmendmentLineService.GetPurchaseOrderLineForMultiSelect(vm).ToList();
            SaleOrderAmendmentMasterDetailModel       svm  = new SaleOrderAmendmentMasterDetailModel();

            svm.SaleOrderQtyAmendmentViewModel = temp;
            return(PartialView("_Results", svm));
        }
        public IEnumerable <SaleOrderQtyAmendmentLineViewModel> GetPurchaseOrderLineForMultiSelect(SaleOrderAmendmentFilterViewModel svm)
        {
            string[] ProductIdArr = null;
            if (!string.IsNullOrEmpty(svm.ProductId))
            {
                ProductIdArr = svm.ProductId.Split(",".ToCharArray());
            }
            else
            {
                ProductIdArr = new string[] { "NA" };
            }

            string[] SaleOrderIdArr = null;
            if (!string.IsNullOrEmpty(svm.SaleOrderHeaderId))
            {
                SaleOrderIdArr = svm.SaleOrderHeaderId.Split(",".ToCharArray());
            }
            else
            {
                SaleOrderIdArr = new string[] { "NA" };
            }

            string[] ProductGroupIdArr = null;
            if (!string.IsNullOrEmpty(svm.ProductGroupId))
            {
                ProductGroupIdArr = svm.ProductGroupId.Split(",".ToCharArray());
            }
            else
            {
                ProductGroupIdArr = new string[] { "NA" };
            }

            var temp = (from p in db.SaleOrderHeader
                        join t1 in db.SaleOrderLine on p.SaleOrderHeaderId equals t1.SaleOrderHeaderId
                        join product in db.Product on t1.ProductId equals product.ProductId into table2
                        from tab2 in table2.DefaultIfEmpty()
                        where (string.IsNullOrEmpty(svm.ProductId) ? 1 == 1 : ProductIdArr.Contains(t1.ProductId.ToString())) &&
                        (svm.BuyerId == 0 ? 1 == 1 : p.SaleToBuyerId == svm.BuyerId) &&
                        (string.IsNullOrEmpty(svm.SaleOrderHeaderId) ? 1 == 1 : SaleOrderIdArr.Contains(p.SaleOrderHeaderId.ToString())) &&
                        (string.IsNullOrEmpty(svm.ProductGroupId) ? 1 == 1 : ProductGroupIdArr.Contains(tab2.ProductGroupId.ToString())) &&
                        t1.Qty > 0 && p.SaleToBuyerId == svm.BuyerId
                        select new SaleOrderQtyAmendmentLineViewModel
            {
                SaleOrderDocNo = p.DocNo,
                CurrentQty = t1.Qty,
                SaleOrderAmendmentHeaderDocNo = p.DocNo,
                ProductName = tab2.ProductName,
                ProductId = t1.ProductId,
                SaleOrderAmendmentHeaderId = svm.SaleOrderAmendmentHeaderId,
                SaleOrderLineId = t1.SaleOrderLineId
            }
                        );

            return(temp);
        }