예제 #1
0
        public IActionResult InsertComment(CommentDTO commentDto)
        {
            ResponseCreated <CommentDTO> responseSingleObject = new ResponseCreated <CommentDTO>()
            {
                Status      = StatusCodes.Status500InternalServerError,
                Errors      = null,
                Message     = null,
                Succeded    = false,
                Value       = null,
                LocationUri = null
            };

            try
            {
                int idCreated = _bllManager.InsertComment(commentDto);
                responseSingleObject.Status   = StatusCodes.Status201Created;
                responseSingleObject.Succeded = true;
                string baseUrl     = $"{HttpContext.Request.Scheme}://{HttpContext.Request.Host.ToUriComponent()}";
                string locationUri = baseUrl + "/" + ApiRoute.Comments.GetCommentFromId.Replace("{id}", idCreated.ToString());
            }
            catch (Exception e)
            {
                responseSingleObject.Errors =
                    "InsertComment() EXCEPTION : " + e.ToString();
            }

            return(StatusCode(responseSingleObject.Status, responseSingleObject));
        }
        public void testInsertComment()
        {
            Console.WriteLine("insert comment...");
            _bllManager.InsertComment(_comment);
            Console.WriteLine("insert comment ok : affichage à partir de la lecture de la bd :");

            FullFilmDTO film      = _bllManager.GetFullFilmDetailsByIdFilm(_comment.Film.Id);
            int         idComment = 0;

            foreach (CommentDTO filmComment in film.Comments)
            {
                idComment = filmComment.Id;
            }

            Console.WriteLine("Film : \n" + film.ToStringAll());

            _comment = _bllManager.getCommentFromId(idComment);
            Console.WriteLine("Comment : \n" + _comment.ToStringWithFilm());

            Assert.Pass();
        }