Exemplo n.º 1
0
        public async Task<IdentityResult> Create(string userName, string password, string displayName)
        {
            var usr = new ApplicationUser();
            var usrData = new ApplicationUserData();

            usr.UserName = userName;
            usrData.CreatedOn = DateTime.Now;
            usrData.DisplayName = displayName;

            IdentityResult t = await userManager.CreateAsync(usr, password);

            if(t.Succeeded)
            {
                var user = await userManager.FindByNameAsync(userName);
                if (user != null)
                {
                    usrData.Id = user.Id;
                    await userRepository.CreateUser(usrData);
                }
            }

            return t;
        }
Exemplo n.º 2
0
 public async Task<int> UpdateUser(ApplicationUserData usr)
 {
     var ret = await userRepository.SaveUser(usr);
     return ret;
 }
Exemplo n.º 3
0
        public void UpdateUserReturnsZeroRecorsdIfUpdateAsyncFails()
        {
            var usr = new ApplicationUserData();
            usr.DisplayName = "testname";
            //usr.DisplayName = "testdisplay";
            //usr.CreatedOn = DateTime.Now;

            mockUserRepo.Setup(x => x.SaveUser(It.IsAny<ApplicationUserData>()))
                .ReturnsAsync(0)
                .Verifiable();

            var result = target.UpdateUser(usr);

            mockUserRepo.Verify();
            Assert.AreEqual(0, result.Result);
        }