Simplified User Delete page

This commit is contained in:
Emanuele Filardo 2019-10-08 11:23:22 +02:00
parent 7b4eee4d0c
commit 5fd4d69034

View File

@ -5,7 +5,7 @@
@inject IProfileService ProfileService
@inject ISettingService SettingService
@if (profiles != null)
@if (!string.IsNullOrWhiteSpace(username))
{
<table class="table table-borderless">
<tr>
@ -13,7 +13,7 @@
<label for="Name" class="control-label">Username: </label>
</td>
<td>
<input class="form-control" @bind="@username" readonly />
<input class="form-control" @bind="@username" disabled />
</td>
</tr>
<tr>
@ -21,7 +21,7 @@
<label for="Name" class="control-label">Email: </label>
</td>
<td>
<input class="form-control" @bind="@email" readonly />
<input class="form-control" @bind="@email" disabled />
</td>
</tr>
<tr>
@ -29,34 +29,26 @@
<label for="Name" class="control-label">Full Name: </label>
</td>
<td>
<input class="form-control" @bind="@displayname" readonly />
<input class="form-control" @bind="@displayname" disabled />
</td>
</tr>
<tr>
<td>
<label for="Name" class="control-label">Is Deleted? </label>
</td>
<td>
<select class="form-control" @bind="@isdeleted" disabled>
<option value="True">Yes</option>
<option value="False">No</option>
</select>
</td>
</tr>
@foreach (Profile profile in profiles)
{
var p = profile;
if (p.Category != category)
{
<tr>
<th colspan="2" style="text-align: center;">
@p.Category
</th>
</tr>
category = p.Category;
}
<tr>
<td>
<label for="@p.Name" class="control-label">@p.Title: </label>
</td>
<td>
<input class="form-control" maxlength="@p.MaxLength" value="@GetProfileValue(p.Name, p.DefaultValue)" readonly />
</td>
</tr>
}
</table>
<button type="button" class="btn btn-primary" @onclick="DeleteUser">Delete</button>
<NavLink class="btn btn-secondary" href="@NavigateUrl()">Cancel</NavLink>
<br />
<br />
<AuditInfo CreatedBy="@createdby" CreatedOn="@createdon" ModifiedBy="@modifiedby" ModifiedOn="@modifiedon" DeletedBy="@deletedby" DeletedOn="@deletedon"></AuditInfo>
}
@code {
@ -66,16 +58,19 @@
string username = "";
string email = "";
string displayname = "";
List<Profile> profiles;
Dictionary<string, string> settings;
string category = "";
string createdby;
DateTime createdon;
string modifiedby;
DateTime modifiedon;
string deletedby;
DateTime? deletedon;
string isdeleted;
protected override async Task OnInitializedAsync()
{
try
{
profiles = await ProfileService.GetProfilesAsync(PageState.Site.SiteId);
userid = Int32.Parse(PageState.QueryString["id"]);
User user = await UserService.GetUserAsync(userid, PageState.Site.SiteId);
if (user != null)
@ -83,7 +78,13 @@
username = user.Username;
email = user.Email;
displayname = user.DisplayName;
settings = await SettingService.GetUserSettingsAsync(user.UserId);
createdby = user.CreatedBy;
createdon = user.CreatedOn;
modifiedby = user.ModifiedBy;
modifiedon = user.ModifiedOn;
deletedby = user.DeletedBy;
deletedon = user.DeletedOn;
isdeleted = user.IsDeleted.ToString();
}
}
catch (Exception ex)
@ -92,11 +93,6 @@
}
}
private string GetProfileValue(string SettingName, string DefaultValue)
{
return SettingService.GetSetting(settings, SettingName, DefaultValue);
}
private async Task DeleteUser()
{
try