/// <inheritdoc/> public async Task CreateAgendaItemRecursivelyAsync( IWho who, IAuditHeaderWithAuditDetails auditHeader, IAgendaItem agendaItem) { AgendaItemDto dto = AgendaItemDto.ToDto(agendaItem); this.context.AgendaItems.Add(dto); Audit.AuditCreate(auditHeader, dto, dto.Id); foreach (IAgendaItem child in agendaItem.ChildAgendaItems) { await this.CreateAgendaItemRecursivelyAsync( who, auditHeader, child); } if (agendaItem.ParentId == null) { this.logger.Debug( who, "Saving changes", new { AgendaItemId = agendaItem }); await this.context.SaveChangesAsync(); } this.logger.ReportExit(who); }
/// <inheritdoc/> public async Task UpdateAgendaItemAsync( IWho who, IAuditHeaderWithAuditDetails auditHeader, IAgendaItem agendaItem) { this.logger.ReportEntry( who, new { AgendaItem = agendaItem }); AgendaItemDto dto = AgendaItemDto.ToDto(agendaItem); AgendaItemDto original = await this.context.FindAsync <AgendaItemDto>(agendaItem.Id); Audit.AuditUpdate(auditHeader, dto.Id, original, dto); this.context.Entry(original).CurrentValues.SetValues(dto); await this.context.SaveChangesAsync().ConfigureAwait(false); this.logger.ReportExit(who); }