Exemplo n.º 1
0
        public ActionResult <List <BlockDTO> > GetBlocksForUser([FromHeader] string key, int userID)
        {
            if (!_authService.Authorize(key))
            {
                return(StatusCode(StatusCodes.Status401Unauthorized, "User authorization failed!"));
            }

            try
            {
                var type = _blockingService.GetBlocksForUser(userID);
                if (type == null)
                {
                    return(NotFound());
                }

                logger.LogInformation("Successfully returned block based on ID");

                return(Ok(type));
            }
            catch (Exception ex)
            {
                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }