コード例 #1
0
        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);
        }
コード例 #2
0
 // GET: AccountStatements/Create
 public IActionResult Create(int? accountId = null)
 {
     var viewModel = new AccountStatementViewModel { BankAccountId = accountId };
     ViewData["BankAccountId"] = new SelectList(context.BankAccounts, "Id", "Name");
     return View(viewModel);
 }