public IActionResult AddBill() { // For passing simple types. // return RedirectToAction("ManageBills", new { productID = 5, productName = "bob"}); string userId = User.getUserId(); RoomieRepo roomieRepo = new RoomieRepo(_context); Roommate currentSignedInUser = roomieRepo.GetRoommate(userId); IEnumerable <Roommate> roommates = roomieRepo.GetAllOtherRoommates(userId); AddTransactionVM addTransactionVM = new AddTransactionVM { currentUser = currentSignedInUser, otherRoommates = roommates }; return(View(addTransactionVM)); }
public async Task <ActionResult> AddTransaction(string monzoTransId, string name, decimal amount, string date, bool?isFinance, int?Id, CategoryType?secondTypeId) { var viewModel = new AddTransactionVM { IsFinance = isFinance ?? false }; if (Id.HasValue) { viewModel.SelectedId = Id.Value; } viewModel.Date = date; viewModel.MonzoTransId = monzoTransId; viewModel.Amount = amount; if (amount < 0) { var finances = await monzoService.GetFinances(); viewModel.Finances = finances; viewModel.Name = name; viewModel.Type = CategoryType.Spendings; viewModel.ActualAmount = (-amount / 100m); } else { viewModel.Type = CategoryType.Income; viewModel.ActualAmount = (amount / 100m); } // get categories and sub-categories var categories = await monzoService.GetCategories(amount < 0?CategoryType.Spendings : CategoryType.IncomeSources); viewModel.Categories = categories; if (secondTypeId.HasValue && secondTypeId != 0) { var secondCategories = await monzoService.GetCategories(secondTypeId); viewModel.SecondCategories = secondCategories; } return(View("AddTransaction", viewModel)); }