コード例 #1
0
        public ActionResult NewUser(UserModel user, UserFilterModel filter)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    EmployeeServices.CreateUser(user);
                    return RedirectToAction("UserListing", filter.GenerateUserAccessRoute());
                }
            }
            catch (Exception ex)
            {
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
            }

            // Invalid - redisplay with errors
            var model = new UserDetailModel()
            {
                Action = "NewUser",
                User = user,
                Filter = filter,
                Roles = LookupServices.GetRoleOptions(user.RoleName)
            };

            ViewBag.Locations = LocationServices.GetLocationLookup(true, -1);
            return View("UserDetail", model);
        }
コード例 #2
0
        public ActionResult EditUser(int id, UserFilterModel filter, FormCollection collection)
        {
            var user = EmployeeServices.GetUser(id);

            try
            {
                UpdateModel(user, "User");
                EmployeeServices.UpdateUser(user);

                return RedirectToAction("UserListing", filter.GenerateUserAccessRoute());
            }
            catch (Exception ex)
            {
                // Invalid - redisplay with errors
                Logger.Error(ex.ToString());
                ModelState.AddModelError(String.Empty, Constants.ServerError);
                var model = new UserDetailModel()
                {
                    Action = "EditUser",
                    User = user,
                    Filter = filter,
                    Roles = LookupServices.GetRoleOptions(user.RoleName)
                };

                ViewBag.Locations = LocationServices.GetLocationLookup(true, model.User.LocationId);
                return View("UserDetail", model);
            }
        }
コード例 #3
0
        public ActionResult NewUser(UserFilterModel filter)
        {
            var model = new UserDetailModel()
            {
                Action = "NewUser",
                User = new UserModel(),
                Filter = filter,
                Roles = LookupServices.GetRoleOptions("Employee")
            };
            model.User.PasswordString = PasswordGenerator.GeneratePassword();

            ViewBag.Locations = LocationServices.GetLocationLookup(true, -1);
            return View("UserDetail", model);
        }
コード例 #4
0
        public ActionResult EditUser(int id, UserFilterModel filter)
        {
            var user = EmployeeServices.GetUser(id);

            var model = new UserDetailModel()
            {
                Action = "EditUser",
                User = user,
                Filter = filter,
                Roles = LookupServices.GetRoleOptions(user.RoleName)
            };

            ViewBag.Locations = LocationServices.GetLocationLookup(true, model.User.LocationId);
            return View("UserDetail", model);
        }