Exemple #1
0
 public async Task<ActionResult> VerifyPhoneNumber(VerifyPhoneNumberViewModel model)
 {
     if (!ModelState.IsValid)
     {
         return View(model);
     }
     var result = await UserManager.ChangePhoneNumberAsync(User.Identity.GetUserId(), model.PhoneNumber, model.Code);
     if (result.Succeeded)
     {
         var users = await UserManager.FindByIdAsync(User.Identity.GetUserId());
         if (users != null)
         {
             await SignInManager.SignInAsync(users, isPersistent: false, rememberBrowser: false);
         }
         return RedirectToAction("Index", new { Message = ManageMessageId.AddPhoneSuccess });
     }
     // If we got this far, something failed, redisplay form
     ModelState.AddModelError("", "Failed to verify phone");
     return View(model);
 }
        public void ManageController_VerifyPhoneNumber_Test02()
        {
            // Initialization
            ManageController ctl = new ManageController();
            VerifyPhoneNumberViewModel model = new VerifyPhoneNumberViewModel();

            // To test if it is null
            var result = ctl.VerifyPhoneNumber(model);
            Assert.IsNotNull(result);
        }