public async Task Invite(string recipient, string referee, AuthCodeMessageType messageType, string appName) { if (string.IsNullOrEmpty(recipient)) { throw new ApplicationException("Invalid recipient."); } var exists = false; if (messageType == AuthCodeMessageType.Email) { exists = _dataManager.Exists <User>(new { Email = recipient }); } else { exists = _dataManager.Exists <User>(new { Phone = recipient }); } if (exists) { throw new UserRightException("کاربری با این مشخصات از قبل عضو سامانه میباشد."); } var link = GenerateInvitationLink(referee); // Send Message switch (messageType) { case AuthCodeMessageType.SmsMessageWithCode: case AuthCodeMessageType.SmsMessageWithAppLink: case AuthCodeMessageType.ChatMessage: case AuthCodeMessageType.PhoneCall: case AuthCodeMessageType.PushMessage: await _notificationProvider?.SendInvitationPhoneMessage(recipient, link, appName); break; case AuthCodeMessageType.Email: await _notificationProvider?.SendInvitationEmailMessage(recipient, link, appName); break; default: break; } }