コード例 #1
0
        public async Task <ActionResult> AddPhoneNumber(AddPhoneNumberViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }
            // Generate the token and send it
            var code = await UsersBL.GenerateChangePhoneNumberTokenAsync(User.Identity.GetUserId(), model.Number);

            if (UsersBL.SmsService != null)
            {
                var message = new IdentityMessage
                {
                    Destination = model.Number,
                    Body        = "Your security code is: " + code
                };
                await UsersBL.SmsService.SendAsync(message);
            }
            return(RedirectToAction("VerifyPhoneNumber", new { PhoneNumber = model.Number }));
        }