예제 #1
0
        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);
        }
예제 #2
0
        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 });
        }