コード例 #1
0
        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);
        }
コード例 #2
0
ファイル: PageController.cs プロジェクト: LByron/BS
        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);
        }
コード例 #3
0
ファイル: PostController.cs プロジェクト: rinckd/sblog.net
        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);
        }
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: PageController.cs プロジェクト: LByron/BS
        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);
        }