public async Task <IActionResult> ConfirmPhoneNumber(ConfirmPhoneNumberCommand model) { var command = await _mediator.Send(model); if (command.IsSuccess) { return(Ok(command.Result)); } return(BadRequest(command.ErrorMessage)); }
public async Task <IActionResult> VerifySmsAsync(PhoneConfirmRequest model, CancellationToken token) { var phoneCommand = new ConfirmPhoneNumberCommand(model.Id); var registrationBonusCommand = new FinishRegistrationCommand(model.Id); try { await _commandBus.DispatchAsync(phoneCommand, token); await _commandBus.DispatchAsync(registrationBonusCommand, token); } catch { return(BadRequest()); } return(Ok(new { model.Id })); }
public async Task <IActionResult> ConfirmPhoneNumber(ConfirmPhoneViewModel model) { if (!ModelState.IsValid) { return(View(model)); } var result = await _identityService.ConfirmPhoneAsync(CurrentUserService.UserId, model.PhoneNumber, model.Token); if (result) { var command = new ConfirmPhoneNumberCommand { PhoneNumber = model.PhoneNumber }; await Mediator.Send(command); return(RedirectToAction("Index")); } ModelState.AddModelError("Token", "کد وارد شده معتبر نیست"); return(View(model)); }