public ActionResult <BlockDto> GetBlockById([FromHeader] string key, Guid ID)
        {
            if (!authHelper1.AuthUser(key))
            {
                logger.LogWarning("Autorizacija korisnika neuspesna");
                return(Unauthorized());
            }
            try
            {
                BlockDto one = blockingService1.GetBlockById(ID);
                if (one == null)
                {
                    logger.LogWarning("Ne postoji nijedno blokiranje korisnika");
                    return(NotFound());
                }

                logger.LogInformation("Uspesno vracen blokiranje sa prosledjenim ID-em");
                return(Ok(one));
            }
            catch (Exception e)
            {
                logger.LogError(e.Message);
                return(StatusCode(StatusCodes.Status500InternalServerError, e.Message));
            }
        }
Exemplo n.º 2
0
        public ActionResult GetBlockByID([FromHeader] string key, Guid BlockID)
        {
            if (!_authService.Authorize(key))
            {
                return(StatusCode(StatusCodes.Status401Unauthorized, "User authorization failed!"));
            }

            try
            {
                var type = _blockingService.GetBlockById(BlockID);
                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));
            }
        }