private async Task Hinzufuegen(BenutzerID benutzerID, string kontokorrentId) { await _kontokorrentContext.BenutzerKontokorrent.AddAsync(new BenutzerKontokorrent() { BenutzerId = benutzerID.Id, KontokorrentId = kontokorrentId }); await _kontokorrentContext.SaveChangesAsync(); }
public async Task Entfernen(string kontokorrentId, BenutzerID benutzerID) { var eintraege = await _kontokorrentContext.BenutzerKontokorrent.Where(v => v.BenutzerId == benutzerID.Id && v.KontokorrentId == kontokorrentId) .ToArrayAsync(); foreach (var eintrag in eintraege) { _kontokorrentContext.BenutzerKontokorrent.Remove(eintrag); } await _kontokorrentContext.SaveChangesAsync(); }
public async Task <Models.KontokorrentInfo[]> Auflisten(BenutzerID benutzerID) { return(await _kontokorrentContext.BenutzerKontokorrent.Where(v => v.BenutzerId == benutzerID.Id) .Include(v => v.Kontokorrent) .ThenInclude(v => v.Personen) .Select(v => new KontokorrentInfo() { Id = v.Kontokorrent.Id, Name = v.Kontokorrent.Name, OeffentlicherName = v.Kontokorrent.OeffentlicherName, Personen = v.Kontokorrent.Personen.Select(d => new Models.Person() { Id = d.Id, Name = d.Name }).ToArray() }).ToArrayAsync()); }
public async Task <Models.Aktion[]> Auflisten(BenutzerID benutzer, string kontokorrentId, int?ab) { if (!await kontokorrentsService.HasAccess(benutzer, kontokorrentId)) { return(null); } return(await kontokorrentV2Context.Aktionen .Where(v => v.KontokorrentId == kontokorrentId) .OrderBy(v => v.LaufendeNummer) .Include(v => v.Bezahlung) .Include(v => v.Bezahlung.BezahlendePerson) .Include(v => v.Bezahlung.Emfpaenger) .ThenInclude(v => v.Empfaenger) .Where(v => ab == null || v.LaufendeNummer > ab) .Select(v => new Models.Aktion() { LaufendeNummer = v.LaufendeNummer, BearbeiteteBezahlungId = v.BearbeiteteBezahlungId, Bezahlung = v.Bezahlung != null ? new Models.Bezahlung() { Beschreibung = v.Bezahlung.Beschreibung, BezahlendePerson = new Models.Person() { Id = v.Bezahlung.BezahlendePersonId, Name = v.Bezahlung.BezahlendePerson.Name }, Id = v.Bezahlung.Id, Empfaenger = v.Bezahlung.Emfpaenger.Select(d => new Models.Person() { Id = d.Empfaenger.Id, Name = d.Empfaenger.Name }).ToArray(), Wert = v.Bezahlung.Wert, Zeitpunkt = new DateTimeOffset(v.Bezahlung.Zeitpunkt, TimeSpan.Zero) } : null, GeloeschteBezahlungId = v.GeloeschteBezahlungId }).ToArrayAsync()); }
public async Task <bool> HasAccess(BenutzerID benutzerID, string kontokorrentId) { return(await _kontokorrentContext.BenutzerKontokorrent.Where(v => v.BenutzerId == benutzerID.Id && v.KontokorrentId == kontokorrentId).AnyAsync()); }
public async Task <KontokorrentInfo[]> HinzufuegenPerOeffentlicherName(string oeffentlicherName, BenutzerID benutzerID) { var kontokorrentId = await _kontokorrentContext.Kontokorrent.Where(v => v.OeffentlicherName == oeffentlicherName && !v.Privat) .Select(v => v.Id) .SingleOrDefaultAsync(); if (null == kontokorrentId) { return(null); } await Hinzufuegen(benutzerID, kontokorrentId); return(await Auflisten(benutzerID)); }
public async Task <KontokorrentInfo[]> HinzufuegenPerCode(string einladungsCode, BenutzerID benutzerID) { var code = await _kontokorrentContext.EinladungsCode.Where(v => v.Id == einladungsCode).SingleOrDefaultAsync(); if (null == code) { return(null); } await Hinzufuegen(benutzerID, code.KontokorrentId); return(await Auflisten(benutzerID)); }