public JsonResult Create(EditorViewModel model)
 {
     if (ModelState.IsValid)
     {
         var tags = Entities.ParseTags(model.TagString);
         var presentation = new Presentation
         {
             Title = model.Title,
             Description = model.Description,
             Json = model.Json,
             HtmlContents = model.HtmlContents,
             Tags = tags,
             UserName = User.Identity.Name
         };
         try
         {
             Entities.AddToPresentations(presentation);
             EntitiesIndexer.AddPresentationToIndex(presentation);
             var cm = new WebPresentationsCacheManager();
             cm.Flush();
         }
         catch
         {
             return Json("Fail");
         }
         return Json("Success");
     }
     return Json("Fail");
 }
 public void UpdatePresentationTags(Presentation presentation, string tagString)
 {
     foreach(var tag in presentation.Tags.ToList())
     {
         DismissTag(tag);
     }
     Entities.SaveChanges();
     presentation.Tags = ParseTags(tagString);
     Entities.SaveChanges();
 }
 private Presentation TestPresentation(string t = "Test")
 {
     var testPresentation = new Presentation
     {
         UserName = t,
         Title = t,
         Json = t,
         Description = t,
         Tags = new List<Tag> { new Tag(t) },
     };
     return testPresentation;
 }
Example #4
0
 public int AddLike(Presentation presentation, string userName)
 {
     if (!IsLikedByUser(presentation, userName))
     {
         if (!UserOwnsPresentation(presentation.PresentationId, userName))
         {
             presentation.LikedUsers.Add(new LikedUser(userName));
             Entities.SaveChanges();
             return 0;
         }
         return 1;
     }
     return 2;
 }
 public static void AddPresentationToIndex(Presentation presentation)
 {
     var document = new Document();
     foreach (var tag in presentation.Tags)
     {
         document.Add(new Field("Tags", tag.Text, Field.Store.YES, Field.Index.ANALYZED));  
     }
     foreach (var word in ParseTextData(presentation.Json))
     {
         document.Add(new Field("TextData", word, Field.Store.YES, Field.Index.ANALYZED)); 
     }
     document.Add(new Field("Id", Convert.ToString(presentation.PresentationId), Field.Store.YES, Field.Index.NOT_ANALYZED));
     document.Add(new Field("Title", presentation.Title, Field.Store.YES, Field.Index.ANALYZED));
     document.Add(new Field("Description", presentation.Description, Field.Store.YES, Field.Index.ANALYZED));
     LuceneIndexer.AddDocument(document);
 }
Example #6
0
 public void AddToPresentations(Presentation presentation)
 {
     Entities.Presentations.Add(presentation);
     Entities.SaveChanges();
 }
Example #7
0
 public bool IsLikedByUser(Presentation presentation, string userName)
 {
     return presentation.LikedUsers.Any(l => l.UserName.Equals(userName));
 }
 public static void UpdatePresentationIndex(Presentation presentation)
 {
     LuceneIndexer.ClearIndexRecord(presentation.PresentationId);
     AddPresentationToIndex(presentation);
 }