public bool Edit(Note note) { foreach (Note c in this.Notes) { if (note.id == c.id) { c.NotesName = note.NotesName; c.NotesDetail = note.NotesDetail; this.Save(this.Path()); return true; } } return false; }
public ActionResult Edit(Note note) { ProjectNotes cm = new ProjectNotes(); cm.Edit(note); return RedirectToAction("Index"); }
public ActionResult Delete(Note note) { ProjectNotes cm = new ProjectNotes(); cm.Remove(note); return RedirectToAction("Index"); }
public ActionResult Create(Note note) { ProjectNotes cm = new ProjectNotes(); cm.Add(note); return RedirectToAction("Index"); }
public Note FindNoteById(int id) { foreach (Note c in this.Notes) if (c.id == id) return c; Note rtn = new Note(); rtn.id = -1; rtn.NotesName = "Error"; rtn.NotesDetail = ""; return rtn; }
public bool Fill(string path) { try { XDocument doc = XDocument.Load(path); var q = from chr in doc.Elements("notes").Elements("note") select chr; foreach (var elem in q) { Note c = new Note(); c.NotesName = elem.Element("NotesName").Value; c.NotesDetail = elem.Element("NotesDetail").Value; Notes.Add(c); } } catch { return false; } return true; }
public void Add(Note c) { Notes.Add(c); Save(Path()); }
public bool Remove(Note gone) { int count = 0; foreach (Note c in this.Notes) { if (gone.id == c.id) { this.Notes.RemoveAt(count); break; } ++count; } if (count < Notes.Count + 1) { this.Save(this.Path()); return true; } return false; }