Пример #1
0
        public IActionResult Block([FromBody] BlockModel blockModel)
        {
            if (blockModel != null)
            {
                if (!string.IsNullOrEmpty(blockModel.blockFromUsername) && string.IsNullOrEmpty(blockModel.blockToUsername))
                {
                    var blockFrom = _userService.FindByUserName(blockModel.blockFromUsername);
                    var blockTo   = _userService.FindByUserName(blockModel.blockToUsername);

                    if (blockFrom != null && blockTo != null)
                    {
                        _blockService.Block(blockFrom.Id, blockTo.Id, blockModel.isBlocked);
                        return(Ok(new
                        {
                            blockFrom = blockFrom.Username,
                            blockTo = blockTo.Username,
                            blockModel.isBlocked
                        }));
                    }
                    else
                    {
                        _logger.LogError("Blocking person could not be found.");
                        return(BadRequest("Blocking person could not be found."));
                    }
                }
                else
                {
                    _logger.LogError("Credentials are not sufficient.");
                    return(BadRequest("Credentials are not sufficient."));
                }
            }
            _logger.LogError("Credentials needed.");
            return(BadRequest("Credentials needed."));
        }
Пример #2
0
        public async Task <IActionResult> Block(string Blocked, [FromHeader] string Authorization)
        {
            var SourceId = _authService.Authorize(Authorization);

            await _blockService.Block(SourceId, Blocked);

            return(Ok());
        }