public async Task <int> Update(DTOuser entity)
 {
     using (var context = new ThorvaldIdentityDBContext(_serviceProvider.GetRequiredService <DbContextOptions <ThorvaldIdentityDBContext> >()))
     {
         context.Update(dtoConverter.ConvertDTOUser(entity));
         return(await context.SaveChangesAsync());
     }
 }
 public async Task <int> Delete(int id)
 {
     using (var context = new ThorvaldIdentityDBContext(_serviceProvider.GetRequiredService <DbContextOptions <ThorvaldIdentityDBContext> >()))
     {
         context.UserRole.RemoveRange(context.UserRole.Where(u => u.UserId == id));
         return(await context.SaveChangesAsync());
     }
 }
 public async Task <int> Create(DTOrole entity)
 {
     using (var context = new ThorvaldIdentityDBContext(_serviceProvider.GetRequiredService <DbContextOptions <ThorvaldIdentityDBContext> >()))
     {
         var role = dtoConverter.ConvertDTORole(entity);
         context.Role.Add(role);
         return(await context.SaveChangesAsync());
     }
 }
 public async Task <int> Delete(int id)
 {
     using (var context = new ThorvaldIdentityDBContext(_serviceProvider.GetRequiredService <DbContextOptions <ThorvaldIdentityDBContext> >()))
     {
         DTOrole role = new DTOrole()
         {
             Id = id
         };
         context.UserRole.RemoveRange(context.UserRole.Where(i => i.RoleId == id));
         context.Role.Remove(dtoConverter.ConvertDTORole(role));
         return(await context.SaveChangesAsync());
     }
 }