using OrderSystem.Entity; using OrderSystem.Entity.ViewModel; using System; using System.Collections.Generic; using System.Text; using System.Linq; namespace OrderSystem.Services { public class OrderService : IOrderService { private OrderSystemContext DbContext { get; set; } public OrderService(OrderSystemContext dbContext) { DbContext = dbContext; } public List GetContractList(string mobile) { var contractList = (from c in DbContext.VxContractInfo.Where(e => e.客户号码 == mobile) select new ContractModel { ContractNo = c.合同号, Count = c.图纸数, Mobile = c.客户号码, CustomerName = c.客户名称, Status = c.订单状态 }).ToList(); var orderList = (from o in DbContext.VxOrderInfo.Where(e => e.客户号码 == mobile) select new OrderModel { ContractNo = o.合同号, CustomerName = o.客户名称, OrderNo = o.订单号, ProductName = o.产品, Status = o.订单状态 }).ToList(); contractList.ForEach(e => e.OrderList = orderList.Where(o => o.ContractNo == e.ContractNo).ToList()); return contractList; } } }