public ActionResult Add(PostViewModel postModel) { if (ModelState.IsValid) { var tags = _tagRepository.GetTagEntities(postModel.Tags.Split(',').ToList()); _tagRepository.AddTags(tags); var postEntity = postModel.ToPostEntity(_tagRepository); postEntity.PostAddedDate = DateTime.Now; postEntity.PostEditedDate = postEntity.PostAddedDate; postEntity.OwnerUserID = GetUserId(); if (string.IsNullOrEmpty(postEntity.PostUrl)) { postEntity.PostUrl = UniqueUrlHelper.FindUniqueUrl(_postRepository, postEntity.PostTitle, ItemEntryType); } var biltyPostUrl = BitlyUrlService.GetBiltyPostUrl(SettingsRepository, postEntity.PostUrl); if (biltyPostUrl != null) { postEntity.BitlyUrl = biltyPostUrl; postEntity.BitlySourceUrl = postEntity.PostUrl; } var postId = _postRepository.AddPost(postEntity); if (postId > 0) { return(RedirectToAction("Edit", new { postID = postId, newlyAdded = true })); } } postModel.Title = SettingsRepository.BlogName; postModel.SharingEnabled = SettingsRepository.BlogSocialSharing; return(View(postModel)); }
public ActionResult Edit(PostViewModel postModel) { if (ModelState.IsValid) { var tags = _tagRepository.GetTagEntities(postModel.Tags.Split(',').ToList()); _tagRepository.AddTags(tags); var postEntity = postModel.ToPostEntity(_tagRepository); postEntity.PostEditedDate = DateTime.Now; if (string.IsNullOrEmpty(postEntity.PostUrl)) { postEntity.PostUrl = UniqueUrlHelper.FindUniqueUrl(_postRepository, postEntity.PostTitle, ItemEntryType, postEntity.PostID); } if (postEntity.PostUrl != postEntity.BitlySourceUrl) { var biltyPostUrl = BitlyUrlService.GetBiltyPostUrl(SettingsRepository, postEntity.PostUrl); if (biltyPostUrl != null) { postEntity.BitlyUrl = biltyPostUrl; postEntity.BitlySourceUrl = postEntity.PostUrl; } } _postRepository.UpdatePost(postEntity); postModel.UpdateStatus = true; postModel.IsNewPostOrPage = false; } postModel.Title = SettingsRepository.BlogName; postModel.SharingEnabled = SettingsRepository.BlogSocialSharing; return(View(postModel)); }
public ActionResult Add(PostViewModel postModel) { if (ModelState.IsValid) { var postEntity = postModel.ToPostEntity(_tagRepository); postEntity.PostAddedDate = DateTime.Now; postEntity.PostEditedDate = postEntity.PostAddedDate; postEntity.OwnerUserID = GetUserId(); if (string.IsNullOrEmpty(postEntity.PostUrl)) { postEntity.PostUrl = UniqueUrlHelper.FindUniqueUrl(_postRepository, postEntity.PostTitle, ItemEntryType); } var pageID = _postRepository.AddPost(postEntity); if (pageID > 0) { return(RedirectToAction("Edit", new { postID = pageID, newlyAdded = true })); } } postModel.Title = SettingsRepository.BlogName; postModel.SharingEnabled = SettingsRepository.BlogSocialSharing; return(View(postModel)); }
private void SavePostInternal(PostViewModel postModel) { var tags = _tagRepository.GetTagEntities(postModel.Tags.Split(',').ToList()); _tagRepository.AddTags(tags); var postEntity = postModel.ToPostEntity(_tagRepository); postEntity.PostEditedDate = DateTime.Now; if (string.IsNullOrEmpty(postEntity.PostUrl)) { postEntity.PostUrl = UniqueUrlHelper.FindUniqueUrl(_postRepository, postEntity.PostTitle, ItemEntryType, postEntity.PostID); } if (postEntity.PostUrl != postEntity.BitlySourceUrl) { var biltyPostUrl = BitlyUrlService.GetBiltyPostUrl(SettingsRepository, postEntity.PostUrl); if (biltyPostUrl != null) { postEntity.BitlyUrl = biltyPostUrl; postEntity.BitlySourceUrl = postEntity.PostUrl; } } _postRepository.UpdatePost(postEntity); }
public ActionResult Edit(PostViewModel postModel) { if (ModelState.IsValid) { var postEntity = postModel.ToPostEntity(_tagRepository); postEntity.PostEditedDate = DateTime.Now; if (string.IsNullOrEmpty(postEntity.PostUrl)) { postEntity.PostUrl = UniqueUrlHelper.FindUniqueUrl(_postRepository, postEntity.PostTitle, ItemEntryType, postEntity.PostID); } _postRepository.UpdatePost(postEntity); postModel.UpdateStatus = true; postModel.IsNewPostOrPage = false; } postModel.Title = SettingsRepository.BlogName; postModel.SharingEnabled = SettingsRepository.BlogSocialSharing; return(View(postModel)); }