Пример #1
0
        public IActionResult Delete(int id)
        {
            string accessToken = HttpContext.Request.Headers["Authorization"];
            int    bearerId    = _userService.GetId(accessToken);

            if (!Entities.User.IsOnline(bearerId))
            {
                return(StatusCode(StatusCodes.Status401Unauthorized, new { message = "User not logged in" }));
            }
            Comment comment = GameForum.Comment.Select(id);

            if (bearerId != comment.fk_user)
            {
                return(StatusCode(StatusCodes.Status401Unauthorized, new { message = "Incorrect id" }));
            }
            if (Comment.CheckExists(id))
            {
                Comment.Delete(id);
                return(StatusCode(StatusCodes.Status200OK));
            }
            else
            {
                return(StatusCode(StatusCodes.Status404NotFound));
            }
        }