public List <CustomerDatastatistics> GetReportData()
        {
            customerContactRepo = RepositoryHelper.Get客戶聯絡人Repository();
            customerDataRepo    = RepositoryHelper.Get客戶資料Repository();
            customerBankRepo    = RepositoryHelper.Get客戶銀行資訊Repository();

            var customerDatas = customerDataRepo.All().Select(
                c =>
                new CustomerDatastatistics
            {
                ID   = c.Id,
                客戶名稱 = c.客戶名稱,
            }).ToList();


            foreach (var a in customerDatas)
            {
                var customerContactDatas = customerContactRepo.All().Where(c => c.客戶Id == a.ID).Count();

                var customerBankDatas = customerBankRepo.All().Where(c => c.客戶Id == a.ID).Count();

                a.聯絡人數量  = customerContactDatas;
                a.銀行帳戶數量 = customerBankDatas;
            }

            return(customerDatas);
        }
示例#2
0
        public List <客戶聯絡人> AllData()
        {
            客戶聯絡人Repository customerContactRepo = RepositoryHelper.Get客戶聯絡人Repository();

            var customerData = RepositoryHelper.Get客戶資料Repository().All().ToList();

            var customerContact = customerContactRepo.All().ToList()
                                  .Join(customerData, a => a.客戶Id, b => b.Id, (a, b) => new 客戶聯絡人
            {
                Id    = a.Id,
                客戶Id  = a.客戶Id,
                職稱    = a.職稱,
                姓名    = a.姓名,
                Email = a.Email,
                手機    = a.手機,
                電話    = a.電話,
                是否已刪除 = a.是否已刪除,
                客戶資料  = new 客戶資料 {
                    Id = a.客戶Id, 客戶名稱 = b.客戶名稱
                }
            }).Where(c => c.是否已刪除 == false).ToList();

            return(customerContact);
        }