예제 #1
0
        public ActionResult SetRole(SetRoleUpsertModel model, string searchQueryId = null)
        {
            if (!ModelState.IsValid)
            {
                using (ContextManager.NewConnection())
                {
                    ViewBag.Roles = roleService.Search(new RoleQuery());
                }

                return(Json(RenderRazorViewToString("_SetRole", model), JsonRequestBehavior.AllowGet));
            }

            var mappedModel = Mapper.Map <SetRole>(model);
            UserTableViewModel updatedUser;

            using (var transaction = ContextManager.NewTransaction())
            {
                userService.SetUserRoles(mappedModel);
                transaction.Commit();
                updatedUser = Mapper.Map <UserTableViewModel>(
                    userService.Search(new UserQuery {
                    Id = model.UserId
                }).SingleOrDefault());
            }

            RefreshGridItem(searchQueryId, updatedUser, x => x.Id == updatedUser.Id);
            return(Json(
                       new { success = true, refreshgrid = true, searchqueryid = searchQueryId },
                       JsonRequestBehavior.AllowGet));
        }
예제 #2
0
        public ActionResult SetRole(Guid id, string searchQueryId = null)
        {
            var model = new SetRoleUpsertModel
            {
                UserId = id
            };

            ViewBag.SearchQueryId = searchQueryId;

            using (ContextManager.NewConnection())
            {
                model.Roles   = roleService.GetUserRoles(id);
                ViewBag.Roles = roleService.Search(new RoleQuery {
                    UserId = User.Id
                });
            }

            return(PartialView("_SetRole", model));
        }