public virtual async Task <ActionResult> Delete(int id) { _postService.Delete(id); await _unitOfWork.SaveAllChangesAsync(); LuceneIndex.ClearLucenePostIndexRecord(id); return(Json("ok")); }
public virtual async Task <ActionResult> Add(AddPostViewModel postModel) { if (!ModelState.IsValid) { ViewData["CategoriesSelectList"] = new SelectList(await _postCategoryService.GetAll(), "Id", "Name"); return(View(postModel)); } var post = new DomainClasses.Post { PostedByUserId = User.Identity.GetUserId <int>() }; _mappingEngine.Map(postModel, post); if (postModel.Id.HasValue) { _postService.Edit(post); TempData["message"] = "پست مورد نظر با موفقیت ویرایش شد"; } else { _postService.Add(post); TempData["message"] = "پست جدید با موفقیت در سیستم ثبت شد"; } await _unitOfWork.SaveAllChangesAsync(); if (postModel.Id.HasValue) { LuceneIndex.ClearLucenePostIndexRecord(postModel.Id.Value); } LuceneIndex.AddUpdateLuceneIndex(new LuceneSearchModel { PostId = post.Id, Title = post.Title, Image = post.Image, Description = post.Body.RemoveHtmlTags(), Category = await _postCategoryService.GetCategoryName(postModel.CategoryId.Value), SlugUrl = post.SlugUrl }); return(RedirectToAction(MVC.Post.Admin.ActionNames.Index)); }
public override async Task RunAsync() { if (this.IsShuttingDown || this.Pause) { return; } LuceneIndex.ClearLuceneIndex(); var productService = IoC.Container.GetInstance <IProductService>(); var postService = IoC.Container.GetInstance <IPostService>(); foreach (var product in await productService.GetAllForLuceneIndex()) { LuceneIndex.ClearLuceneIndexRecord(product.Id); LuceneIndex.AddUpdateLuceneIndex(new LuceneSearchModel { ProductId = product.Id, Title = product.Title, Image = product.Image, Description = product.Description.RemoveHtmlTags(), Category = "کالاها", SlugUrl = product.SlugUrl, Price = product.Price.ToString(CultureInfo.InvariantCulture), ProductStatus = product.ProductStatus.ToString() }); } foreach (var post in await postService.GetAllForLuceneIndex()) { LuceneIndex.ClearLucenePostIndexRecord(post.Id); LuceneIndex.AddUpdateLuceneIndex(new LuceneSearchModel { PostId = post.Id, Title = post.Title, Image = post.Image, Description = post.Description.RemoveHtmlTags(), Category = post.Category, SlugUrl = post.SlugUrl }); } }
public virtual async Task <ActionResult> ReIndex() { LuceneIndex.ClearLuceneIndex(); var productService = IoC.Container.GetInstance <IProductService>(); var postService = IoC.Container.GetInstance <IPostService>(); foreach (var product in await productService.GetAllForLuceneIndex()) { LuceneIndex.ClearLuceneIndexRecord(product.Id); LuceneIndex.AddUpdateLuceneIndex(new LuceneSearchModel { ProductId = product.Id, Title = product.Title, Image = product.Image, Description = product.Description.RemoveHtmlTags(), Category = "کالاها", SlugUrl = product.SlugUrl, Price = product.Price.ToString(CultureInfo.InvariantCulture), ProductStatus = product.ProductStatus.ToString() }); } foreach (var post in await postService.GetAllForLuceneIndex()) { LuceneIndex.ClearLucenePostIndexRecord(post.Id); LuceneIndex.AddUpdateLuceneIndex(new LuceneSearchModel { PostId = post.Id, Title = post.Title, Image = post.Image, Description = post.Description.RemoveHtmlTags(), Category = post.Category, SlugUrl = post.SlugUrl }); } return(Content("ReIndexing Complete.")); }