public async Task <IActionResult> Index(OFXUploadViewModelRequest ofxFileViewModel)
        {
            if (ModelState.IsValid)
            {
                await _transactionApp.UploadOFXFiles(ofxFileViewModel);

                return(RedirectToAction("Index", "Home"));
            }

            return(View());
        }
Exemplo n.º 2
0
        public async Task UploadOFXFiles(OFXUploadViewModelRequest OfxFileViewModelRequest)
        {
            //Read file(s) content and transform into a list of transactions
            IEnumerable <Transaction> transactionsToVerify = await _ofxfilereader
                                                             .ReadOFXFileAsync(OfxFileViewModelRequest.Files);

            //retrieve all transactions save in database
            IEnumerable <Transaction> transactionsFromBase =
                await _transactionRepository.GetAll();

            //remove duplicated transactions inside the list + database
            IEnumerable <Transaction> transactionsToSave =
                _conciliation.BeginConciliation(transactionsToVerify, transactionsFromBase);

            await _transactionRepository.InsertRange(transactionsToSave);
        }