public IHttpActionResult Create(int?Id, BankAccountBindingModel bankAccountBindingModel)
        {
            if (ModelState is null || !ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            var household = DbContext.Households.FirstOrDefault(p => p.Id == Id);

            if (household is null)
            {
                return(NotFound());
            }

            var bankAccount = new BankAccount
            {
                Name        = bankAccountBindingModel.Name,
                Description = bankAccountBindingModel.Description,
                DateCreated = DateTime.Now,
                DateUpdated = null,
                Balance     = 0.0m,
                Household   = household
            };

            household.BankAccounts.Add(bankAccount);
            DbContext.SaveChanges();

            var bankAccountView = BankAccountHelpers.MapBankAccountToView(bankAccount);

            return(Created(Url.Link(
                               "GetBankAccountById",
                               new { bankAccount.Id }),
                           bankAccountView
                           ));
        }
        public IHttpActionResult GetAllByHousehold(int?Id)
        {
            var userId = User.Identity.GetUserId();

            if (userId is null)
            {
                return(Unauthorized());
            }

            var bankAccounts = DbContext.Households.FirstOrDefault(p => p.Id == Id).BankAccounts.ToList();

            if (bankAccounts is null)
            {
                return(BadRequest("No Accounts for this household"));
            }

            var viewModels = bankAccounts.Select(p => BankAccountHelpers.MapBankAccountToView(p));

            return(Ok(viewModels));
        }
        private IHttpActionResult OkView(List <BankAccount> bankAccounts)
        {
            var bankAccountViews = bankAccounts.Select(p => BankAccountHelpers.MapBankAccountToView(p));

            return(Ok(bankAccountViews));
        }
        private IHttpActionResult OkView(BankAccount bankAccount)
        {
            var bankAccountView = BankAccountHelpers.MapBankAccountToView(bankAccount);

            return(Ok(bankAccountView));
        }