Exemplo n.º 1
0
        public ActionResult <BlockDTO> Block([FromHeader] string key, [FromBody] BlockCreationDTO block, int blockerID, int blockedID)
        {
            if (!_authService.Authorize(key))
            {
                return(StatusCode(StatusCodes.Status401Unauthorized, "User authorization failed!"));
            }

            try
            {
                var createdType = _blockingService.Block(block, blockerID, blockedID);


                //string location = linkGenerator.GetPathByAction("GetBlockByID", "Block", new { BlockID = createdType.BlockID });

                return(StatusCode(StatusCodes.Status201Created, "You have successfully blocked user"));
            }
            catch (Exception ex)
            {
                logger.LogError(ex, "Error creating new block: " + ex.Message);

                return(StatusCode(StatusCodes.Status500InternalServerError, ex.Message));
            }
        }