// GET: Comment
        public ActionResult ShowNoteComments(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Note not = nm.Find(x => x.Id == id);

            if (not == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_PartialComments", not.Comments));
        }
예제 #2
0
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Note note = noteManager.Find(x => x.Id == id);

            if (note == null)
            {
                return(HttpNotFound());
            }
            return(View(note));
        }
예제 #3
0
        void OpenTemplateButtonClicked(object sender, EventArgs args)
        {
            NoteManager manager       = Tomboy.DefaultNoteManager;
            Note        template_note = manager.Find(NoteOfTheDay.TemplateTitle);

            if (template_note == null)
            {
                // Create a new template note for the user
                try {
                    template_note = manager.Create(
                        NoteOfTheDay.TemplateTitle,
                        NoteOfTheDay.GetTemplateContent(
                            NoteOfTheDay.TemplateTitle));
                    template_note.QueueSave(ChangeType.ContentChanged);
                } catch (Exception e) {
                    Logger.Warn("Error creating Note of the Day Template note: {0}\n{1}",
                                e.Message, e.StackTrace);
                }
            }

            // Open the template note
            if (template_note != null)
            {
                template_note.Window.Show();
            }
        }
        public ActionResult writeComment(Comment comment, int?noteID)
        {
            if (noteID == null)
            {
                return(Json(new { data = false, text = "Yorum Yaptığınız Not Silinmiş Olabilir !" }));
            }

            Note note = noteManager.Find(x => x.ID == noteID);

            if (note == null)
            {
                return(Json(new { data = false, text = "Yorum Yaptığınız Not Silinmiş Olabilir !" }));
            }


            comment.Note  = note;
            comment.Owner = CSession.User;

            int count = commentManager.insert(comment);

            if (count == 0)
            {
                return(Json(new { data = false, text = "Yorum İşlemi Esnasında Bir Hata Meydana Geldi !" }));
            }

            return(Json(new { data = true, text = "Yorum İşlemi Başarılı!" }));
        }
예제 #5
0
        public ActionResult Create(Comment comment, int?noteid)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                if (noteid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                Album note = noteManager.Find(x => x.Id == noteid);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }

                comment.Note  = note;
                comment.Owner = CurrentSession.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
예제 #6
0
        public static string GetContent(DateTime day, NoteManager manager)
        {
            string title = GetTitle (day);

            bool yesterdayAsTemplate;

            Note templateNote = manager.Find (TemplateTitle);

            // Attempt to load yesterday "NoteOfTheDay" note. If not, then template.
            // And if not again, then default.
            // First of all... Do you want to start with yesterday note?
            try{
                yesterdayAsTemplate = (bool) Preferences.Get(NoteOfTheDay.NOTD_YESTERDAY);
            }catch (Exception) {
                Logger.Debug("NoteOfTheDay: Couldn't find a preference for yesterday as template.");
                yesterdayAsTemplate = true; // Defaults to true. See NoteOfTheDayPreferences.cs
            }
            // TODO: Let number of days to look back for to be configurable.
            if (yesterdayAsTemplate) {
                /*
                 * Ok. Let me see...
                 * First of all: find yesterday note calculating yesterday date as today minus 24 h.
                 * There is a method for searching by date.
                 * Then, replace yesterday date for today date.
                 * And finally return note content.
                 */
                ; // TODO: PORASQUI
            } else {
                // Attempt to load content from template
                if (templateNote != null)
                    return templateNote.XmlContent.Replace (TemplateTitle, title);
                else
                    return GetTemplateContent (title);
            }
        }
예제 #7
0
        public ActionResult Create(Comment comment, int? noteId) 
        {
            ModelState.Remove("ModifiedUserName");

            if (ModelState.IsValid)
            {
                if (noteId == null)
                    return new HttpStatusCodeResult(HttpStatusCode.BadRequest);

                Note note = noteManager.Find(n => n.Id == noteId.Value);

                if (note == null)
                    return new HttpNotFoundResult();

                comment.Note = note;
                comment.Owner = CurrentSession.User;

                if (commentManager.Insert(comment) > 0)
                    return Json(new { result = true }, JsonRequestBehavior.AllowGet);
                else
                    return Json(new { result = false }, JsonRequestBehavior.AllowGet);
            }

            return Json(new { result = false }, JsonRequestBehavior.AllowGet);
        }
