예제 #1
0
        public ActionResult EditNote(NoteControllerNoteVM model)
        {
            if (!this.ModelState.IsValid)
            {
                return(View(model));
            }

            model = new NoteControllerNoteVM();
            TryUpdateModel(model);
            Note note = new Note();

            if (model.Id > 0)
            {
                note             = NoteRepository.GetByID(model.Id);
                note.Description = model.description;
                note.Text        = model.note;
                note.ContactId   = model.ParentContactId;
            }
            else
            {
                note.Description = model.description;
                note.Text        = model.note;
                note.ContactId   = model.ParentContactId;
            }

            NoteRepository.Save(note);

            return(RedirectToAction("ListNotes", "Note", new { @parentId = model.ParentContactId }));
        }
예제 #2
0
 public ActionResult Delete(int id)
 {
     if (id > 0)
     {
         Note note = new Note();
         note = NoteRepository.GetByID(id);
         NoteRepository.Delete(note);
     }
     model = new NoteControllerNoteVM();
     TryUpdateModel(model);
     return(RedirectToAction("ListNotes", "Note", new { @parentId = model.ParentContactId }));
 }
예제 #3
0
 public ActionResult EditNote(int id)
 {
     if (AuthenticationService.LoggedUser == null)
     {
         return(RedirectToAction("Login", "Default"));
     }
     else
     {
         model = new NoteControllerNoteVM();
         TryUpdateModel(model);
         Note note = new Note();
         if (model.Id > 0)
         {
             note = NoteRepository.GetByID(model.Id);
             model.description = note.Description;
             model.note        = note.Text;
         }
     }
     return(View(model));
 }