public Response<Account> CreateAccount(CreateAccountRequest request) { var response = new Response<Account>(); var newAccount = request.Account; var repo = new AccountRepository(); repo.CreateAccount(newAccount); response.Success = true; response.Data = newAccount; return response; }
public Response<CreateReceipt> Create(string[] newAccount) { AccountRepository repo = new AccountRepository(); var response = new Response<CreateReceipt>(); var allAccounts = repo.GetAllAccounts(); List<int> accountNums = new List<int>(); foreach (var accout in allAccounts) { accountNums.Add(accout.AccountNumber); } int freshAccountNumber = accountNums.Max() + 1; try { if (Decimal.Parse(newAccount[2]) <= 0) { response.Success = false; response.Message = "Must initially deposit a positive value."; } else { response.Data = new CreateReceipt(); response.Data.AccountNumber = freshAccountNumber; response.Data.FirstName = newAccount[0]; response.Data.LastName = newAccount[1]; response.Data.InitalAmount = Decimal.Parse(newAccount[2]); response.Success = true; response.Message = "Account successfully created. Press any key to continue..."; repo.CreateAccount(response); } } catch (Exception ex) { response.Success = false; response.Message = ex.Message; } return response; }