/// <summary> /// Gets the comment. /// </summary> /// <param name="user">The user.</param> /// <param name="saveView">The save view.</param> /// <param name="media">The media.</param> /// <returns></returns> private Comment GetComment(IId<int> user, CommentSaveView saveView, IMediaFiles media) { return new Comment { Text = saveView.Comments, MediaId = media.MediaId, CommentStatus = CommentStatus.Approved, Email = saveView.Email, Name = saveView.Name, SiteUrl = saveView.Website ?? string.Empty, CommentDate = DateTime.Now, Ip = HttpContext.Request.UserHostAddress, UserAgent = HttpContext.Request.UserAgent, UserId = user.Id }; }
public ActionResult Leave(string id, CommentSaveView saveView) { int photoId = Convert.ToInt32(id); Media media = _mediaRepository.RetrieveByPrimaryKeyAndUserId(photoId, Owner.Id); Comment comment = GetComment(Owner, saveView, media); _commentRepository.Save(comment); IDictionary<string, string> crumb = CommentCrumb(media, photoId); List<Comment> comments = _commentRepository.RetrieveAllByMediaId(media.MediaId); CommentsView commentsView = ModelFactory<CommentsView>(new { media, comments }); commentsView.UIMessage = "Thank you for commenting."; return View(commentsView, crumb); }