Ejemplo n.º 1
0
        public ActionResult SetupAlert(SetupAlertViewModel viewModel)
        {
            Account account = db.Accounts.Find(viewModel.SelectedAccountId);

            var studentProfile = db.UserProfiles.Local.SingleOrDefault(u => u.UserName == User.Identity.Name)
                ?? db.UserProfiles.SingleOrDefault(u => u.UserName == User.Identity.Name);

            var student = db.Students.Find(studentProfile.UserId);

            if (ModelState.IsValid)
            {
                try
                {
                    student.AlertAccountID = viewModel.SelectedAccountId;
                    student.bAlertSetup = true;
                    student.AccountThreshold = viewModel.AmountThreshold;
                    db.Entry(student).State = EntityState.Modified;
                    db.SaveChanges();
                }
                catch (DataException)
                {
                    ModelState.AddModelError("", "Something went wrong, transfer could not be completed.");
                }
            }
            return RedirectToAction("AccountSummary");
        }
Ejemplo n.º 2
0
        public ActionResult SetupAlert()
        {
            //Get logged in user
            var studentProfile = db.UserProfiles.Local.SingleOrDefault(u => u.UserName == User.Identity.Name)
                ?? db.UserProfiles.SingleOrDefault(u => u.UserName == User.Identity.Name);
            //Get student account associated with logged in user
            var student = db.Students.Find(studentProfile.UserId);
            //Get accounts associated with student account
            var accounts = db.Accounts.Where(x => x.StudentID == student.UserId);

            var selectionList = new SelectList(accounts, "AccountID", "AccountName");

            var vm = new SetupAlertViewModel { ListOfAccounts = selectionList };

            return View(vm);
        }