public async Task <Result <FeedbackMessage> > DeleteNoteAsync(long noteID) { var getNote = await _notes.GetNoteAsync(_context.GuildID.Value, noteID); if (!getNote.IsSuccess) { return(Result <FeedbackMessage> .FromError(getNote)); } var note = getNote.Entity; // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and // navigation properties can't be evaluated var notifyResult = await _logging.NotifyUserNoteRemovedAsync(note, _context.User.ID); if (!notifyResult.IsSuccess) { return(Result <FeedbackMessage> .FromError(notifyResult)); } var deleteNote = await _notes.DeleteNoteAsync(note); return(deleteNote.IsSuccess ? new FeedbackMessage("Note deleted.", _feedback.Theme.Secondary) : Result <FeedbackMessage> .FromError(deleteNote)); }
public async Task <RuntimeResult> DeleteNoteAsync(long noteID) { var getNote = await _notes.GetNoteAsync(this.Context.Guild, noteID); if (!getNote.IsSuccess) { return(getNote.ToRuntimeResult()); } var note = getNote.Entity; // This has to be done before the warning is actually deleted - otherwise, the lazy loader is removed and // navigation properties can't be evaluated var rescinder = await this.Context.Guild.GetUserAsync(this.Context.User.Id); var notifyResult = await _logging.NotifyUserNoteRemovedAsync(note, rescinder); if (!notifyResult.IsSuccess) { return(notifyResult.ToRuntimeResult()); } var deleteNote = await _notes.DeleteNoteAsync(note); if (!deleteNote.IsSuccess) { return(deleteNote.ToRuntimeResult()); } return(RuntimeCommandResult.FromSuccess("Note deleted.")); }