private void HandleSaveCommand(object parameter) { var result = string.Empty; try { var newNote = new NotePostDto() { Id = this.id, Date = this.noteDate, Description = this.description, Type = this.selectedType, ProjectId = this.selectedProject.Id, }; if (this.SelectedNote == null) { result = this.NoteService.CreateNote(newNote); MessageBox.Show(result); this.CloseAction(); } else { result = this.NoteService.EditNote(newNote); MessageBox.Show(result); this.CloseAction(); } } catch (Exception e) { result = e.Message; MessageBox.Show(result); } }
public string EditNote(NotePostDto newNote) { var noteToUpdate = this.bmsData.Notes.Find(newNote.Id); noteToUpdate.Type = newNote.Type; noteToUpdate.Date = newNote.Date; noteToUpdate.Description = newNote.Description; noteToUpdate.ProjectId = newNote.ProjectId; this.bmsData.Notes.Update(noteToUpdate); this.bmsData.SaveChanges(); return($"Note was updated"); }
public string CreateNote(NotePostDto newNote) { var userSvr = new UserService(this.bmsData); var note = new Note() { Id = newNote.Id, Type = newNote.Type, Date = newNote.Date, Description = newNote.Description, ProjectId = newNote.ProjectId }; this.bmsData.Notes.Add(note); this.bmsData.SaveChanges(); return($"Note was saved!"); }