Beispiel #1
0
        public ActionResult Save(ExpensesModel model)
        {
            BudgetModel    bmodel  = new BudgetModel();
            SessionManager session = new SessionManager();
            int            userId  = session.Get <User>(PageConstant.USER_ID_I_SESSION).Id;

            model.BudgetId = session.Get <Budget>(PageConstant.BUDGET_ID_IN_SESSION).Id;
            model.Save(model);

            Budget budget = bmodel.GetCurrentBudget(userId);

            budget.CurrentBudget = budget.CurrentBudget - model.Amount;
            bmodel.UpdateBudget(budget);

            bmodel.CurrentBudget = budget.CurrentBudget;
            bmodel.StartBudget   = budget.StartBudget;
            return(View("MainPanel", bmodel));
        }
        public ActionResult Login(UserModel model)
        {
            User user = model.Get(model);

            if (user != null)
            {
                SessionManager sessionManager  = new SessionManager();
                bool           passwordCorrect = CheckPassword(user.Password, model.Password);

                if (passwordCorrect)
                {
                    if (!user.IsActive)
                    {
                        user.IsActive = true;
                        model.UpdateUser(user);
                    }

                    sessionManager.Add <User>(user, PageConstant.USER_ID_I_SESSION);
                    ViewBag.Name = user.Name;

                    BudgetModel bmodel = new BudgetModel();
                    Budget      budget = bmodel.GetCurrentBudget(user.Id);

                    if (budget == null)
                    {
                        return(RedirectToAction("FirstLaunch", "FirstLaunch"));
                    }

                    sessionManager.Add <Budget>(budget, PageConstant.BUDGET_ID_IN_SESSION);

                    bmodel.CurrentBudget = budget.CurrentBudget;
                    bmodel.StartBudget   = budget.StartBudget;
                    return(View("MainPanel", bmodel));
                }
            }
            else
            {
                ModelState.AddModelError("", "Error");
            }

            ModelState.Clear();
            return(View("UserLoginView"));
        }
Beispiel #3
0
        public ActionResult Save(FirstLaunchModel model)
        {
            BudgetModel    budgetModel    = new BudgetModel();
            SettingsModel  settingModel   = new SettingsModel();
            SessionManager sessionManager = new SessionManager();
            int            userid         = sessionManager.Get <User>(PageConstant.USER_ID_I_SESSION).Id;

            budgetModel        = model.Budget;
            settingModel       = model.Settings;
            budgetModel.UserId = settingModel.UserId = userid;
            budgetModel.AddBudget(budgetModel);
            settingModel.AddSettings(settingModel);

            Budget budget = budgetModel.GetCurrentBudget(userid);

            sessionManager.Add <Budget>(budget, PageConstant.BUDGET_ID_IN_SESSION);
            budgetModel.CurrentBudget = budget.CurrentBudget;
            budgetModel.StartBudget   = budget.StartBudget;

            return(View("MainPanel", budgetModel));
        }