public static void CreateIndexCreative(Creative 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.About))
            {
                document.Add(new Field("About", entity.About, 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);

              try
              {

            writer.AddDocument(document);

            writer.Optimize();

            writer.Dispose();
              }
             finally
              {

              writer.Dispose();
              }
        }
Example #2
0
 public static void Add(Creative creative)
 {
     using (EntityContext _db = new EntityContext())
     {
         _db.Creative.Add(creative);
         _db.SaveChanges();
     }
 }
Example #3
0
        public ActionResult Edit(Creative creative, int id)
        {
            if (ModelState.IsValid)
            {
              _creativesRepository.ModifiedCreatives(creative);
              _creativesRepository.AddTag(creative.Creativeid);
              return RedirectToAction("Find", new { id });

            }
            return View();
        }
Example #4
0
 public ActionResult Create(Creative creative)
 {
     if (ModelState.IsValid)
     {
         var user = _creativesRepository.GetUserByName(User.Identity.Name);
         creative.DateCreate = DateTime.Now;
         creative.UserId = user.UserId;
         AddCreative.Add(creative);
         string IndexPath = Server.MapPath("~/App_Data");
         CreativeIndexDefinition.CreateIndexCreative(creative, IndexPath);
         if (creative.Tagon != null)
         {
             _creativesRepository.AddTag(creative.Creativeid);
         }
         return RedirectToAction("Add", "Chapter", new { id = creative.Creativeid });
     }
     return View();
 }
Example #5
0
 public void ModifiedCreatives(Creative creative)
 {
     _db.Entry(GetCreativeById(creative.Creativeid)).CurrentValues.SetValues(creative);
     _db.SaveChanges();
 }