Exemple #1
0
        public ActionResult New(int id)
        {
            var selectedUser       = _userContext.Get(id);
            var selectedGlAccounts = _glAccountContext.GetAllUnassigned();
            var selectedViewModel  = new NewTellerViewModel
            {
                User      = selectedUser,
                GlAccount = selectedGlAccounts
            };

            return(View("TellerForm", selectedViewModel));
        }
Exemple #2
0
        public ActionResult Save(Teller teller)
        {
            int userId = Convert.ToInt32(Request.Form["userId"]);

            if (_userContext.GetUnassigned(userId) != null)
            {
                var user      = new User();
                var glAccount = new GlAccount();

                var userInDb      = _userContext.Get(userId);
                var glAccountInDb = _glAccountContext.Get(teller.GlAccountId);

                userInDb.IsAssigned = true;
                _userContext.Update(user);

                glAccountInDb.IsAssigned = true;
                _glAccountContext.Update(glAccount);

                teller.UserId = userId;
                _context.Save(teller);
                TempData["Success"] = "Till Account Assigned Successfully";
                return(RedirectToAction("Index"));
            }

            ViewBag.hasTillAccount = "User Has Till Account";
            var tellers            = _context.GetWithAll();
            var selectedUser       = _userContext.Get(userId);
            var selectedGlAccounts = _glAccountContext.GetAllUnassigned();
            var selectedViewModel  = new NewTellerViewModel
            {
                User      = selectedUser,
                GlAccount = selectedGlAccounts
            };

            return(View("TellerForm", selectedViewModel));
        }