public IHttpActionResult AddBankAccount(int hId, string name, AccountType type, float startBal, float lowBal, string ownerId)
        {
            try
            {
                Guid ownerIdGuid = new Guid(ownerId);
            }
            catch (FormatException e)
            {
                return(BadRequest($"Invalid Value for ownerId: '{ownerId}'"));
            }

            if (!Enum.IsDefined(typeof(AccountType), type))
            {
                return(BadRequest($"Invalid Value for AccountType: '{type}'"));
            }

            var      startBalDecResult = Convert.ToDecimal(Math.Round(startBal, 2));
            var      lowBalDecResult   = Convert.ToDecimal(Math.Round(lowBal, 2));
            DateTime created           = DateTime.Now;

            var bankAccount = new BankAccount
            {
                HouseholdId     = hId,
                Name            = name,
                AccountType     = type,
                StartingBalance = startBalDecResult,
                CurrentBalance  = startBalDecResult,
                LowBalanceLevel = lowBalDecResult,
                OwnerId         = ownerId
            };

            return(Ok(_db.AddBankAccount(bankAccount)));
        }
예제 #2
0
 public IHttpActionResult AddBankAccount(int hhId, string ownerId, string name, AccountType accountType, int startBal, int currentBal, int lowBal)
 {
     return(Ok(db.AddBankAccount(hhId, ownerId, name, accountType, startBal, currentBal, lowBal)));
 }