public List<Comment> GetComments() { VideoData.CommentsDataTable DT = db.GetComments(); List<Comment> comments = new List<Comment>(); foreach (var item in DT) { Comment com = new Comment() { CommentId = item.Comment_ID, VideoId = item.Video_ID, EndTime = item.EndTime, StartTime = item.StartTime, Email = item.Email, Name = item.Name, Message = item.Comment}; comments.Add(com); } return comments; }
public async Task<ActionResult> AddComment(int videoId, string email, string name, string message, string startTime, string endTime) { Video vid = new Video(); if (true) try { vid = videos.GetVideoById(videoId); Comment com = new Comment(); com.VideoId = videoId; com.Email = email; com.Message = message; com.Name = name; com.StartTime = startTime; com.EndTime = endTime; comments.AddCommentToDB(com.VideoId, com.Name, com.Email, com.Message, com.StartTime, com.EndTime); ViewBag.Message = "comment added"; } catch (Exception ex) { ViewBag.Message = "ERROR:" + ex.Message.ToString(); } else { ViewBag.Message = "not entered comment."; } return RedirectToAction("Video", "Home", new { videoId = vid.Id }); //return View(Video(vid.Id)); }