private SalesController GetController(BasicTestAppDbContext context) { IAccountData accountData = new SqlAccountData(context, _sqlmapper); IAccountService accountService = new AccountService(accountData, _mapper); return(new SalesController(accountService)); }
private void SendEmailConfirmationCode(SqlAccountData accountData) { var code = Security.CreateRandomString(6); _database.SaveEmailConfirmationCode(accountData.Email, code); _mailPlugin.SendMail(accountData.Email, "E-mail confirmation", string.Format(ConfirmEmailBody, code)); }
private SqlAccountData ReadAccountData(NpgsqlDataReader reader, NpgsqlCommand cmd) { SqlAccountData account = null; // Read primary account data while (reader.Read()) { account = new SqlAccountData() { Username = reader["username"] as string, //AccountId = reader.GetInt32("account_id"), AccountId = Int32.Parse(reader["account_id"].ToString()), Email = reader["email"] as string, Password = reader["password"] as string, IsAdmin = reader["is_admin"] as bool? ?? false, IsGuest = reader["is_guest"] as bool? ?? false, IsEmailConfirmed = reader["is_email_confirmed"] as bool? ?? false, Properties = new Dictionary <string, string>(), Token = reader["token"] as string }; } if (account == null) { return(null); } // Read account values reader.Close(); cmd.CommandText = "SELECT * FROM account_properties WHERE account_id = @account_id"; cmd.Parameters.Clear(); cmd.Parameters.AddWithValue("@account_id", account.AccountId); reader = cmd.ExecuteReader(); while (reader.Read()) { var key = reader["prop_key"] as string ?? ""; var value = reader["prop_val"] as string ?? ""; if (string.IsNullOrEmpty(key)) { continue; } account.Properties[key] = value; } return(account); }