public PostedNote.PostedNotePayload ToggleHighlightNote([FromForm] int noteId) { ProMaUser user = DataController.LoggedInUser; if (user == null) { throw new NotLoggedInException(); } PostedNote relevantNote = PostedNoteHandler.GetNote(noteId); if (relevantNote == null) { throw new Exception("No note with id " + noteId.ToString()); } if (relevantNote.NoteTypeId.HasValue && !NoteTypeHandler.UserCanPostNotesOfType(user.UserId, relevantNote.NoteTypeId.Value)) { throw new Exception("Cannot modify or create notes of this type"); } relevantNote.Highlighted = !relevantNote.Highlighted; relevantNote.EditedTime = ProMaUser.NowTime(); relevantNote.EditedUserId = user.UserId; PostedNoteHandler.UpdatePostedNote(relevantNote); return(PostedNoteHandler.GetPayloadNote(relevantNote, user.UserId)); }
public PostedNote.PostedNotePayload SetNoteActive([FromBody] SetNoteActiveRequestObject requestObject) { ProMaUser user = DataController.LoggedInUser; if (user == null) { throw new NotLoggedInException(); } PostedNote relevantNote = PostedNoteHandler.GetNote(requestObject.noteId); if (relevantNote == null) { throw new Exception("No note with id " + requestObject.noteId.ToString()); } if (relevantNote.NoteTypeId.HasValue && !NoteTypeHandler.UserCanPostNotesOfType(user.UserId, relevantNote.NoteTypeId.Value)) { throw new Exception("Cannot modify or create notes of this type"); } relevantNote.Active = requestObject.active; relevantNote.EditedTime = ProMaUser.NowTime(); relevantNote.EditedUserId = user.UserId; PostedNoteHandler.UpdatePostedNote(relevantNote); return(PostedNoteHandler.GetPayloadNote(relevantNote, user.UserId)); }
public PostedNote.PostedNotePayload EditNote([FromBody] EditNoteRequestObject requestObject) { ProMaUser user = DataController.LoggedInUser; if (user == null) { throw new NotLoggedInException(); } PostedNote relevantNote = PostedNoteHandler.GetNote(requestObject.noteId); if (relevantNote == null) { throw new Exception("No note with id " + requestObject.noteId.ToString()); } if (relevantNote.NoteTypeId.HasValue && !NoteTypeHandler.UserCanPostNotesOfType(user.UserId, relevantNote.NoteTypeId.Value)) { throw new Exception("Cannot modify or create notes of this type"); } relevantNote.NoteText = PostedNoteHandler.CleanNoteText(requestObject.noteText); if (requestObject.noteTypeId != -1) { relevantNote.NoteTypeId = requestObject.noteTypeId; } else { relevantNote.NoteTypeId = null; } relevantNote.EditedTime = ProMaUser.NowTime(); relevantNote.EditedUserId = user.UserId; relevantNote.NoteTitle = requestObject.noteTitle; PostedNoteHandler.UpdatePostedNote(relevantNote); return(PostedNoteHandler.GetPayloadNote(relevantNote, (int?)(user.UserId))); }