コード例 #1
0
        public async Task <List <RecordDto> > GetPrizeRecords(int prizeID, bool isShowAllRecords)
        {
            var empQuery = _empRepository.FindAll();

            if (isShowAllRecords)
            {
                return(await _recordRepository.FindAll(x => x.PrizeID == prizeID)
                       .Join(empQuery, r => r.EmpCode, e => e.EmpCode, (r, e) => new RecordDto
                {
                    EmpCode = e.EmpCode,
                    EmpDept = e.EmpDept,
                    EmpName = e.EmpName,
                    ID = r.ID,
                    PrizeID = r.PrizeID,
                    Visible = r.Visible
                }).ToListAsync());
            }
            else
            {
                return(await _recordRepository.FindAll(x => x.PrizeID == prizeID && x.Visible == true)
                       .Join(empQuery, r => r.EmpCode, e => e.EmpCode, (r, e) => new RecordDto
                {
                    EmpCode = e.EmpCode,
                    EmpDept = e.EmpDept,
                    EmpName = e.EmpName,
                    ID = r.ID,
                    PrizeID = r.PrizeID,
                    Visible = r.Visible
                }).ToListAsync());
            }
        }