Example #1
0
        public async Task <GetDebitMemoForEditOutput> GetDebitMemoForEdit(EntityDto input)
        {
            var result = new DebitMemoEditDto();
            var header = await Repository
                         .GetAllIncluding(x => x.Supplier)
                         .FirstOrDefaultAsync(x => x.Id == input.Id);

            if (header != null)
            {
                ObjectMapper.Map(header, result);
                var details = await _debitMemoDetailRepository.GetAll()
                              .Include(x => x.Product)
                              .Where(x => x.DebitMemoHeaderId == header.Id)
                              .ToListAsync();

                result.DebitMemoDetails = ObjectMapper.Map <List <DebitMemoEditDetailsDto> >(details);
            }

            var debitMemoEditDto = ObjectMapper.Map <DebitMemoEditDto>(result);

            return(new GetDebitMemoForEditOutput
            {
                DebitMemoEdit = debitMemoEditDto
            });
        }
Example #2
0
        public async Task <DebitMemoEditDto> GetDebitMemoAsync(int debitMemoId)
        {
            var result    = new DebitMemoEditDto();
            var debitmemo = await Repository
                            .GetAllIncluding(x => x.Supplier)
                            .FirstOrDefaultAsync(x => x.Id == debitMemoId);

            if (debitmemo != null)
            {
                ObjectMapper.Map(debitmemo, result);
                var details = await _debitMemoDetailRepository.GetAll()
                              .Include(x => x.Product)
                              .Where(x => x.DebitMemoHeaderId == debitmemo.Id)
                              .ToListAsync();

                result.DebitMemoDetails = ObjectMapper.Map <List <DebitMemoEditDetailsDto> >(details);
            }

            return(result);
        }