public ActionResult Create(int?Id)
        {
            // Household Id
            if (Id is null)
            {
                TempData.Add("Message", "Improper Id");
                TempData.Add("MessageColour", "danger");
                return(RedirectToAction("Index", "Household"));
            }

            var viewModel = new CreateTransactionViewModel()
            {
                HouseholdId = (int)Id,
                Date        = DateTime.Now
            };

            TransactionHelpers.SetDropDownLists(viewModel, Request);

            if (TransactionHelpers.BankAccntOrCategoriesIsNull(viewModel, TempData))
            {
                return(RedirectToAction("Index", "Household"));
            }

            return(View(viewModel));
        }
        public ActionResult Create(CreateTransactionViewModel transactionViewModel)
        {
            if (!ModelState.IsValid || transactionViewModel.BankAccountId is null || transactionViewModel.CategoryId is null)
            {
                TransactionHelpers.SetDropDownLists(transactionViewModel, Request);

                if (TransactionHelpers.BankAccntOrCategoriesIsNull(transactionViewModel, TempData))
                {
                    return(RedirectToAction("Index", "Household"));
                }

                return(View(transactionViewModel));
            }


            var url = $"{ProjectConstants.APIURL}/api/transaction/create/{transactionViewModel.BankAccountId}";

            var parameters = new List <KeyValuePair <string, string> >
            {
                new KeyValuePair <string, string>("Title", transactionViewModel.Title),
                new KeyValuePair <string, string>("Description", transactionViewModel.Description),
                new KeyValuePair <string, string>("Amount", transactionViewModel.Amount.ToString()),
                new KeyValuePair <string, string>("Date", transactionViewModel.Date.ToString()),
                new KeyValuePair <string, string>("CategoryId", transactionViewModel.CategoryId.ToString()),
            };

            var encodedParameters = new FormUrlEncodedContent(parameters);
            var response          = HttpClientContext.httpClient.PostAsync(url, encodedParameters).Result;

            if (response.IsSuccessStatusCode)
            {
                TempData.Add("Message", "Transaction Created!");
                return(RedirectToAction("HouseholdTransactions", "Transaction", new { Id = transactionViewModel.HouseholdId }));
            }
            else
            {
                TransactionHelpers.SetDropDownLists(transactionViewModel, Request);
                if (TransactionHelpers.BankAccntOrCategoriesIsNull(transactionViewModel, TempData))
                {
                    return(RedirectToAction("Index", "Household"));
                }

                ErrorHelpers.HandleResponseErrors(response, TempData, ModelState);

                return(View(transactionViewModel));
            }
        }