Example #1
0
        public virtual ActionResult Delete(int id)
        {
            _postService.RemovePostById(id);
            _uow.SaveChanges();

            #region Remove lucene search index
            new LucenePostSearch(_postService);
            LucenePostSearch.ClearLuceneIndexRecord(id);

            #endregion

            return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert {
                Message = "دانشنامه مورد نظر با موفقیت حذف شد"
            }));
        }
Example #2
0
        public virtual ActionResult EditPost(EditPostModel postModel)
        {
            if (!ModelState.IsValid)
            {
                return(PartialView(MVC.Admin.Shared.Views._ValidationSummery));
            }

            postModel.ModifiedDate = DateAndTime.GetDateTime();
            postModel.EditedByUser = _userService.GetUserByUserName(User.Identity.Name);
            postModel.Labels       = _labelService.GetLabelsById(postModel.LabelsId);

            // _downloadLinkService.RemoveByPostId(postModel.PostId);

            _uow.SaveChanges();

            //if (!string.IsNullOrEmpty(postModel.Links.DownloadLink1.Link))
            //{
            //    postModel.DownloadLinks.Add(postModel.Links.DownloadLink1);
            //}
            //if (!string.IsNullOrEmpty(postModel.Links.DownloadLink2.Link))
            //{
            //    postModel.DownloadLinks.Add(postModel.Links.DownloadLink2);
            //}
            //if (!string.IsNullOrEmpty(postModel.Links.DownloadLink3.Link))
            //{
            //    postModel.DownloadLinks.Add(postModel.Links.DownloadLink3);
            //}
            //if (!string.IsNullOrEmpty(postModel.Links.DownloadLink4.Link))
            //{
            //    postModel.DownloadLinks.Add(postModel.Links.DownloadLink4);
            //}

            //postModel.Book.Description = postModel.Book.Description.ToSafeHtml();
            postModel.PostBody = postModel.PostBody.ToSafeHtml();

            UpdatePostStatus status = _postService.UpdatePost(postModel);

            if (status == UpdatePostStatus.Successfull)
            {
                _uow.SaveChanges();

                #region Indexing updated Post by Lucene.NET
                new LucenePostSearch(_postService);
                //Index updated book lucene.NET
                LucenePostSearch.ClearLuceneIndexRecord(postModel.PostId);
                Post currentPost = _postService.Find(postModel.PostId);
                LucenePostSearch.AddUpdateLuceneIndex(new LucenePostModel
                {
                    Labels      = string.Join(" , ", currentPost.Labels.Select(l => l.Name).ToArray()),
                    Body        = HtmlUtility.RemoveHtmlTags(currentPost.Body),
                    Description = currentPost.Description,
                    Keywords    = currentPost.Keyword,
                    PostId      = currentPost.Id,
                    Title       = currentPost.Title
                });

                #endregion

                return(PartialView(MVC.Admin.Shared.Views._Alert,
                                   new Alert {
                    Message = "اطلاعات با موفقیت به روز رسانی شد", Mode = AlertMode.Success
                }));
            }

            return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert
            {
                Message = "خطا در به روز رسانی اطلاعات",
                Mode = AlertMode.Error
            }));
        }