public ProductExtendAttr FindSingleProductInvoiceStockIn(string id) { ProductExtendAttr pil = (from p in ctx.Products join c in ctx.Categories on p.CategoryId equals c.CategoryId join v in ctx.Vendors on p.VendorId equals v.VendorId where p.Status == true && p.ProductId.Equals(id) select new ProductExtendAttr { ProductId = p.ProductId, ProductName = p.ProductName, QuantityPerBox = p.QuantityPerBox, Category = c.CategoryName, Vendor = v.VendorName }).SingleOrDefault(); return(pil); }
public ProductExtendAttr FindSingleProductInvoiceStockOut(string id) { ProductExtendAttr pil = (from p in ctx.Products where p.ProductId.Equals(id) group new { p, p.Vendor, p.Category } by new { p.ProductId, p.ProductName, p.QuantityPerBox, p.Vendor.VendorName, p.Category.CategoryName, } into p select new ProductExtendAttr { ProductId = p.Key.ProductId, ProductName = p.Key.ProductName, Vendor = p.Key.VendorName, Category = p.Key.CategoryName, QuantityPerBox = p.Key.QuantityPerBox, InstockQuantity = ctx.Boxes.Count(x => x.ProductId.Equals(p.Key.ProductId) && x.Status == true) }).SingleOrDefault(); return(pil); }