public async Task ThenTheNoteHasBeenPersisted(NotesFixture notesFixture) { var responseObject = notesFixture.NoteResponse; var response = await CallApi(responseObject.TargetId.ToString()).ConfigureAwait(false); var apiResult = await ExtractResultFromHttpResponse(response).ConfigureAwait(false); var note = apiResult.Results.FirstOrDefault(x => x.TargetId == responseObject.TargetId && x.Id == responseObject.Id); note.Should().NotBeNull(); note.Id.Should().Be(responseObject.Id); // Remove after use... var dbNote = new NoteDb() { Author = note.Author, Categorisation = note.Categorisation, CreatedAt = note.CreatedAt, Description = note.Description, Id = note.Id, TargetId = note.TargetId, TargetType = note.TargetType }; notesFixture.Notes.Add(dbNote); }
public async Task <Note> PostNewNoteAsync(CreateNoteRequest request) { var dbNote = new NoteDb { Id = Guid.NewGuid(), Description = request.Description, CreatedAt = request.CreatedAt.Value, TargetId = request.TargetId.Value, TargetType = request.TargetType.Value, Author = new AuthorDetails { Email = request.Author?.Email, FullName = request.Author?.FullName }, Categorisation = new Categorisation { Description = request.Categorisation?.Description, Category = request.Categorisation?.Category, SubCategory = request.Categorisation?.SubCategory } }; _logger.LogDebug($"Saving a new note for targetId: {dbNote.TargetId}, targetType: {Enum.GetName(typeof(TargetType), dbNote.TargetType)}"); await _dynamoDbContext.SaveAsync(dbNote).ConfigureAwait(false); return(dbNote.ToDomain()); }
public static Note ToDomain(this NoteDb databaseNote) { return(new Note { Author = databaseNote.Author, Categorisation = databaseNote.Categorisation, CreatedAt = databaseNote.CreatedAt, Description = databaseNote.Description, Id = databaseNote.Id, TargetId = databaseNote.TargetId, TargetType = databaseNote.TargetType }); }
private async void Button_Click(object sender, RoutedEventArgs e) { if (titleBlock.Text.Length < 1) { MessageBox.Show("Title too short"); return; } NoteDb _dbContext = new NoteDb(); var note = new Note(titleBlock.Text, contentBlock.Text); _dbContext.Notes.Add(note); await _dbContext.SaveChangesAsync(); this.Hide(); }