Naming conventions

This commit is contained in:
Pavel Vesely
2020-03-14 21:52:26 +01:00
parent 7feee22b32
commit ab3f0853a7
15 changed files with 267 additions and 247 deletions

View File

@ -17,7 +17,7 @@
<label class="control-label">Description: </label>
</td>
<td>
<textarea class="form-control" @bind="@description" rows="5" />
<textarea class="form-control" @bind="@description" rows="5"></textarea>
</td>
</tr>
<tr>

View File

@ -9,7 +9,7 @@
<label class="control-label">Name: </label>
</td>
<td>
<input class="form-control" @bind="@name" />
<input class="form-control" @bind="@_name" />
</td>
</tr>
<tr>
@ -17,7 +17,7 @@
<label class="control-label">Description: </label>
</td>
<td>
<textarea class="form-control" @bind="@description" rows="5" />
<textarea class="form-control" @bind="@_description" rows="5"></textarea>
</td>
</tr>
<tr>
@ -25,7 +25,7 @@
<label class="control-label">Auto Assigned? </label>
</td>
<td>
<select class="form-control" @bind="@isautoassigned">
<select class="form-control" @bind="@_isautoassigned">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
@ -36,7 +36,7 @@
<label class="control-label">System Role? </label>
</td>
<td>
<select class="form-control" @bind="@issystem">
<select class="form-control" @bind="@_issystem">
<option value="True">Yes</option>
<option value="False">No</option>
</select>
@ -49,40 +49,40 @@
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
int roleid;
string name = "";
string description = "";
string isautoassigned = "False";
string issystem = "False";
int _roleid;
string _name = "";
string _description = "";
string _isautoassigned = "False";
string _issystem = "False";
protected override async Task OnInitializedAsync()
{
try
{
roleid = Int32.Parse(PageState.QueryString["id"]);
Role role = await RoleService.GetRoleAsync(roleid);
_roleid = Int32.Parse(PageState.QueryString["id"]);
Role role = await RoleService.GetRoleAsync(_roleid);
if (role != null)
{
name = role.Name;
description = role.Description;
isautoassigned = role.IsAutoAssigned.ToString();
issystem = role.IsSystem.ToString();
_name = role.Name;
_description = role.Description;
_isautoassigned = role.IsAutoAssigned.ToString();
_issystem = role.IsSystem.ToString();
}
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", roleid, ex.Message);
await logger.LogError(ex, "Error Loading Role {RoleId} {Error}", _roleid, ex.Message);
AddModuleMessage("Error Loading Role", MessageType.Error);
}
}
private async Task SaveRole()
{
Role role = await RoleService.GetRoleAsync(roleid);
role.Name = name;
role.Description = description;
role.IsAutoAssigned = (isautoassigned == null ? false : Boolean.Parse(isautoassigned));
role.IsSystem = (issystem == null ? false : Boolean.Parse(issystem));
Role role = await RoleService.GetRoleAsync(_roleid);
role.Name = _name;
role.Description = _description;
role.IsAutoAssigned = (_isautoassigned != null && Boolean.Parse(_isautoassigned));
role.IsSystem = (_issystem != null && Boolean.Parse(_issystem));
try
{

View File

@ -2,7 +2,7 @@
@inherits ModuleBase
@inject IRoleService RoleService
@if (Roles == null)
@if (_roles == null)
{
<p><em>Loading...</em></p>
}
@ -10,7 +10,7 @@ else
{
<ActionLink Action="Add" Text="Add Role" />
<Pager Items="@Roles">
<Pager Items="@_roles">
<Header>
<th>&nbsp;</th>
<th>&nbsp;</th>
@ -27,25 +27,25 @@ else
@code {
public override SecurityAccessLevel SecurityAccessLevel { get { return SecurityAccessLevel.Admin; } }
List<Role> Roles;
List<Role> _roles;
protected override async Task OnParametersSetAsync()
{
Roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
_roles = await RoleService.GetRolesAsync(PageState.Site.SiteId);
}
private async Task DeleteRole(Role Role)
private async Task DeleteRole(Role role)
{
try
{
await RoleService.DeleteRoleAsync(Role.RoleId);
await logger.LogInformation("Role Deleted {Role}", Role);
await RoleService.DeleteRoleAsync(role.RoleId);
await logger.LogInformation("Role Deleted {Role}", role);
StateHasChanged();
}
catch (Exception ex)
{
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", Role, ex.Message);
await logger.LogError(ex, "Error Deleting Role {Role} {Error}", role, ex.Message);
AddModuleMessage("Error Deleting Role", MessageType.Error);
}
}
}
}