Пример #1
0
        public CommentListResponse GetCommentForMovie(int id)
        {
            Dictionary <string, string[]> errors = new Dictionary <string, string[]>();

            Movie movie = _context.Movies.FirstOrDefault(m => m.MovieId == id);

            if (movie == null)
            {
                errors.Add("Film", new[] { "Podany film nie istnieje" });
                return(new CommentListResponse(errors));
            }

            var comments = _context.Comments.Where(m => m.MovieId == id).ToList();

            if (comments == null)
            {
                errors.Add("Komentarze", new[] { "Podany film nie posiada komentarzy " });
                return(new CommentListResponse(errors));
            }
            CommentListReturnDto commentListReturn = new CommentListReturnDto
            {
                CommentList = comments
            };

            return(new CommentListResponse(commentListReturn));
        }
Пример #2
0
 public CommentListResponse(CommentListReturnDto comments)
     : this(true, new Dictionary <string, string[]>(), comments)
 {
 }
Пример #3
0
 private CommentListResponse(bool success, Dictionary <string, string[]> message, CommentListReturnDto comments)
     : base(success, message)
 {
     Comments = comments;
 }