예제 #1
0
        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);
        }
예제 #2
0
        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);
        }