示例#1
0
 /// <summary>
 /// Initializes <see cref="VideoController"/>
 /// </summary>
 /// <param name="videoService"></param>
 /// <param name="videoCommentService"></param>
 /// <param name="mapper"></param>
 /// <param name="currentUserProvider"></param>
 public VideoController(VideoService videoService, VideoCommentService videoCommentService,
                        IMapper mapper, ICurrentUserProvider currentUserProvider)
 {
     this.VideoService        = videoService;
     this.Mapper              = mapper;
     this.CurrentUserProvider = currentUserProvider;
     this.VideoCommentService = videoCommentService;
 }
示例#2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";

            if (context.Request["act"].ToString() == "get")  //获取评论
            {
                int videoId = Convert.ToInt32(context.Request.QueryString["videoId"]);
                List <VideoComment>  videoComments = VideoCommentService.GetVideoComments(videoId);
                IsoDateTimeConverter timeConverter = new IsoDateTimeConverter();
                timeConverter.DateTimeFormat = "yyyy-MM-dd HH:mm";
                string jsonComments = JsonConvert.SerializeObject(videoComments, Formatting.Indented, timeConverter);
                context.Response.Write(jsonComments);
            }
            else //添加评论
            {
                int          videoId     = Convert.ToInt32(context.Request["videoId"]);
                string       content     = context.Request["commentContent"].ToString();
                string       commentUser = context.Session["CurrentUser"].ToString();
                DateTime     commentTime = DateTime.Now;
                VideoComment comment     = new VideoComment()
                {
                    VideoId     = videoId,
                    CommentUser = commentUser,
                    CommentTime = commentTime,
                    Content     = content
                };
                if (VideoCommentService.Create(comment))
                {
                    context.Response.Write("评论成功");
                }
                else
                {
                    context.Response.Write("评论失败");
                }
            }
        }
示例#3
0
 public List <VideoComment> Comments(string video)
 {
     return(VideoCommentService.GetByMainId(video));
 }
 /// <summary>
 /// Initializes <see cref="VideoCommentController"/>
 /// </summary>
 /// <param name="videoCommentService"></param>
 /// <param name="mapper"></param>
 public VideoCommentController(VideoCommentService videoCommentService,
                               IMapper mapper)
 {
     this.VideoCommentService = videoCommentService;
     this.Mapper = mapper;
 }