public void SendRegistrationCode(string linkKey) { var invite = _inviteRepository.GetByLinkKey(linkKey); CheckInvite(invite); if (invite.PhoneCode != 0) { ContextAccessor.SetModelError("phoneCode", "Code has been sent yet"); ContextAccessor.ThrowIfModelInvalid(); } var verificationCode = SecurityExtensions.GetVerificationCode(); var user = _userRepository.GetById(invite.IdUser); _messengerService.SendSms(user.Phone, $"Your code: {verificationCode}"); invite.PhoneCode = verificationCode; _inviteRepository.Save(invite); }