public Entity.UserCommunicationChannel GetByEmail(MailAddress email) { var retVal = default(Entity.UserCommunicationChannel); var identifierHash = email.GetSHA1(); using (var connection = new SqliteConnection(_connectionString)) { connection.Open(); var command = connection.CreateCommand(); command.CommandText = $@"SELECT * FROM user_communication_channels WHERE identifier_hash='$identifier_hash' AND type='$type';"; command.Parameters.Add(new SqliteParameter("$identifier_hash", identifierHash)); command.Parameters.Add(new SqliteParameter("$type", DataProvider.Entity.UserCommunicationChannel.Types.Email.ToString())); var reader = command.ExecuteReader(); if (reader.HasRows) { reader.Read(); retVal = Entity.UserCommunicationChannel.FromDb((ulong) reader.GetInt64(Entity.UserCommunicationChannel.Columns.Id)); } connection.Close(); } return(retVal); }
public void SendInvitation(MailAddress email) { var invitation = _applicationDataProvider.Invitations.Create(); invitation.CommunicationChannelType = UserCommunicationChannel.Types.Email; invitation.IdentifierHash = email.GetSHA1(); invitation.Token = Guid.NewGuid().ToString(); _applicationDataProvider.Invitations.Push(invitation); var msg = new MailMessage { Body = invitation.Token, BodyEncoding = Encoding.UTF8, Subject = "Приглашение на регистрацию", SubjectEncoding = Encoding.UTF8, From = _from, }; msg.To.Add(email); _smtpClient.Send(msg); }