예제 #1
0
        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()));
        }
예제 #2
0
        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));
        }
예제 #3
0
        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());
        }