Пример #1
0
 public int AddPost(Post post)
 {
     if (post.Id == default(int))
         post.CreatedDate = DateTime.Now;// if post is a new one, set created date is current date
     postRepository.SaveOrUpdate(post);
     return post.Id;
 }
Пример #2
0
 public JsonResult CreatePost(string title, string content)
 {
     Post post = new Post();
     //post.BlogId = 1;// set default, will be changed in the future when authentication + authorization applied
     post.Blog = blogRepository.Blog(1);
     post.Title = title;
     post.PostContent = content;
     int Id = blogRepository.AddPost(post);
     // shorten the PostContent before sending result back to client
     post.PostContent = Common.ShortenString(post.PostContent);
     return Json(post);
 }