Exemple #1
0
        public async Task UpdateAPHeaderTransactionUnit(APHeaderTransactionsInputUnit input)
        {
            var aPHeaderTransactionsInput = await _apHeaderTransactionsUnitRepository.GetAsync(input.AccountingDocumentId);

            Mapper.Map(input, aPHeaderTransactionsInput);
            await _apHeaderTransactionsUnitManager.UpdateAsync(aPHeaderTransactionsInput);

            if (!ReferenceEquals(input.InvoiceEntryDocumentDetailList, null))
            {
                //Bulk CRUD operations of InvoiceEntryDocumentDetails
                foreach (var invoiceEntryDocumentDetail in input.InvoiceEntryDocumentDetailList)
                {
                    if (invoiceEntryDocumentDetail.AccountingItemId == 0)
                    {
                        await CreateAPHeaderTransactionDetailUnit(invoiceEntryDocumentDetail, input.AccountingDocumentId);
                    }
                    else if (invoiceEntryDocumentDetail.AccountingItemId > 0)
                    {
                        await UpdateAPHeaderTransactionDetailUnit(invoiceEntryDocumentDetail);
                    }
                }
            }

            await CurrentUnitOfWork.SaveChangesAsync();
        }
Exemple #2
0
        public async Task <IdOutputDto <long> > CreateAPHeaderTransactionUnit(APHeaderTransactionsInputUnit input)
        {
            var apHeaderTransactions    = input.MapTo <ApHeaderTransactions>();
            IdOutputDto <long> response = new IdOutputDto <long>
            {
                Id = await _apHeaderTransactionsUnitManager.CreateAsync(apHeaderTransactions)
            };

            //Null Checking of InvoiceEntryDocumentDetailList
            if (!ReferenceEquals(input.InvoiceEntryDocumentDetailList, null))
            {
                //Bulk Insertion of InvoiceEntryDocumentDetails
                foreach (var invoiceEntryDocumentDetail in input.InvoiceEntryDocumentDetailList)
                {
                    await CreateAPHeaderTransactionDetailUnit(invoiceEntryDocumentDetail, response.Id);
                }
            }
            await CurrentUnitOfWork.SaveChangesAsync();

            return(response);
        }