public void SetAuthorization(UserAuthorizationInput input) { var user = _userRepository.GetUserAndRoles().Single(r => r.Id == input.Id); user.Roles = new List <Core.System.Role>(); input.Roles.ForEach(r => { user.Roles.Add(_roleRepository.Get(r.Id)); }); }
public ActionResult Authorization(int id, string[] roles) { if (ModelState.IsValid) { var input = new UserAuthorizationInput { Id = id, Roles = new List <Role>() }; foreach (var role in roles) { input.Roles.Add(new Role { Id = Convert.ToInt32(role) }); } _userService.SetAuthorization(input); ViewBag.Success = "success"; } return(View(_roleService.GetAll(new RoleDto()))); }