I am using identity 1.0 for my application and want to move UserManager
to Data layer such as the following code (I've Customized Userstore
to AppUserStore
):
public class UserRepository
{
public UserManager<ApplicationUser, string> AppUserManager()
{
using (var db=new DataContext())
{
var Appstore = new AppUserStore<ApplicationUser>(db);
var userManager = new UserManager<ApplicationUser, string>(Appstore);
return userManager;
}
}
}
and then in business Layer i want to use this userManager
to create a user:
public bool Create(CreateUserViewModel quser)
{
var repository = new UserRepository();
var userManager = repository.AppUserManager();
var result = userManager.Create(quser);
return result.IsCompleted
{
but it threw an exception that DataContext
is disposed.
how can i Move userManager
to Data Layer and fix this problem? i always use this pattern for my Apps.