예제 #1
0
        public async Task <IActionResult> CreateAccount(AccountViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest());
            }

            if (!_managementService.IsSupportCurrencyCharCode(model.CurrencyCharCode))
            {
                ModelState.AddModelError("CurrencyCharCode", "Not supported currency code.");
                model.AvailableCharCodes = GetAvailableCharCodes();
                return(View("Create", model));
            }

            var accountId = await _managementService.CreateAccount(Guid.Empty, model.CurrencyCharCode);

            await _managementService.Acquire(accountId, model.Amount);

            Log.Information($"Account with ID: {accountId} created");
            return(RedirectToAction("Index"));
        }