public async Task DeleteAsync(int id) { var entity = IdentityResources.Find(id); if (Context.Entry(entity).State == EntityState.Detached) { IdentityResources.Attach(entity); } IdentityResources.Remove(entity); await Context.SaveChangesAsync(); }
/// <summary> /// Update identity resource /// </summary> /// <returns>This method return new identity resource id</returns> public async Task <IdentityResourceDTO> UpdateIdentityResourceAsync(IdentityResourceDTO dto) { var entity = dto.ToEntity(); var canInsert = await CanInsertIdentityResourceAsync(entity); if (!canInsert) { throw new Exception(Constants.Errors.CantInsert); } IdentityResources.Attach(entity); await CleanupIdentityResourceAsync(entity); IdentityResources.Update(entity); await Context.SaveChangesAsync(); return(entity.ToDTO()); }