Make user email and phone editable through the role editor
This commit is contained in:
parent
c8e634156b
commit
41cae96922
@ -8,7 +8,7 @@
|
||||
<applicationSettings>
|
||||
<RoleEditor.Properties.Settings>
|
||||
<setting name="ConnectionString" serializeAs="String">
|
||||
<value>Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling;Port=33306</value>
|
||||
<value>Server=localhost;User ID=ds;Password=HalloWach_2323XXL!!;Database=bremen_calling_devel;Port=33306</value>
|
||||
</setting>
|
||||
</RoleEditor.Properties.Settings>
|
||||
</applicationSettings>
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
xmlns:local="clr-namespace:RoleEditor"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
mc:Ignorable="d"
|
||||
Title="Bremen calling admin editor" Height="650" Width="800" Icon="Resources/lock_preferences.ico" Loaded="Window_Loaded">
|
||||
Title="Bremen calling admin editor" Height="670" Width="800" Icon="Resources/lock_preferences.ico" Loaded="Window_Loaded">
|
||||
<Grid>
|
||||
<TabControl>
|
||||
<TabItem Header="Participant, users and roles">
|
||||
@ -121,19 +121,23 @@
|
||||
<Label Grid.Row="1" Grid.Column="1" Content="Last name" HorizontalAlignment="Right"/>
|
||||
<Label Grid.Row="2" Grid.Column="1" Content="User name" HorizontalAlignment="Right"/>
|
||||
<Label Grid.Row="3" Grid.Column="1" Content="Password" HorizontalAlignment="Right"/>
|
||||
<Label Grid.Row="4" Grid.Column="1" Content="API Key" HorizontalAlignment="Right"/>
|
||||
<Label Content="Created" Grid.Row="5" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Content="Modified" Grid.Row="6" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Grid.Row="4" Grid.Column="1" Content="E-Mail" HorizontalAlignment="Right" />
|
||||
<Label Grid.Row="5" Grid.Column="1" Content="Phone" HorizontalAlignment="Right" />
|
||||
<Label Grid.Row="6" Grid.Column="1" Content="API Key" HorizontalAlignment="Right"/>
|
||||
<Label Content="Created" Grid.Row="7" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
<Label Content="Modified" Grid.Row="8" Grid.Column="1" HorizontalAlignment="Right"/>
|
||||
|
||||
<TextBox x:Name="textBoxUserFirstName" Grid.Row="0" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserLastName" Grid.Row="1" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserUserName" Grid.Row="2" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserPassword" Grid.Row="3" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserAPIKey" Grid.Row="4" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserCreated" Grid.Row="5" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserModified" Grid.Row="6" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserEMail" Grid.Row="4" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserPhone" Grid.Row="5" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserAPIKey" Grid.Row="6" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserCreated" Grid.Row="7" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
<TextBox x:Name="textBoxUserModified" Grid.Row="8" IsReadOnly="True" IsEnabled="False" Grid.Column="2" Margin="2" VerticalContentAlignment="Center" />
|
||||
|
||||
<Button x:Name="buttonUserSave" Grid.Row="7" Grid.Column="2" Click="buttonUserSave_Click" Margin="2">
|
||||
<Button x:Name="buttonUserSave" Grid.Row="9" Grid.Column="2" Click="buttonUserSave_Click" Margin="2">
|
||||
<DockPanel>
|
||||
<Image Source="./Resources/disk_blue.png" Margin="0,0,5,0" Height="24" DockPanel.Dock="Left" Width="16"/>
|
||||
<TextBlock Text="Save" VerticalAlignment="Center" DockPanel.Dock="Right"/>
|
||||
|
||||
@ -253,6 +253,8 @@ namespace RoleEditor
|
||||
u.Firstname = this.textBoxUserFirstName.Text.Trim();
|
||||
u.Lastname = this.textBoxUserLastName.Text.Trim();
|
||||
u.Username = this.textBoxUserUserName.Text.Trim();
|
||||
u.EMail = this.textBoxUserEMail.Text.Trim();
|
||||
u.Phone = this.textBoxUserPhone.Text.Trim();
|
||||
if(this.textBoxUserPassword.Text.Trim().Length > 0 )
|
||||
{
|
||||
string passwortText = this.textBoxUserPassword.Text.Trim();
|
||||
@ -455,6 +457,8 @@ namespace RoleEditor
|
||||
this.textBoxUserFirstName.Text = (u != null) ? u.Firstname : string.Empty;
|
||||
this.textBoxUserLastName.Text = (u != null) ? u.Lastname : string.Empty;
|
||||
this.textBoxUserUserName.Text = (u != null) ? u.Username : string.Empty;
|
||||
this.textBoxUserEMail.Text = (u != null) ? u.EMail : string.Empty;
|
||||
this.textBoxUserPhone.Text = (u != null) ? u.Phone : string.Empty;
|
||||
this.textBoxUserAPIKey.Text = (u != null) ? u.APIKey : string.Empty;
|
||||
this.textBoxUserCreated.Text = (u != null) ? u.Created.ToString() : string.Empty;
|
||||
this.textBoxUserModified.Text = (u != null) ? u.Modified.ToString() : string.Empty;
|
||||
|
||||
@ -12,6 +12,10 @@ namespace brecal.model
|
||||
|
||||
public string Username { get; set; } = "";
|
||||
|
||||
public string EMail { get; set; } = "";
|
||||
|
||||
public string Phone { get; set; } = "";
|
||||
|
||||
public string? PasswordHash { get; set; }
|
||||
|
||||
public string? APIKey { get; set; }
|
||||
@ -33,7 +37,7 @@ namespace brecal.model
|
||||
|
||||
public static void SetLoadQuery(IDbCommand cmd, params object?[] args)
|
||||
{
|
||||
cmd.CommandText = "SELECT id, first_name, last_name, user_name, api_key, created, modified FROM user WHERE participant_id = @PID";
|
||||
cmd.CommandText = "SELECT id, first_name, last_name, user_name, user_email, user_phone, api_key, created, modified FROM user WHERE participant_id = @PID";
|
||||
if (args.Length != 1 || !(args[0] is Participant))
|
||||
throw new ArgumentException("loader needs single partipant as argument");
|
||||
IDataParameter pid = cmd.CreateParameter();
|
||||
@ -53,9 +57,11 @@ namespace brecal.model
|
||||
if (!reader.IsDBNull(1)) u.Firstname = reader.GetString(1);
|
||||
if (!reader.IsDBNull(2)) u.Lastname = reader.GetString(2);
|
||||
if (!reader.IsDBNull(3)) u.Username = reader.GetString(3);
|
||||
if (!reader.IsDBNull(4)) u.APIKey = reader.GetString(4);
|
||||
if (!reader.IsDBNull(5)) u.Created = reader.GetDateTime(5);
|
||||
if (!reader.IsDBNull(6)) u.Modified = reader.GetDateTime(6);
|
||||
if (!reader.IsDBNull(4)) u.EMail = reader.GetString(4);
|
||||
if (!reader.IsDBNull(5)) u.Phone = reader.GetString(5);
|
||||
if (!reader.IsDBNull(6)) u.APIKey = reader.GetString(6);
|
||||
if (!reader.IsDBNull(7)) u.Created = reader.GetDateTime(7);
|
||||
if (!reader.IsDBNull(8)) u.Modified = reader.GetDateTime(8);
|
||||
result.Add(u);
|
||||
}
|
||||
return result;
|
||||
@ -68,15 +74,15 @@ namespace brecal.model
|
||||
public override void SetUpdate(IDbCommand cmd)
|
||||
{
|
||||
if(!string.IsNullOrEmpty(this.PasswordHash))
|
||||
cmd.CommandText = "UPDATE user SET first_name = @FIRSTNAME, last_name = @LASTNAME, user_name = @USERNAME, password_hash = @PWHASH, api_key = @APIKEY WHERE id = @ID";
|
||||
cmd.CommandText = "UPDATE user SET first_name = @FIRSTNAME, last_name = @LASTNAME, user_name = @USERNAME, password_hash = @PWHASH, api_key = @APIKEY, user_email = @USEREMAIL, user_phone = @USERPHONE WHERE id = @ID";
|
||||
else
|
||||
cmd.CommandText = "UPDATE user SET first_name = @FIRSTNAME, last_name = @LASTNAME, user_name = @USERNAME, api_key = @APIKEY WHERE id = @ID";
|
||||
cmd.CommandText = "UPDATE user SET first_name = @FIRSTNAME, last_name = @LASTNAME, user_name = @USERNAME, api_key = @APIKEY, user_email = @USEREMAIL, user_phone = @USERPHONE WHERE id = @ID";
|
||||
this.SetParameters(cmd);
|
||||
}
|
||||
|
||||
public override void SetCreate(IDbCommand cmd)
|
||||
{
|
||||
cmd.CommandText = "INSERT INTO user (participant_id, first_name, last_name, user_name, password_hash, api_key) VALUES ( @PID, @FIRSTNAME, @LASTNAME, @USERNAME, @PWHASH, @APIKEY)";
|
||||
cmd.CommandText = "INSERT INTO user (participant_id, first_name, last_name, user_name, password_hash, api_key, user_email, user_phone) VALUES ( @PID, @FIRSTNAME, @LASTNAME, @USERNAME, @PWHASH, @APIKEY, @USEREMAIL, @USERPHONE)";
|
||||
this.SetParameters(cmd);
|
||||
}
|
||||
|
||||
@ -126,6 +132,16 @@ namespace brecal.model
|
||||
username.Value = this.Username;
|
||||
cmd.Parameters.Add(username);
|
||||
|
||||
IDbDataParameter email = cmd.CreateParameter();
|
||||
email.ParameterName = "USEREMAIL";
|
||||
email.Value = this.EMail;
|
||||
cmd.Parameters.Add(email);
|
||||
|
||||
IDbDataParameter phone = cmd.CreateParameter();
|
||||
phone.ParameterName = "USERPHONE";
|
||||
phone.Value = this.Phone;
|
||||
cmd.Parameters.Add(phone);
|
||||
|
||||
IDbDataParameter pwhash = cmd.CreateParameter();
|
||||
pwhash.ParameterName = "PWHASH";
|
||||
pwhash.Value = this.PasswordHash;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user