public static void CreateIndexChapter(Chapter entity, string IndexPath) { var document = new Document(); document.Add(new Field("CreativeId", entity.CreativeId.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED)); document.Add(new Field("Title", entity.Title, Field.Store.YES, Field.Index.ANALYZED)); if (!string.IsNullOrEmpty(entity.Body)) { document.Add(new Field("About", entity.Body, Field.Store.YES, Field.Index.ANALYZED)); } Directory directory = FSDirectory.Open(new DirectoryInfo(IndexPath)); Analyzer analyzer = new StandardAnalyzer(Version.LUCENE_30); var writer = new IndexWriter(directory, analyzer, true, IndexWriter.MaxFieldLength.LIMITED); writer.AddDocument(document); writer.Optimize(); writer.Dispose(); }
public ActionResult Add(Chapter chapter, int id, string numb, string count) { if (ModelState.IsValid) { var numbInt = Convert.ToInt32(numb); var countInt = Convert.ToInt32(count); if (numbInt <= countInt) { _creativesRepository.ChangeOrderByChapter(numbInt, countInt, id); } chapter.NumbChapter = numbInt; chapter.CreativeId = id; _creativesRepository.AddChapter(chapter); string IndexPath = Server.MapPath("~/App_Data"); CreativeIndexDefinition.CreateIndexChapter(chapter, IndexPath); return RedirectToAction("Find", "Creative", new { id }); } return View(); }
public void AddChapter(Chapter chapter) { _db.Chapter.Add(chapter); _db.SaveChanges(); }
public void ModifiedChapter(Chapter chapter) { var chapter1 = GetChapterById(chapter.ChapterId); _db.Entry(chapter1).CurrentValues.SetValues(chapter); _db.SaveChanges(); }
public ActionResult Edit(Chapter chapter) { if (ModelState.IsValid) { _creativesRepository.ModifiedChapter(chapter); return RedirectToAction("Find", "Creative", new { id = chapter.CreativeId }); } return RedirectToAction("Edit"); }