// Return the client data associated with the given being and client name. public async Task <IActionResult> Index([EmailAddress, MaxLength(100)] string email_address, [Required, MaxLength(20)] string client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } BeingClient bc = (await ef.Aliases .Include(a => a.Being).ThenInclude(b => b.Clients) .FirstOrDefaultAsync(a => a.EmailAddress == email_address)) ?.Being .Clients .FirstOrDefault(c => c.ClientName == client); if (bc == null) { return(NotFound()); } Dictionary <string, string> data = new Dictionary <string, string>(); foreach (BeingClientDatum datum in await ef.BeingClientData .Where(d => d.BeingClientID == bc.BeingClientID) .ToListAsync()) { data.Add(datum.Key, datum.Value); } return(Json(data)); }
public async Task <IActionResult> IndexDelete([Required, EmailAddress, MaxLength(100)] string email_address, [Required, MaxLength(20)] string client) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } Being being = (await ef.Aliases .Include(a => a.Being).ThenInclude(b => b.Clients) .FirstOrDefaultAsync(a => a.EmailAddress == email_address)) ?.Being; if (being == null) { return(NotFound()); } BeingClient bc = being.Clients.FirstOrDefault(c => c.ClientName == client); if (bc == null) { return(NotFound()); } if (being.Clients.Count == 1) { ef.Beings.Remove(being); } else { ef.BeingClients.Remove(bc); } await ef.SaveChangesAsync(); return(NoContent()); }