public virtual ActionResult Delete(int id) { _postService.RemovePostById(id); _uow.SaveChanges(); #region Remove lucene search index LuceneBookSearch.ClearLuceneIndexRecord(id); #endregion return(PartialView(MVC.Admin.Shared.Views._Alert, new Alert { Message = "پست مورد نظر با موفقیت حذف شد" })); }
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 book by Lucene.NET //Index updated book lucene.NET LuceneBookSearch.ClearLuceneIndexRecord(postModel.PostId); Post currentPost = _postService.Find(postModel.PostId); LuceneBookSearch.AddUpdateLuceneIndex(new LuceneBookModel { Author = currentPost.Book.Author, Description = HtmlUtility.RemoveHtmlTags(currentPost.Book.Description), ISBN = currentPost.Book.ISBN, Name = currentPost.Book.Name, PostId = currentPost.Id, Publisher = currentPost.Book.Publisher, 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 })); }