0

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.

MHadi Taghdisi
  • 380
  • 1
  • 4
  • 15
  • Maybe this help you https://stackoverflow.com/questions/23861196/moving-identity-2-0-functions-to-repository-class?answertab=votes#tab-top – Hossein Aug 03 '18 at 17:21
  • No, it wants to use UserManager in the business layer but for me is something else, I want to use the UserManager in Data Layer but it's disposed. – MHadi Taghdisi Aug 05 '18 at 09:42
  • @mhadi-taghdidi I dont any more idea. I think you must implement it custom ,without `asp.net-identity` – Hossein Aug 05 '18 at 09:50

0 Answers0