public async Task <GetWithdrawalForEditOutput> GetWithdrawalForEdit(EntityDto input) { var result = new WithdrawalEditDto(); var header = await Repository .GetAllIncluding(x => x.Van, x => x.Salesman) .FirstOrDefaultAsync(x => x.Id == input.Id); if (header != null) { ObjectMapper.Map(header, result); var details = await _withdrawalDetailRepository.GetAll() .Include(x => x.Product) .Where(x => x.WithdrawalHeaderId == header.Id) .ToListAsync(); result.WithdrawalDetails = ObjectMapper.Map <List <WithdrawalEditDetailsDto> >(details); } var dto = ObjectMapper.Map <WithdrawalEditDto>(result); return(new GetWithdrawalForEditOutput { WithdrawalEdit = dto }); }
public async Task <WithdrawalEditDto> GetWithdrawalAsync(int withdrawalId) { var result = new WithdrawalEditDto(); var header = await Repository .GetAllIncluding(x => x.Van, x => x.Salesman) .FirstOrDefaultAsync(x => x.Id == withdrawalId); if (header != null) { ObjectMapper.Map(header, result); var details = await _withdrawalDetailRepository.GetAll() .Include(x => x.Product) .Where(x => x.WithdrawalHeaderId == header.Id) .ToListAsync(); result.WithdrawalDetails = ObjectMapper.Map <List <WithdrawalEditDetailsDto> >(details); } return(result); }