GetCommentsByUser() public method

public GetCommentsByUser ( ) : IList
return IList
Beispiel #1
0
        public ActionResult CommentsForUser()
        {
            if (WebSecurity.CurrentUserId <= 0)
                return Json(new []{ "error",  "you must be logged in to use this feature"}, JsonRequestBehavior.AllowGet);

            var db = new PhotoGalleryRepository();
            IList<dynamic> comments = db.GetCommentsByUser();

            var jsonComments = comments.Select(comment => new jsonComment
            {
                id = comment.Id,
                date = comment.CommentDate.ToString(),
                text = comment.CommentText
            }).ToList();

            return Json(jsonComments, JsonRequestBehavior.AllowGet);
        }