public async Task<IActionResult> Create(AccountStatementViewModel model)
        {
            if (ModelState.IsValid)
            {
                IFileUpload upload;
                try
                {
                    upload = await context.SaveFileUploadAsync(model.Attachment);
                }
                catch (Exception ex)
                {
                    throw new Exception("Failed to save uploaded file. Please upload it again later.", ex);
                }
                var statement = new AccountStatement
                {
                    BankAccountId = model.BankAccountId.Value,
                    FileUploadId = upload.Id,
                    ProcessedAt = DateTimeOffset.Now
                };
                context.AccountStatements.Add(statement);
                await context.SaveChangesAsync();

                statementProcessor.StartProcessing(statement.Id);

                return RedirectToAction("Index");
            }
            ViewData["BankAccountId"] = new SelectList(context.BankAccounts, "Id", "Name", model.BankAccountId);
            return View(model);
        }
 public BankAccountDetailsViewModel(BankAccount account, BankAccountDetailsTab activeTab, AccountStatement[] statements = null)
 {
     Account = account;
     ActiveTab = activeTab;
     Statements = statements;
 }
 public async Task<IActionResult> Edit(AccountStatement accountStatement)
 {
     if (ModelState.IsValid)
     {
         context.Update(accountStatement);
         await context.SaveChangesAsync();
         return RedirectToAction("Index");
     }
     ViewData["BankAccountId"] = new SelectList(context.BankAccounts, "Id", "BankAccount", accountStatement.BankAccountId);
     ViewData["FileUploadId"] = new SelectList(context.FileUploads, "Id", "FileUpload", accountStatement.FileUploadId);
     return View(accountStatement);
 }