Beispiel #1
0
        public IActionResult AssignAuthor(int newAuthorId, int newsId)
        {
            string authHeader = Request.Headers["Authorization"];

            if (secretKey != authHeader)
            {
                return(Unauthorized());
            }
            ;
            if (!AuthorData.Models.Any(n => n.Id == newAuthorId))
            {
                return(StatusCode(404, $"id: {newAuthorId} Author does not exist, please create it first"));
            }

            _newsService.AssignAuthor(newAuthorId, newsId);
            return(NoContent());
        }