public void AddPost(Post post) { // Parse Tags into separate hash tags if (post.Tags != null) { var hashtags = post.Tags.Replace("#", "").Split(','); foreach (var hashtag in hashtags) { if (hashtag != "") { var p = new HashTag(); p.ActualHashTag = hashtag; post.HashTags.Add(p); } } } var create = new Create(); var postID = create.AddPost(post); // Check if post add was successful and returned the new postID if (postID != null && post.HashTags.Count() != 0) { foreach (var tag in post.HashTags) { create.AddTag((int) postID, tag); } } }
public ActionResult EditPost(Post post) { var update = new FITlosophiOperations(); update.EditPost(post); return View("ManagePosts"); }
public void PublishPost(int PostID) { var post = new Post(); post.PostID = PostID; var update = new FITlosophiOperations(); update.PublishPost(post); }
public void AddPost() { Post newpost = new Post(); newpost.CategoryID = 1; newpost.UserID = "b75da91b-e39a-42ce-b2f0-4834eda139e1"; newpost.Title = "My Test Post for data layer"; newpost.CoverImgURL = "http://localhost:54909/Content/img/golf.jpg"; newpost.Body = "Test Body"; var result = Createrepo.AddPost(newpost); var posts = Readrepo.GetAllPostSummaries(); var post = posts.FirstOrDefault(p => p.PostID == result); Assert.AreEqual(post.PostID, result); }
public void EditPost(Post post) { using (SqlConnection cn = new SqlConnection(Settings.ConnectionString)) { var p = new DynamicParameters(); try { p.Add("PostID", post.PostID); p.Add("CategoryID", post.CategoryID); p.Add("UserID", post.UserID); p.Add("Title", post.Title); p.Add("CoverImgURL", post.CoverImgURL); p.Add("Body", post.Body); p.Add("HasSchedule", post.HasSchedule); p.Add("StartDate", post.StartDate); p.Add("EndDate", post.EndDate); cn.Execute("EditPost", p, commandType: CommandType.StoredProcedure); } //catch (Exception e) //{ // // Write failure to database // var ep = new DynamicParameters(); // ep.Add("ExceptionType", e.GetType()); // ep.Add("ExceptionMessage", e.Message); // cn.Execute("AddError", ep, commandType: CommandType.StoredProcedure); //} finally { cn.Close(); } } }
public void PublishPostWithSchedule(Post Post) { var update = new FITlosophiOperations(); update.PublishPost(Post); }
public void Post(Post post) { var create = new FITlosophiOperations(); create.AddPost(post); }
public void EditPost(Post Post) { var update = new FITlosophiOperations(); update.EditPost(Post); }
public void PublishPost() { Post post = new Post(); post.PostID = 4; post.HasSchedule = false; post.StartDate = null; post.EndDate = null; Updaterepo.PublishPost(post); var newpost = Readrepo.GetAllPostSummaries(); Assert.AreEqual(false, newpost.Where(m=> m.PostID == 4).FirstOrDefault(x => x.HasSchedule == false ).HasSchedule); }
public void EditPost() { Post newPost = new Post(); newPost.PostID = 15; newPost.CategoryID = 3; newPost.UserID = "b75da91b-e39a-42ce-b2f0-4834eda139e1"; newPost.Title = "Test post 44"; newPost.CoverImgURL = "http://localhost:54909/Content/img/eating.jpg"; newPost.Body = "Hi"; newPost.DateCreated = DateTime.Parse("12/07/2015"); newPost.HasSchedule = false; newPost.IsPublished = false; newPost.IsActive = false; Updaterepo.EditPost(newPost); var newbody = Readrepo.GetPostByID(15); Assert.AreEqual("Hi", newbody.Body); }
public ActionResult PostPost(Post post) { var create = new FITlosophiOperations(); create.AddPost(post); if (User.IsInRole("Admin")) { return View("ManagePosts"); } return RedirectToAction("Index", "Home"); }
public void EditPost(Post post) { // Overwrite post with edited data var update = new Update(); update.EditPost(post); // Delete all hashtags associated with post from PostsXTags table var delete = new Delete(); delete.DeleteAllTagsByPostID(post.PostID); // Split up tags string from UI into individual hashtags. Then remove all # symbols. // Afterwards, only tags that contain characters are added to the HashTags list. if (post.Tags != null) { var hashtags = post.Tags.Replace("#", "").Split(','); foreach (var hashtag in hashtags) { if (hashtag != "") { var p = new HashTag(); p.ActualHashTag = hashtag; post.HashTags.Add(p); } } } // Iterate: Check if hashtag is in Tags table. If not, create a new record in that table // before creating a new record in PostsXTags. Else, just create new record in PostsXTags. if (post.HashTags.Count() != 0) { var create = new Create(); foreach (var tag in post.HashTags) { create.AddTag((int)post.PostID, tag); } } }
public void PublishPost(Post post) { var update = new Update(); update.PublishPost(post); }