Beispiel #1
0
        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);
        }
Beispiel #2
0
        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);
        }
Beispiel #3
0
        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;
        }
Beispiel #4
0
        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;
        }
Beispiel #5
0
        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");
        }