Skip to content

Commit

Permalink
added interceptor to main component . removed others. #20
Browse files Browse the repository at this point in the history
  • Loading branch information
iammukeshm committed Mar 19, 2021
1 parent 34278cc commit cdfacd2
Show file tree
Hide file tree
Showing 17 changed files with 87 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Catalog
{
public partial class AddEditBrandModal : IDisposable
public partial class AddEditBrandModal
{
private bool success;
private string[] errors = { };
Expand All @@ -29,11 +29,6 @@ public partial class AddEditBrandModal : IDisposable
public string Description { get; set; }

[CascadingParameter] private MudDialogInstance MudDialog { get; set; }
protected override void OnInitialized()
{
_interceptor.RegisterEvent();
}
public void Dispose() => _interceptor.DisposeEvent();
public void Cancel()
{
MudDialog.Cancel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Catalog
{
public partial class AddEditProductModal : IDisposable
public partial class AddEditProductModal
{
private bool success;
private string[] errors = { };
Expand Down Expand Up @@ -81,10 +81,8 @@ private async Task SaveAsync()

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await LoadDataAsync();
}
public void Dispose() => _interceptor.DisposeEvent();

private async Task LoadDataAsync()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,15 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Catalog
{
public partial class Brands : IDisposable
public partial class Brands
{
public List<GetAllBrandsResponse> BrandList = new List<GetAllBrandsResponse>();
private GetAllBrandsResponse brand = new GetAllBrandsResponse();
private string searchString = "";

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await GetBrandsAsync();
}
public void Dispose() => _interceptor.DisposeEvent();

private async Task GetBrandsAsync()
{
var response = await _brandManager.GetAllAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,14 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Catalog
{
public partial class Products : IDisposable
public partial class Products
{
private IEnumerable<GetAllPagedProductsResponse> pagedData;
private MudTable<GetAllPagedProductsResponse> table;

private int totalItems;
private int currentPage;
private string searchString = null;

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await Task.CompletedTask;
}

public void Dispose() => _interceptor.DisposeEvent();
private async Task<TableData<GetAllPagedProductsResponse>> ServerReload(TableState state)
{
await LoadData(state.Page, state.PageSize);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Content
{
public partial class Dashboard : IDisposable
public partial class Dashboard
{
[Parameter]
public int ProductCount { get; set; }
Expand All @@ -19,12 +19,9 @@ public partial class Dashboard : IDisposable

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await LoadDataAsync();
}

public void Dispose() => _interceptor.DisposeEvent();

private async Task LoadDataAsync()
{
var data = await _dashboardManager.GetDataAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,8 @@ private async Task UpdateProfileAsync()

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await LoadDataAsync();
}
public void Dispose() => _interceptor.DisposeEvent();

private async Task LoadDataAsync()
{
var state = await _stateProvider.GetAuthenticationStateAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class RegisterUserModal : IDisposable
public partial class RegisterUserModal
{
private bool success;
private string[] errors = { };
Expand Down Expand Up @@ -52,33 +52,6 @@ public void Cancel()
{
MudDialog.Cancel();
}
[Parameter]
public int ProductCount { get; set; }
[Parameter]
public int BrandCount { get; set; }
[Parameter]
public int UserCount { get; set; }
[Parameter]
public int RoleCount { get; set; }

protected override void OnInitialized()
{
_interceptor.RegisterEvent();
}

public void Dispose() => _interceptor.DisposeEvent();

private async Task LoadDataAsync()
{
var data = await _dashboardManager.GetDataAsync();
if (data.Succeeded)
{
ProductCount = data.Data.ProductCount;
BrandCount = data.Data.BrandCount;
UserCount = data.Data.UserCount;
RoleCount = data.Data.RoleCount;
}
}
private async Task SaveAsync()
{
form.Validate();
Expand Down Expand Up @@ -111,7 +84,6 @@ private async Task SaveAsync()
}
}
}

private IEnumerable<string> PasswordStrength(string pw)
{
if (string.IsNullOrWhiteSpace(pw))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class RoleModal : IDisposable
public partial class RoleModal
{
private bool success;
private string[] errors = { };
Expand All @@ -26,11 +26,6 @@ public void Cancel()
{
MudDialog.Cancel();
}
protected override void OnInitialized()
{
_interceptor.RegisterEvent();
}
public void Dispose() => _interceptor.DisposeEvent();
private async Task SaveAsync()
{
form.Validate();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class RolePermissions : IDisposable
public partial class RolePermissions
{
[Parameter]
public string Id { get; set; }
Expand All @@ -25,7 +25,6 @@ public partial class RolePermissions : IDisposable

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
_mapper = new MapperConfiguration(c => { c.AddProfile<RoleProfile>(); }).CreateMapper();
var roleId = Id;
var result = await _roleManager.GetPermissionsAsync(roleId);
Expand All @@ -38,7 +37,6 @@ protected override async Task OnInitializedAsync()
}
}
}
public void Dispose() => _interceptor.DisposeEvent();
private async Task SaveAsync()
{
var request = _mapper.Map<PermissionResponse, PermissionRequest>(model);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,19 +7,16 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class Roles : IDisposable
public partial class Roles
{
public List<RoleResponse> RoleList = new List<RoleResponse>();
private RoleResponse role = new RoleResponse();
private string searchString = "";

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await GetRolesAsync();
}
public void Dispose() => _interceptor.DisposeEvent();

private async Task GetRolesAsync()
{
var response = await _roleManager.GetRolesAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,24 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class Security : IDisposable
public partial class Security
{
[Inject] private Microsoft.Extensions.Localization.IStringLocalizer<Security> localizer { get; set; }

private readonly ChangePasswordRequest passwordModel = new ChangePasswordRequest();

protected override void OnInitialized()
{
_interceptor.RegisterEvent();
}
public void Dispose() => _interceptor.DisposeEvent();

private async Task ChangePasswordAsync()
{
var response = await _accountManager.ChangePasswordAsync(passwordModel);
if(response.Succeeded)
if (response.Succeeded)
{
_snackBar.Add("Password Changed!",Severity.Success);
_snackBar.Add("Password Changed!", Severity.Success);
passwordModel.Password = string.Empty;
passwordModel.NewPassword = string.Empty;
passwordModel.ConfirmNewPassword = string.Empty;
}
else
{
foreach(var error in response.Messages)
foreach (var error in response.Messages)
{
_snackBar.Add(error, Severity.Error);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class UserProfile : IDisposable
public partial class UserProfile
{
[Parameter]
public string Id { get; set; }
Expand Down Expand Up @@ -48,10 +48,8 @@ private async Task ToggleUserStatus()

[Parameter]
public string ImageDataUrl { get; set; }
public void Dispose() => _interceptor.DisposeEvent();
protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
var userId = Id;
var result = await _userManager.GetAsync(userId);
if (result.Succeeded)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class UserRoles : IDisposable
public partial class UserRoles
{
[Parameter]
public string Id { get; set; }
Expand All @@ -25,7 +25,6 @@ public partial class UserRoles : IDisposable

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
CurrentUser = await _authenticationManager.CurrentUser();

var userId = Id;
Expand All @@ -42,7 +41,6 @@ protected override async Task OnInitializedAsync()
}
}
}
public void Dispose() => _interceptor.DisposeEvent();
private async Task SaveAsync()
{
var request = new UpdateUserRolesRequest()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,16 @@

namespace BlazorHero.CleanArchitecture.Client.Pages.Identity
{
public partial class Users : IDisposable
public partial class Users
{
public List<UserResponse> UserList = new List<UserResponse>();
private UserResponse user = new UserResponse();
private string searchString = "";

protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await GetUsersAsync();
}
public void Dispose() => _interceptor.DisposeEvent();
private async Task GetUsersAsync()
{
var response = await _userManager.GetAllAsync();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

namespace BlazorHero.CleanArchitecture.Client.Shared.Components
{
public partial class UserCard : IDisposable
public partial class UserCard
{
[Parameter] public string Class { get; set; }
private string FirstName { get; set; }
Expand All @@ -19,10 +19,8 @@ public partial class UserCard : IDisposable
public string ImageDataUrl { get; set; }
protected override async Task OnInitializedAsync()
{
_interceptor.RegisterEvent();
await LoadDataAsync();
}
public void Dispose() => _interceptor.DisposeEvent();
private async Task LoadDataAsync()
{
var state = await _stateProvider.GetAuthenticationStateAsync();
Expand Down
Loading

0 comments on commit cdfacd2

Please sign in to comment.