예제 #8
0
        /// <summary>
        /// Return the template Tomboy Note that corresponds with
        /// this Notebook.
        /// </summary>
        /// <returns>
        /// A <see cref="Note"/>
        /// </returns>
        public virtual Note GetTemplateNote()
        {
            NoteManager noteManager = Tomboy.DefaultNoteManager;
            Note        note        = noteManager.Find(templateNoteTitle);

            if (note == null)
            {
                note =
                    noteManager.Create(templateNoteTitle,
                                       NoteManager.GetNoteTemplateContent(templateNoteTitle));

                // Select the initial text
                NoteBuffer   buffer = note.Buffer;
                Gtk.TextIter iter   = buffer.GetIterAtLineOffset(2, 0);
                buffer.MoveMark(buffer.SelectionBound, iter);
                buffer.MoveMark(buffer.InsertMark, buffer.EndIter);

                // Flag this as a template note
                Tag tag = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag);
                note.AddTag(tag);

                // Add on the notebook system tag so Tomboy
                // will persist the tag/notebook across sessions
                // if no other notes are added to the notebook.
                tag = TagManager.GetOrCreateSystemTag(NotebookTagPrefix + Name);
                note.AddTag(tag);

                note.QueueSave(ChangeType.ContentChanged);
            }

            return(note);
        }
예제 #9
0
        //Index.cshtml    $("#modal_comment_body").load("/Comment/ShowNoteComments"); bu şekilde çağırdık
        public ActionResult ShowNoteComments(int?id)  //noteid
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Note note = noteManager.Find(x => x.Id == id);

            //Note note = noteManager.ListQueryable().Include("Commnets").FirstOrDefault(x => x.Id == id);

            if (note == null)
            {
                return(HttpNotFound());
            }

            return(PartialView("_PartialComments", note.Comments));
        }
예제 #10
0
        public ActionResult ShowNoteComments(int?Id)
        {
            if (Id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Note note = nm.Find(x => x.Id == Id);

            //var comments = cm.ListQueryable().Include("Note").Include("NoteUser").
            //   Where(z => z.Note.Id == Id).
            //   OrderByDescending(x => x.ModifiedOn);
            if (note == null)
            {
                return(HttpNotFound());
            }
            return(PartialView("_PartialComments",
                               note.Comments.OrderByDescending(z => z.ModifiedOn).ToList()));
        }
예제 #11
0
		public static string GetContent (DateTime day, NoteManager manager)
		{
			string title = GetTitle (day);

			// Attempt to load content from template
			Note templateNote = manager.Find (TemplateTitle);
			if (templateNote != null)
				return templateNote.XmlContent.Replace (TemplateTitle, title);
			else
				return GetTemplateContent (title);
		}
예제 #12
0
        //notları göster
        public ActionResult ShowNoteComments(int?id)
        {
            //id degeri bos gelirse
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            //note degeri id dwgerini cek
            Note note = noteManager.Find(x => x.Id == id);


            if (note == null)
            {
                return(HttpNotFound());
            }

            //nottaki yorumları retun yap
            return(PartialView("_PartialComments", note.Commnets));
        }
예제 #13
0
        public string GetPath(string title)
        {
            if (string.IsNullOrEmpty(title))
            {
                return(string.Empty);
            }

            if (resolved_notes.Contains(title.ToLower()))
            {
                return(string.Empty);
            }

            resolved_notes.Add(title.ToLower());
            return(manager.Find(title).FilePath);
        }
예제 #14
0
        /// <summary>
        /// Return the template Tomboy Note that corresponds with
        /// this Notebook.
        /// </summary>
        /// <returns>
        /// A <see cref="Note"/>
        /// </returns>
        public virtual Note GetTemplateNote()
        {
            NoteManager noteManager   = Tomboy.DefaultNoteManager;
            Note        template_note = null;
            Tag         template_tag  = TagManager.GetOrCreateSystemTag(TagManager.TemplateNoteSystemTag);
            Tag         notebook_tag  = TagManager.GetOrCreateSystemTag(NotebookTagPrefix + Name);

            foreach (Note note in template_tag.Notes)
            {
                if (note.ContainsTag(notebook_tag))
                {
                    template_note = note;
                    break;
                }
            }

            if (template_note == null)
            {
                // Check name does not exist
                String template_name = templateNoteTitle;
                if (noteManager.Find(template_name) != null)
                {
                    template_name = noteManager.GetUniqueName(template_name, 1);
                }

                template_note =
                    noteManager.Create(template_name,
                                       NoteManager.GetNoteTemplateContent(template_name));

                // Select the initial text
                NoteBuffer   buffer = template_note.Buffer;
                Gtk.TextIter iter   = buffer.GetIterAtLineOffset(2, 0);
                buffer.MoveMark(buffer.SelectionBound, iter);
                buffer.MoveMark(buffer.InsertMark, buffer.EndIter);

                // Flag this as a template note
                template_note.AddTag(template_tag);

                // Add on the notebook system tag so Tomboy
                // will persist the tag/notebook across sessions
                // if no other notes are added to the notebook.
                template_note.AddTag(notebook_tag);

                template_note.QueueSave(ChangeType.ContentChanged);
            }

            return(template_note);
        }
예제 #15
0
        public static string GetContent(DateTime day, NoteManager manager)
        {
            string title = GetTitle(day);

            // Attempt to load content from template
            Note templateNote = manager.Find(TemplateTitle);

            if (templateNote != null)
            {
                return(templateNote.XmlContent.Replace(TemplateTitle, title));
            }
            else
            {
                return(GetTemplateContent(title));
            }
        }
예제 #16
0
        public ActionResult GetNoteText(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }

            Note note = noteManager.Find(x => x.Id == id);

            if (note == null)
            {
                return(HttpNotFound());
            }

            return(PartialView("_PartialNoteText", note));
        }
