OrderService.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. using OrderSystem.Entity;
  2. using OrderSystem.Entity.ViewModel;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Text;
  6. using System.Linq;
  7. namespace OrderSystem.Services
  8. {
  9. public class OrderService : IOrderService
  10. {
  11. private OrderSystemContext DbContext { get; set; }
  12. public OrderService(OrderSystemContext dbContext)
  13. {
  14. DbContext = dbContext;
  15. }
  16. public List<ContractModel> GetContractList(string mobile)
  17. {
  18. var contractList = (from c in DbContext.VxContractInfo.Where(e => e.客户号码 == mobile)
  19. select new ContractModel
  20. {
  21. ContractNo = c.合同号,
  22. Count = c.图纸数,
  23. Mobile = c.客户号码,
  24. CustomerName = c.客户名称,
  25. Status = c.订单状态
  26. }).ToList();
  27. var orderList = (from o in DbContext.VxOrderInfo.Where(e => e.客户号码 == mobile)
  28. select new OrderModel
  29. {
  30. ContractNo = o.合同号,
  31. CustomerName = o.客户名称,
  32. OrderNo = o.订单号,
  33. ProductName = o.产品,
  34. Status = o.订单状态
  35. }).ToList();
  36. contractList.ForEach(e => e.OrderList = orderList.Where(o => o.ContractNo == e.ContractNo).ToList());
  37. return contractList;
  38. }
  39. }
  40. }