public async Task DeleteResourceAsync(Project source, string resourceId) { ProjectIdentityResource projectIdentityResource = await GetDbProjectResource(source.Id, resourceId); _context.ProjectIdentityResources.Remove(projectIdentityResource); await _context.SaveChangesAsync(); }
public async Task AddResourcesAsync(Project source, IEnumerable <string> resourcesToAddIds) { IdentityResource[] query = await _context.IdentityResources.Include(x => x.ProjectResources).ToArrayAsync(); IEnumerable <IdentityResource> resources = query.Where(x => resourcesToAddIds.Any(id => id == x.Id)); foreach (IdentityResource resource in resources) { ProjectIdentityResource projectIdentityResource = new ProjectIdentityResource { ProjectId = source.Id, IdentityResourceId = resource.Id }; await _context.ProjectIdentityResources.AddAsync(projectIdentityResource); } await _context.SaveChangesAsync(); }