public JsonResult GetPurcherseOrderInfo(Int32 PurcherseOrderId) { var data = new LstPurcherseOrderInfo(); try { var documentCode = context.PurcherseOrder.FirstOrDefault(x => x.PurcherseOrderId == PurcherseOrderId).Code; var prePurcherseOrderId = context.PurcherseOrder.FirstOrDefault(x => x.PurcherseOrderId == PurcherseOrderId).PrePurcherseOrderId; data.lstPurcharseOrder = context.PrePurcherseOrderDetail.Where(x => x.PrePurcherseOrderId == prePurcherseOrderId).Select(x => new PurcherseOrderInfo { descriptionLocal = x.Product.LocalDescription.ToUpper(), descriptionInvoice = x.Product.InvoiceDescription.ToUpper(), code = x.Product.InternalCode, family = x.Product.SubFamily.Family.Description, design = x.Product.DesignNumber, quantity = x.Quantity, unit = x.Product.MeasureUnit.Acronym, prePurcherseOrderDetailId = x.PrePurcherseOrderDetailId, supplierName = x.PrePurcherseOrder.Supplier.BussinessName, supplierId = x.PrePurcherseOrder.SupplierId, documentCode = documentCode, productId = x.ProductId }).ToList(); data.lstProductId = context.PrePurcherseOrderDetail.Where(x => x.PrePurcherseOrderId == prePurcherseOrderId).Select( x => x.ProductId).Distinct().ToList(); return(Json(data, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(data, JsonRequestBehavior.AllowGet)); } }
public JsonResult GetProductsPurcherseOrderInfo(Int32 PurcherseOrderId, Int32 StoreId) { var data = new LstPurcherseOrderInfo(); try { var entryNoteId = context.EntryNote.FirstOrDefault(x => x.DocumentId == PurcherseOrderId && x.State == ConstantHelpers.ESTADO.ACTIVO).EntryNoteId; data.lstPurcharseOrder = context.StockProductDetail.Where(x => x.EntryNoteId == entryNoteId && x.StockProduct.Quantity > 0 && x.StockProduct.StoreId == StoreId).Select(x => new PurcherseOrderInfo { descriptionLocal = x.StockProduct.Product.LocalDescription.ToUpper(), descriptionInvoice = x.StockProduct.Product.InvoiceDescription.ToUpper(), code = x.StockProduct.Product.InternalCode, family = x.StockProduct.Product.SubFamily.Family.Description, design = x.StockProduct.Product.DesignNumber, quantity = x.StockProduct.Quantity, unit = x.StockProduct.Product.MeasureUnit.Acronym, prePurcherseOrderDetailId = x.StockProduct.ProductId, documentCode = x.EntryNote.PurcherseOrder.Code, productId = x.StockProduct.Product.ProductId }).Distinct().ToList(); data.lstProductId = data.lstPurcharseOrder.Select( x => x.productId).Distinct().ToList(); return(Json(data, JsonRequestBehavior.AllowGet)); } catch (Exception ex) { return(Json(data, JsonRequestBehavior.AllowGet)); } }