public Task<Response> DeleteNote(string noteId, string editKey) { var noteManager = new NoteManager(Resolver.Get<KeyValueStore<NoteEntity>>()); var deleteRequest = new DeleteNoteRequest { NoteId = noteId, EditKey = editKey, }; return noteManager.DeleteNote(deleteRequest, CancellationToken.None); }
public Task<Response> UpdateNote(string noteId, string editKey) { var updateNoteRequest = new UpdateNoteRequest { NoteId = noteId, EditKey = editKey, Content = Content, Title = Title, NoteType = NoteType, }; var noteManager = new NoteManager(Resolver.Get<KeyValueStore<NoteEntity>>()); return noteManager.UpdateNote(updateNoteRequest, CancellationToken.None); }
public async Task<bool> Initialize(string noteId, string editKey) { var noteManager = new NoteManager(Resolver.Get<KeyValueStore<NoteEntity>>()); var getNoteResponse = await noteManager.GetNoteForEditing(noteId, editKey, CancellationToken.None); if (getNoteResponse.IsSuccessful == false) { return false; } NoteId = noteId; EditKey = editKey; Title = getNoteResponse.Title; Content = getNoteResponse.Content; NoteType = getNoteResponse.NoteType; ExpirationTime = getNoteResponse.ExpirationTime; return true; }
public async Task<bool> Initialize(string noteId, string editKey) { if (string.IsNullOrWhiteSpace(noteId)) { throw new ArgumentException("Cannot be null or white space", nameof(noteId)); } var noteManager = new NoteManager(Resolver.Get<KeyValueStore<NoteEntity>>()); var getNoteResponse = await noteManager.GetNote(noteId, CancellationToken.None); if (getNoteResponse.IsSuccessful == false) { return false; } NoteId = getNoteResponse.NoteId; Title = getNoteResponse.Title; Content = getNoteResponse.Content; NoteType = getNoteResponse.NoteType; EditKey = editKey; return true; }
public async Task<NoteCreatedViewModel> CreateNote() { var createNoteRequest = new CreateNoteRequest { Title = Title, Content = Content, NoteType = NoteType, ExpiresOn = GetExpirationTime(), }; var noteManager = new NoteManager(Resolver.Get<KeyValueStore<NoteEntity>>()); var createNoteResponse = await noteManager.CreateNote(createNoteRequest, CancellationToken.None); if (createNoteResponse.IsSuccessful) { return new NoteCreatedViewModel { NoteId = createNoteResponse.NoteId, EditKey = createNoteResponse.EditKey, }; } throw new ApplicationException("Fail to create note"); }