public IActionResult AddExisting([FromRoute] string groupId, [FromBody] AddExistingUserRequest addExistingUserRequest) { Core.Models.Result.Result result = _groupUserService.AddExisting(groupId, addExistingUserRequest); if (result.Failure) { ModelState.AddErrors(result); return(BadRequest(ModelState)); } return(Ok(new EmptyResult())); }
public Result AddExisting(string groupId, AddExistingUserRequest addExistingUserRequest) { ValidationResult validationResult = _addExistingUserValidator.Validate(addExistingUserRequest); if (!validationResult.IsValid) { _logger.LogWarning($"Invalid AddExistingUserRequest model"); return(Result.Fail(validationResult.Errors)); } return(AddUserToGroup(addExistingUserRequest.UserId, groupId, addExistingUserRequest.GroupRoleId)); }
public Core.Models.Result.Result AddExisting(string groupId, AddExistingUserRequest addExistingUserRequest) { ValidationResult validationResult = _addExistingUserValidator.Validate(addExistingUserRequest); if (!validationResult.IsValid) { _logger.LogWarning($"Invalid AddExistingUserRequest model"); return(Core.Models.Result.Result.Fail(validationResult.Errors)); } Task <Result <GroupUserEntity> > addUserToGroup = AddUserToGroupWithValidation(addExistingUserRequest.UserId, groupId, addExistingUserRequest.GroupRoleId); Task <Result <GroupUserEntity>[]> taskResult = Task.WhenAll(addUserToGroup); Result result = taskResult.Result.Single(); return(result.ToOldResult()); }