예제 #1
0
        /// <summary>
        /// Creates a new account bound to the client specified by <c>clientId</c>.
        /// </summary>
        /// <param name="clientId">The clientId of the owner of the account be modified.</param>
        /// <returns>The starting balance for the new account.</returns>
        ///
        public async Task <string> CreateAccount(string clientId)
        {
            UserInputValidation.ValidateClientId(clientId);

            var response = await this.InvokeApiAsync(Post, $"api/admin/create/{clientId}");

            var accountId = await response.TryGetResponseContent();

            return(accountId);
        }
        public ActionResult <string> Create([Required, FromRoute] string clientId)
        {
            Account newAccount;

            try
            {
                UserInputValidation.ValidateClientId(clientId);

                var userInfo = User.GetUserInfo();
                var username = userInfo.AccountsUsername;

                using (var session = Logic.Login(Repository, username))
                {
                    newAccount = Logic.CreateAccount(session, clientId);
                }
            }
            catch (AccountsLibException ex)
            {
                return(new ActionFailureResult(new ApiResponse(500, ex.Message)));
            }

            return(newAccount.AccountNumber);
        }