public async Task SetsNoteInService()
        {
            var note = new NoteDto {
                Content = "my note"
            };

            AsUser("user1", Scopes.Notes);
            await Client.Contacts["1"].Note.SetAsync(note);

            _serviceMock.Verify(x => x.SetNoteAsync("1", note));
        }
        public async Task ReadsNoteFromService()
        {
            var note = new NoteDto {
                Content = "my note"
            };

            _serviceMock.Setup(x => x.ReadNoteAsync("1")).ReturnsAsync(note);

            AsUser("user1", Scopes.Notes);
            var result = await Client.Contacts["1"].Note.ReadAsync();

            result.Should().Be(note);
        }
示例#3
0
        public async Task SetNoteAsync(string id, NoteDto note)
        {
            var entity = await _context.Contacts.FindAsync(id);

            if (entity == null)
            {
                throw new KeyNotFoundException($"Contact '{id}' not found.");
            }

            entity.Note = note.Content;

            using (_metrics.Write())
            {
                _context.Update(entity);
                await _context.SaveChangesAsync();
            }

            _logger.LogDebug("Set note for contact {0}", id);
        }
        public async Task <IActionResult> SetNote([FromRoute] string id, [FromBody] NoteDto note)
        {
            await _service.SetNoteAsync(id, note);

            return(StatusCode((int)HttpStatusCode.NoContent));
        }