コード例 #1
0
        public virtual ActionResult EditUsersInstitutions(string userName)
        {
            var user = WebSecurity.GetUser(userName);
            var viewModel = new UserInstitutionsViewModel();
            viewModel.InstitutionsList = this._institutionManager.GetAll().Select(x => new SelectListItem(){Text = x.Name, Value = x.Id.ToString()});
            viewModel.Institutions =
                this._institutionManager.GetInstitutesForUser((Guid) user.ProviderUserKey)
                    .Select(InstitutionMapper.ToViewModelExp);

            return PartialView(MVC.AdminUser.Views.Partial.UserInstitutions, viewModel);
        }
コード例 #2
0
        public virtual ActionResult EditUsersInstitutions(UserInstitutionsViewModel viewModel)
        {
            if (ModelState.IsValid && Request.IsAjaxRequest())
            {
                var user = WebSecurity.GetUser(viewModel.Username);
                this._institutionManager.AddUserToInstitutes(viewModel.Institutions.Select(x => x.Id), (Guid)user.ProviderUserKey);

                return this.Json(new { success = true });
            }

            return this.Json(new { success = false, errors = this.ModelErrorString() });
        }