예제 #17
0
        public ActionResult ShowNote(int?id)
        {
            NoteManager noteManager = new NoteManager();

            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Note note = noteManager.Find(x => x.ID == id);

            if (note == null)
            {
                return(HttpNotFound());
            }
            return(View(note));
        }
예제 #18
0
 public ActionResult GetNoteDetail(int?Id)
 {
     if (Id == null)
     {
         return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
     }
     _note = nm.Find(x => x.Id == Id);
     if (_note == null)
     {
         return(HttpNotFound());
     }
     return(PartialView("_PartialNoteDetail", _note));
 }
        public ActionResult Insert(string text, int noteId)
        {
            ModelState.Remove("CreatedOn");
            ModelState.Remove("CreatedUserName");
            if (ModelState.IsValid)
            {
                Note note = noteManager.Find(q => q.Id == noteId);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }

                if (commentManager.Insert(new Comment {
                    Text = text, Note = note, Owner = CurrentSession.User
                }) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
        public ActionResult Create(Comment comment, int?noteid)
        {
            //Oluşturma Tarihi,Kimin Oluştuduğu,Oluşturanın kullanıcı adı ModelState de varsa sil
            ModelState.Remove("CreatedOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUsername");

            if (ModelState.IsValid)
            {
                //id null ise
                if (noteid == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }
                //Note id si olanı bana getir
                Note note = noteManager.Find(x => x.Id == noteid);

                //Comment null ise
                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }

                //Yorumun notu
                comment.Note = note;
                //Yorumun sahibi
                comment.Owner = CurrentSession.User;

                //sonuç başarılı ise INSERT et
                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { result = true }, JsonRequestBehavior.AllowGet));
                }
            }
            //işlem başarızsa false
            return(Json(new { result = false }, JsonRequestBehavior.AllowGet));
        }
예제 #21
0
        public ActionResult SetLikeState(int noteid, bool liked)
        {
            int res = 0;

            ND_Liked like = likedManager.Find(x => x.Note.Id == noteid && x.LikedUser.Id == CurrentSession.User.Id);
            ND_Note  note = noteManager.Find(x => x.Id == noteid);

            if (like != null && liked == false)
            {
                res = likedManager.Delete(like);
            }
            else if (like == null && liked == true)
            {
                res = likedManager.Insert(new ND_Liked()
                {
                    LikedUser = CurrentSession.User,
                    Note      = note
                });
            }

            if (res > 0)
            {
                if (liked)
                {
                    note.LikeCount++;
                }
                else
                {
                    note.LikeCount--;
                }

                res = noteManager.Update(note);

                return(Json(new { hasError = false, errorMessage = "", result = note.LikeCount }));
            }


            return(Json(new { hasError = true, errorMessage = "Beğenme işlemi hatalı.", result = note.LikeCount }));
        }
예제 #22
0
        public ActionResult Create(string text, int?noteId)
        {
            ModelState.Remove("CreateOn");
            ModelState.Remove("ModifiedOn");
            ModelState.Remove("ModifiedUser");

            if (ModelState.IsValid)
            {
                if (noteId == null)
                {
                    return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
                }

                ENote note = noteManager.Find(x => x.Id == noteId);

                if (note == null)
                {
                    return(new HttpNotFoundResult());
                }
                if (text == "")
                {
                    return(new HttpNotFoundResult());
                }
                EComment comment = new EComment();
                comment.Text  = text;
                comment.Note  = note;
                comment.Owner = SessionManager.User;

                if (commentManager.Insert(comment) > 0)
                {
                    return(Json(new { ress = true }, JsonRequestBehavior.AllowGet));
                }
            }

            return(Json(new { ress = false }, JsonRequestBehavior.AllowGet));
        }
예제 #23
0
 public ActionResult NoteDetail(int?id)
 {
     return(PartialView(noteManager.Find(x => x.Id == id)));
 }