示例#1
0
        public ViewResult Edit(int id, string returnUrl)
        {
            var model = new EditViewModel
                            {
                                UserProfile = this.UserProfileRepository.Find(id),
                                ReturnUrl = returnUrl
                            };

            var currentRoles = this.roles.GetRolesForUser(model.UserProfile.UserName).ToList();

            model.IsAdmin = currentRoles.Contains(ApplicationRole.Admin);
            model.IsInstitutionAdmin = currentRoles.Contains(ApplicationRole.InstitutionAdmin);
            model.IsDataAdmin = currentRoles.Contains(ApplicationRole.DataAdmin);

            return this.View(model);
        }
示例#2
0
        public ActionResult Edit(int id, EditViewModel model)
        {
            model.UserProfile = this.UserProfileRepository.Find(id);

            if (this.ModelState.IsValid)
            {
                this.roles.UpdateUserRoles(model.UserProfile.UserName, model.Roles);

                return this.Redirect(model.ReturnUrl);
            }

            return this.View(model);
        }