private async Task CreateAsync(NeuerKontokorrent kontokorrent) { var k = new Kontokorrent.Impl.EFV2.Kontokorrent() { LaufendeNummer = 0, Name = kontokorrent.Name, OeffentlicherName = kontokorrent.OeffentlicherName, Privat = kontokorrent.Privat, Id = kontokorrent.Id, Personen = kontokorrent.Personen.Select(v => new EFV2.Person() { Name = v.Name, Id = v.Id ?? Guid.NewGuid().ToString() }).ToList() }; _kontokorrentContext.Kontokorrent.Add(k); try { await _kontokorrentContext.SaveChangesAsync(); } catch (DbUpdateException e) { var inner = e.InnerException as SqliteException; if (null != inner && 19 == inner.SqliteErrorCode) { throw new NameExistsException(); } } }
public async Task Erstellen(NeuerKontokorrent request, BenutzerID?ersteller) { await CreateAsync(request); await _kontokorrentContext.SaveChangesAsync(); if (ersteller.HasValue) { await Hinzufuegen(ersteller.Value, request.Id); } }