Beispiel #1
0
 public EmptyResult AddEmptyChapter(int id)
 {
     Chapter newChapter = new Chapter
     {
         Name = "Chapter" + chapterRepository.FindAllBy(m => m.CreativeId == id).Count(),
         Content = "",
         Position = chapterRepository.FindAllBy(m => m.CreativeId == id).Count() + 1,
         CreativeId = id
     };
     chapterRepository.Create(newChapter);
     LuceneChapterSearch.AddUpdateLuceneIndex(newChapter);
     chapterRepository.Save();
     return null;
 }
Beispiel #2
0
 public static void AddUpdateLuceneIndex(Chapter sampleData)
 {
     AddUpdateLuceneIndex(new List<Chapter> { sampleData });
 }
Beispiel #3
0
        private static void addToLuceneIndex(Chapter Data, IndexWriter writer)
        {
            var searchQuery = new TermQuery(new Term("Id", Data.Id.ToString()));
            writer.DeleteDocuments(searchQuery);

            var doc = new Document();

            doc.Add(new Field("Id", Data.Id.ToString(), Field.Store.YES, Field.Index.NOT_ANALYZED));
            doc.Add(new Field("Name", Data.Name, Field.Store.YES, Field.Index.ANALYZED));
            doc.Add(new Field("Content", Data.Content, Field.Store.YES, Field.Index.ANALYZED));

            writer.AddDocument(doc);
        }
Beispiel #4
0
 public ActionResult UploadCreative(UploadedCreative uploadedCreative)
 {
     Creative newCreative = new Creative
     {
         Description = uploadedCreative.Description,
         Votes = 0,
         Name = uploadedCreative.Name,
         Tags = uploadedCreative.Tags.GetTagsFromText(),
         User = User.Identity.Name
     };
     creativeRepository.Create(newCreative);
     creativeRepository.Save();
     var user = userRepository.FindFirstBy(m => m.Login == User.Identity.Name);
     user.CreativeCount++;
     userRepository.EditCreativeCount(user);
     LuceneCreativeSearch.AddUpdateLuceneIndex(newCreative);
     foreach (var tag in newCreative.Tags)
     {
         tagRepository.Create(tag);
         LuceneTagSearch.AddUpdateLuceneIndex(tag);
     }
     tagRepository.Save();
     Chapter newChapter = new Chapter
     {
         Name = "Chapter 0",
         Content = "",
         CreativeId = newCreative.Id,
         Position = 0
     };
     chapterRepository.Create(newChapter);
     chapterRepository.Save();
     LuceneChapterSearch.AddUpdateLuceneIndex(newChapter);
     newCreative = creativeRepository.FindFirstBy(n => n.Name == newCreative.Name && n.User == newCreative.User);
     var raki = "EditCreative"+"/" + newCreative.Id.ToString();
     return RedirectToAction(raki);
 }
Beispiel #5
0
 public ActionResult UploadChapter(Chapter newChapter)
 {
     chapterRepository.Create(newChapter);
     chapterRepository.Save();
     LuceneChapterSearch.AddUpdateLuceneIndex(newChapter);
     return RedirectToAction("ChapterEdit", "Creative");
 }