public PostViewModel(ForumService.PostModel model) { this.Id = model.Id; this.Poster = model.Poster; this.Title = model.Title; this.PostType = model.PostType; this.Content = model.Content; this.PublishDate = model.PublishDate; this.NoComments = model.NoComments > 0; }
public void SetPostMsgSets(XmlNodeList nodeList) { foreach (XmlElement node in nodeList) { var model = new ForumService.PostModel(); model.Poster = node.SelectSingleNode("poster")?.InnerText; model.Title = node.SelectSingleNode("title")?.InnerText; model.PostType = node.SelectSingleNode("type")?.InnerText; model.Content = node.SelectSingleNode("content")?.InnerText; model.PublishDate = Convert.ToDateTime(node.SelectSingleNode("date")?.InnerText); model.NoComments = Convert.ToInt32(node.SelectSingleNode("NoComments")?.InnerText); forumClient.AddPost(model); } }
public ActionResult AddPost(PostViewModel model) { if (!Authority()) { return(_authorityResult); } var post = new ForumService.PostModel() { Poster = Request.Cookies.Get(DefaultAuthenticationTypes.ApplicationCookie).Value, Content = model.Content, NoComments = Convert.ToInt32(model.NoComments), PostType = model.PostType, PublishDate = DateTime.Now, Title = model.Title }; forumClient.AddPost(post); return(RedirectToAction("Index")); }
public JsonResult PostEdit(PostViewModel model) { var ret = new PostOperatorRep() { Status = 0, Message = @"更新成功!" }; var post = new ForumService.PostModel() { Id = model.Id, Content = model.Content, NoComments = Convert.ToInt32(model.NoComments), PostType = model.PostType, Title = model.Title }; forumClient.UpdatePost(post); return(Json(ret)); }