Beispiel #1
0
        private static void addText()
        {
            string textUrl = @"http://www.dartmouth.edu/~milton/reading_room/pl/book_1/text.shtml";
            var    cont    = getContent(textUrl);
            var    milton  = db.Texts.ToList()[3];

            milton.Content = cont;

            db.SaveChanges();

            //TextDetail detail = new TextDetail() {
            //    Author = "John Milton",
            //    Title = "Paradise Lost",
            //    TextSource = textUrl
            //};
            //db.TextDetails.AddObject(detail);
            //db.SaveChanges();

            //var text = new Text() {
            //    Content = cont,
            //    Details = detail.ID,
            //};
            //db.Texts.AddObject(text);
            //db.SaveChanges();
        }
Beispiel #2
0
        private void saveAnnotation(object state)
        {
            var annotationAndTags = (annotationAndTags)state;

            Annotation annotation = new Annotation()
            {
                StartIndex            = currentSelection.CharIndex,
                SourceLength          = currentSelection.CharLength,
                SourceText            = currentText.ID,
                Content               = annotationAndTags.Annotation,
                Author                = currentUser.ID,
                UpVotes               = 0,
                DownVotes             = 0,
                HighlightedSourceText = string.Concat((this.textRoot.SelectedContent.Content as TextControl).body.Selection.Text.Take(100)),
                Timestamp             = DateTime.Now
            };


            db.Annotations.AddObject(annotation);
            db.SaveChanges();

            List <int>    tagIDs    = new List <int>();
            List <string> inputTags = annotationAndTags.Tags;

            foreach (var tag in inputTags)
            {
                var resolvedTag = db.Tags.Where(i => i.Name == tag).SingleOrDefault();
                if (resolvedTag == null)
                {
                    var newTag = new Tag()
                    {
                        Name = tag
                    };
                    db.Tags.AddObject(newTag);
                    db.SaveChanges();
                    tagIDs.Add(newTag.ID);
                }
                else
                {
                    tagIDs.Add(resolvedTag.ID);
                }
            }

            foreach (var id in tagIDs)
            {
                var annotationTag = new AnnotationTag()
                {
                    AnnotationID = annotation.ID, TagID = id
                };
                db.AnnotationTags.AddObject(annotationTag);
                db.SaveChanges();
            }

            Dispatcher.Invoke((Action)(() => {
                loadAnnotations();
            }));
        }
Beispiel #3
0
 private static void clearAnnotations(table1Entities db)
 {
     db.Annotations.ToList().ForEach(i => db.DeleteObject(i));
     db.SaveChanges();
 }