Ejemplo n.º 1
0
        public IHttpActionResult GetNumberOfClickedLinksForArtist(int artistId, int whenClicked)
        {
            var headers = Request.Headers;

            if (!headers.Contains("token"))
            {
                return(Ok(new { errorCode = "66", message = "unauthorized" }));
            }
            if (headers.Contains("token"))
            {
                var token = headers.GetValues("token").First();
                var jwt   = new JwtToken();
                if (!jwt.VerifyToken(token))
                {
                    return(Ok(new { errorCode = "66", message = "unauthorized" }));
                }
            }
            var service = new VisitService();

            try
            {
                var links = service.GetNumberOfClickedLinksForArtist(artistId, whenClicked);
                return(Ok(links));
            }
            catch (InvalidModelException ex)
            {
                return(BadRequest(ex.Message));
            }
        }