public ActionResult Create(ProfileViewModel profile) { return View(new CreateViewModel { CategoryTypes = DataHelpers.GetCategoryTypeSelectOptions(), Accounts = DataHelpers.GetAccountSelectOptions(_accountServices), RedirectAfterSubmitUrl = _url.Action("Index") }); }
public ActionResult Delete(ProfileViewModel profile, int id, string redirectAfterSubmitUrl) { _categoryServices.Delete(id); // Clear the cache of anything that depends upon categories _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Category)); return Redirect(redirectAfterSubmitUrl); }
public ActionResult ClearCacheContents(ProfileViewModel profile, string id) { if (string.IsNullOrEmpty(id)) { _cache.Clear(); return Content("CLEARED ALL CACHE"); } else { _cache.Remove(id); return Content("CLEARED CACHE " + id); } }
public ActionResult Create(ProfileViewModel profile) { var accounts = _accountServices.All(); var model = new CreateViewModel { AccountTypes = DataHelpers.GetAccountTypeSelectOptions(), Default = (accounts.Count() == 0) ? true : false, IncludeInNetWorth = true, RedirectAfterSubmitUrl = _url.Action("Index") }; if (accounts.Count() == 0) model.Type = AccountTypeDTO.Current; return View(model); }
public ActionResult Create(ProfileViewModel profile, CreateViewModel model) { if (!ModelState.IsValid) { model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices); model.CategoryTypes = DataHelpers.GetCategoryTypeSelectOptions(); return View(model); } var dto = model.MapTo<CategoryDTO>(); _categoryServices.Save(dto); // Clear the cache of anything that depends upon categories _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Category)); return Redirect(model.RedirectAfterSubmitUrl); }
public ActionResult Create(ProfileViewModel profile, CreateViewModel model) { if (!ModelState.IsValid) { model.Categories = DataHelpers.GetCategorySelectOptions(_categoryServices); model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices); return View(model); } var dto = model.MapTo<TransactionDTO>(); _transactionServices.Save(dto); // Clear the cache of anything that depends upon transactions _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Transaction)); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); return Redirect(model.RedirectAfterSubmitUrl); }
public ActionResult Create(ProfileViewModel profile, CreateViewModel model) { if (!ModelState.IsValid) { model.AccountTypes = DataHelpers.GetAccountTypeSelectOptions(); return View(model); } var dto = model.MapTo<AccountDTO>(); _accountServices.Save(dto); var encodedPageState = EncryptionHelpers.EncodeReturnParameters(dto.AccountID, MABMoney.Web.Models.Home.TransactionType.Expense, MABMoney.Web.Models.Home.DashboardTab.BudgetOrPaymentCalc); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); // Clear the account cache so redirect is valid _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Account)); // TODO: This doesn't respect RedirectAfterSubmitUrl, should it? return RedirectToRoute("Home-State", new { state = encodedPageState }); }
public ActionResult CreateTransaction(ProfileViewModel profile, IndexViewModel model) { if (!ModelState.IsValid) { GetModelData(model, profile.UserID, model.Account_AccountID); return View("Index", model); } model.Tab = DashboardTab.BudgetOrPaymentCalc; switch (model.Type) { case TransactionType.Income: if (model.Amount < 0) model.Amount *= -1; model.Tab = DashboardTab.Income; break; case TransactionType.Expense: if (model.Amount > 0) model.Amount *= -1; model.Tab = DashboardTab.Expenses; break; } var dto = model.MapTo<TransactionDTO>(); _transactionServices.Save(dto); // Clear the cache of anything that depends upon transactions _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Transaction)); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); var encodedPageState = EncryptionHelpers.EncodeReturnParameters(model.Account_AccountID, model.Type, model.Tab); return RedirectToRoute("Home-State", new { state = encodedPageState }); }
public ActionResult Create(ProfileViewModel profile, int? id) { var categories = _categoryServices.All().Where(x => x.Type == CategoryTypeDTO.Expense); var budgets = new List<SelectListItem>().AsQueryable(); if (id.HasValue) { categories = categories.Where(x => x.Account_AccountID == id.Value); budgets = _budgetServices.All().Where(x => x.Account_AccountID == id.Value).OrderByDescending(x => x.End).Select(x => new SelectListItem { Value = x.BudgetID.ToString(), Text = x.Start.ToString("dd/MM/yyyy") + " - " + x.End.ToString("dd/MM/yyyy") }).AsQueryable(); } var now = DateTime.Now; var categoryItems = categories.ToList().Select(x => new Category_BudgetViewModel { Category_CategoryID = x.CategoryID, Name = x.Name }).ToList(); if (categoryItems == null || categoryItems.Count == 0) categoryItems.Add(new Category_BudgetViewModel { Name = "NEW CATEGORY" }); return View(new CreateViewModel { Start = new DateTime(now.Year, now.Month, 1), End = new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)), Account_AccountID = (id.HasValue) ? id.Value : 0, Accounts = DataHelpers.GetAccountSelectOptions(_accountServices), Categories = categoryItems, Budgets = budgets, RedirectAfterSubmitUrl = _url.Action("Index") }); }
public ActionResult Index(ProfileViewModel profile) { return View(new IndexViewModel { Categories = _categoryServices.All().ToList() }); }
public ActionResult ShowCacheContents(ProfileViewModel profile) { // We filter on Site Key because newer versions of MVC seem to stuff a load of other data into the memory cache // which we're not interested in (break on the line below and inspect _cache.BaseCache to see what I mean...) return View(_cache.Items.Where(x => x.Key.StartsWith(_config.Get<string>("CookieKey"))).OrderByDescending(x => x.Hits).ToList()); }
public ActionResult MainNavigation(ProfileViewModel profile) { string debug = null; var accounts = _accountServices.All().ToList(); var netWorthAccounts = accounts.Where(x => x.IncludeInNetWorth).ToList(); var nonNetWorthAccounts = accounts.Where(x => !x.IncludeInNetWorth).ToList(); return View(new MainNavigationViewModel { UserID = (profile != null) ? profile.UserID : 0, UserEmail = (profile != null) ? profile.Email : null, Accounts = accounts, NetWorthAccounts = netWorthAccounts, NonNetWorthAccounts = nonNetWorthAccounts, NetWorth = netWorthAccounts.Sum(x => x.CurrentBalance), Debug = debug }); }
public ActionResult InvalidateCache(ProfileViewModel profile, string id) { _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(id)); return Content("INVALIDATED DEPENDENCY: " + id); }
public ActionResult Index(ProfileViewModel profile, int account_accountId) { var encodedPageState = EncryptionHelpers.EncodeReturnParameters(account_accountId, TransactionType.Expense, DashboardTab.BudgetOrPaymentCalc); return RedirectToRoute("Home-State", new { state = encodedPageState }); }
public ActionResult Index(ProfileViewModel profile, string state = null) { var model = new IndexViewModel(); model.Date = DateTime.Now; if (state != null) { var pageState = EncryptionHelpers.DecodeReturnParameters(state); model = GetModelData(model, profile.UserID, Convert.ToInt32(pageState[0])); if (model == null) return RedirectToAction("Create", "Account"); model.Type = (TransactionType)Convert.ToInt32(pageState[1]); model.Tab = (DashboardTab)Convert.ToInt32(pageState[2]); // If it's a savings account it will not have the payment calc or the budget tab, so just set to income if (model.Account.Type == AccountTypeDTO.Savings && model.Tab == DashboardTab.BudgetOrPaymentCalc) model.Tab = DashboardTab.Income; return View(model); } else { model = GetModelData(model, profile.UserID, null); if (model == null) return RedirectToAction("Create", "Accounts"); return View(model); } }
public ActionResult Edit(ProfileViewModel profile, int id) { var model = _accountServices.Get(id).MapTo<EditViewModel>(); model.AccountTypes = DataHelpers.GetAccountTypeSelectOptions(); if (!string.IsNullOrWhiteSpace(model.TransactionDescriptionHistoryAsString)) model.TransactionDescriptionHistoryAsString = string.Join(Environment.NewLine, model.TransactionDescriptionHistoryAsString.Split('|').OrderBy(x => x)); model.RedirectAfterSubmitUrl = _url.Action("Index"); return View(model); }
public ActionResult Edit(ProfileViewModel profile, EditViewModel model) { if (!ModelState.IsValid) { model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices); return View(model); } var dto = model.MapTo<BudgetDTO>(); _budgetServices.Save(dto); foreach (var category in model.Categories) { if (category.Delete) { // TODO: Should this not be deleting the *join*, rather than the actual category? _categoryServices.Delete(category.Category_CategoryID); } else { _budgetServices.SaveCategoryBudget(new Category_BudgetDTO { Budget_BudgetID = dto.BudgetID, Account_AccountID = model.Account_AccountID, Category_CategoryID = category.Category_CategoryID, CategoryName = category.Name, Amount = category.Amount }); } } // Clear the cache of anything that depends upon budgets _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Budget)); return Redirect(model.RedirectAfterSubmitUrl); }
public ActionResult Details(ProfileViewModel profile, int id) { var dto = _budgetServices.Get(id); var model = dto.MapTo<DetailsViewModel>(); model.Categories = dto.Category_Budgets.ToList(); return View(model); }
public ActionResult Index(ProfileViewModel profile) { return View(new IndexViewModel { Accounts = _accountServices.All().ToList() }); }
public ActionResult GetTransactionDescriptionHistory(ProfileViewModel profile, string query, int? id) { if (!id.HasValue) return Json(new string[0]); var account = _accountServices.Get(id.Value); return Json(account.TransactionDescriptionHistory.ToArray()); }
public ActionResult Edit(ProfileViewModel profile, EditViewModel model) { if (!ModelState.IsValid) { model.AccountTypes = DataHelpers.GetAccountTypeSelectOptions(); return View(model); } var dto = model.MapTo<AccountDTO>(); if (!string.IsNullOrWhiteSpace(model.TransactionDescriptionHistoryAsString)) dto.TransactionDescriptionHistory = model.TransactionDescriptionHistoryAsString.Split(new string[] { Environment.NewLine }, StringSplitOptions.RemoveEmptyEntries).ToList(); _accountServices.Save(dto); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); // Clear the account cache _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Account)); return Redirect(model.RedirectAfterSubmitUrl); }
public ActionResult Index(ProfileViewModel profile, IndexViewModel model) { return View(GetTransactionIndexViewModel(profile.UserID, model.AccountID, model.CategoryID, model.From, model.To)); }
public ActionResult CreateFromExistingBudget(ProfileViewModel profile, CreateFromExistingBudgetViewModel model) { if(model.Budget_BudgetID == 0) return RedirectToAction("Create", new { id = model.Account_AccountID }); var categories = _categoryServices.All().Where(x => x.Type == CategoryTypeDTO.Expense && x.Account_AccountID == model.Account_AccountID); var budgets = _budgetServices.All().Where(x => x.Account_AccountID == model.Account_AccountID).OrderByDescending(x => x.End); var now = DateTime.Now; var categoryAmounts = categories.ToList().Select(x => new Category_BudgetViewModel { Category_CategoryID = x.CategoryID, Name = x.Name }).ToList(); if(model.Budget_BudgetID != 0) { var budget = _budgetServices.Get(model.Budget_BudgetID); categoryAmounts = budget.Category_Budgets.Where(x => x.Category_CategoryID != 0).Select(x => new Category_BudgetViewModel { Name = x.CategoryName, Budget_BudgetID = x.Budget_BudgetID, Category_CategoryID = x.Category_CategoryID, Amount = x.Amount, Total = x.Total }).ToList(); var newCategories = categories.Where(x => !categoryAmounts.Any(c => c.Category_CategoryID == x.CategoryID)) .Select(x => new Category_BudgetViewModel { Category_CategoryID = x.CategoryID, Name = x.Name }).ToList(); categoryAmounts.AddRange(newCategories); } return View(new CreateFromExistingBudgetViewModel { Start = new DateTime(now.Year, now.Month, 1), End = new DateTime(now.Year, now.Month, DateTime.DaysInMonth(now.Year, now.Month)), Account_AccountID = model.Account_AccountID, Accounts = DataHelpers.GetAccountSelectOptions(_accountServices), Budget_BudgetID = model.Budget_BudgetID, Budgets = budgets.Select(x => new SelectListItem { Value = x.BudgetID.ToString(), Text = x.Start.ToString("dd/MM/yyyy") + " - " + x.End.ToString("dd/MM/yyyy") }).AsQueryable(), Categories = categoryAmounts, RedirectAfterSubmitUrl = _url.Action("Index") }); }
public ActionResult Edit(ProfileViewModel profile, int id) { var model = _categoryServices.Get(id).MapTo<EditViewModel>(); model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices);model.CategoryTypes = DataHelpers.GetCategoryTypeSelectOptions(); model.CategoryTypes = DataHelpers.GetCategoryTypeSelectOptions(); model.RedirectAfterSubmitUrl = _url.Action("Index"); return View(model); }
public ActionResult Edit(ProfileViewModel profile, int id) { var budget = _budgetServices.Get(id); var model = budget.MapTo<EditViewModel>(); model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices); model.Categories = budget.Category_Budgets.Where(x => x.Category_CategoryID != 0).Select(x => new Category_BudgetViewModel { Name = x.CategoryName, Budget_BudgetID = x.Budget_BudgetID, Category_CategoryID = x.Category_CategoryID, Amount = x.Amount, Total = x.Total }).ToList(); model.RedirectAfterSubmitUrl = _url.Action("Index"); var categories = _categoryServices.All() .Where(x => x.Account_AccountID == budget.Account_AccountID && x.Type == CategoryTypeDTO.Expense && !model.Categories.Any(c => c.Category_CategoryID == x.CategoryID)) .Select(x => new Category_BudgetViewModel { Category_CategoryID = x.CategoryID, Name = x.Name }) .ToList(); model.Categories.AddRange(categories); return View(model); }
public ActionResult Delete(ProfileViewModel profile, int id, string redirectAfterSubmitUrl) { _accountServices.Delete(id); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); // Clear the cached account list _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Account)); return Redirect(redirectAfterSubmitUrl); }
public ActionResult Index(ProfileViewModel profile) { return View(new IndexViewModel { Budgets = _budgetServices.All().OrderByDescending(x => x.Start).ToList() }); }
public ActionResult CreateTransfer(ProfileViewModel profile, IndexViewModel model) { if (!ModelState.IsValid) { GetModelData(model, profile.UserID, model.Account_AccountID); model.Tab = DashboardTab.Transfers; return View("Index", model); } model.Tab = DashboardTab.Transfers; var sourceAccount = _accountServices.Get(model.SourceAccountID); var destinationAccount = _accountServices.Get(model.DestinationAccountID); // Do Transfer var guid = Guid.NewGuid().ToString(); // Make sure the amount is not negative if(model.Amount < 0) model.Amount *= -1; var sourceTransaction = new TransactionDTO { TransferGUID = guid, Account_AccountID = model.SourceAccountID, Date = model.Date, Category_CategoryID = model.Category_CategoryID, Amount = (model.Amount * -1), Description = "Transfer to " + destinationAccount.Name, Note = model.Note }; var destinationTransaction = new TransactionDTO { TransferGUID = guid, Account_AccountID = model.DestinationAccountID, Date = model.Date, // Don't set the category of the destination because we can't know what it should be // Category_CategoryID = model.Category_CategoryID, Amount = model.Amount, Description = "Transfer from " + sourceAccount.Name, Note = model.Note }; _transactionServices.Save(sourceTransaction); _transactionServices.Save(destinationTransaction); // Clear the cache of anything that depends upon transactions _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Transaction)); // Clear the user because current balance comes from User.Accounts property _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.User)); var encodedPageState = EncryptionHelpers.EncodeReturnParameters(model.Account_AccountID, model.Type, model.Tab); return RedirectToRoute("Home-State", new { state = encodedPageState }); }
public ActionResult Create(ProfileViewModel profile, CreateViewModel model) { if (!ModelState.IsValid) { model.Accounts = DataHelpers.GetAccountSelectOptions(_accountServices); model.Budgets = _budgetServices.All().Where(x => x.Account_AccountID == model.Account_AccountID).Select(x => new SelectListItem { Value = x.BudgetID.ToString(), Text = x.Start.ToString("dd/MM/yyyy") + " - " + x.End.ToString("dd/MM/yyyy") }).AsQueryable(); return View(model); } var dto = model.MapTo<BudgetDTO>(); _budgetServices.Save(dto); foreach (var category in model.Categories) { if(category.Delete) { _categoryServices.Delete(category.Category_CategoryID); } else { _budgetServices.SaveCategoryBudget(new Category_BudgetDTO { Account_AccountID = model.Account_AccountID, Budget_BudgetID = dto.BudgetID, Category_CategoryID = category.Category_CategoryID, CategoryName = category.Name, Amount = category.Amount }); } } // Clear the cache of anything that depends upon budgets _cache.InvalidateAllWithDependency(_cachingHelpers.GetDependencyKey(CachingDependency.Budget)); return Redirect(model.RedirectAfterSubmitUrl); }
public ActionResult Index(ProfileViewModel profile, int? id) { return View(GetTransactionIndexViewModel(profile.UserID, id, null, null, null)); }