public async Task <ActivityCodeSearchDto> GetActivityCodeAsync(decimal id) { var activityCodeEntity = await DbSet.AsNoTracking() .Include(x => x.HmrServiceAreaActivities) .FirstOrDefaultAsync(ac => ac.ActivityCodeId == id); if (activityCodeEntity == null) { return(null); } var activityCode = Mapper.Map <ActivityCodeSearchDto>(activityCodeEntity); activityCode.IsReferenced = await _workReportRepo.IsActivityNumberInUseAsync(activityCode.ActivityNumber); var serviceAreasNumbers = activityCodeEntity .HmrServiceAreaActivities //new table .Select(s => s.ServiceAreaNumber) .ToList(); activityCode.ServiceAreaNumbers = serviceAreasNumbers; return(activityCode); }
public async Task <ActivityCodeSearchDto> GetActivityCodeAsync(decimal id) { var activityCodeEntity = await DbSet.AsNoTracking() .FirstOrDefaultAsync(ac => ac.ActivityCodeId == id); if (activityCodeEntity == null) { return(null); } var activityCode = Mapper.Map <ActivityCodeSearchDto>(activityCodeEntity); activityCode.IsReferenced = await _workReportRepo.IsActivityNumberInUseAsync(activityCode.ActivityNumber); return(activityCode); }