public async Task <Model.Common.IApplicationUser> UpdateUserAsync(Model.Common.IApplicationUser user, string password)
        {
            try
            {
                IUnitOfWork            uow           = Repository.CreateUnitOfWork();
                bool                   passwordValid = false;
                Task <ApplicationUser> result        = null;

                UserManager <ApplicationUser> UserManager = CreateUserManager();

                ApplicationUser userToCheck = await UserManager.FindByIdAsync(user.Id);

                passwordValid = await UserManager.CheckPasswordAsync(userToCheck, password);

                if (passwordValid)
                {
                    result = uow.UpdateWithAddAsync <ApplicationUser>(AutoMapper.Mapper.Map <ApplicationUser>(user));
                }
                else
                {
                    throw new Exception("Invalid password");
                }

                await uow.CommitAsync();

                return(await Task.FromResult(AutoMapper.Mapper.Map <StartUpMentor.Model.Common.IApplicationUser>(result.Result) as StartUpMentor.Model.Common.IApplicationUser));
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public async Task <int> AddUser(Model.Common.IApplicationUser user)
 {
     try
     {
         return(await Repository.AddAsync <ApplicationUser>(AutoMapper.Mapper.Map <ApplicationUser>(user)));
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
        public async Task <bool> RegisterUser(Model.Common.IApplicationUser user, string password)
        {
            try
            {
                UserManager <ApplicationUser> userManager = this.CreateUserManager();
                IdentityResult result = await userManager.CreateAsync(AutoMapper.Mapper.Map <ApplicationUser>(user), password);

                return(result.Succeeded);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }