diff --git a/docker-compose.dcproj b/docker-compose.dcproj index 7a1657f92..caaff1ac8 100644 --- a/docker-compose.dcproj +++ b/docker-compose.dcproj @@ -27,4 +27,7 @@ + + + \ No newline at end of file diff --git a/src/Application/Application.csproj b/src/Application/Application.csproj index b04918fe2..18c239501 100644 --- a/src/Application/Application.csproj +++ b/src/Application/Application.csproj @@ -17,8 +17,6 @@ - - diff --git a/src/Application/Common/Behaviours/ValidationBehaviour.cs b/src/Application/Common/Behaviours/ValidationBehaviour.cs index 424bd23c9..cfbe6bb9d 100644 --- a/src/Application/Common/Behaviours/ValidationBehaviour.cs +++ b/src/Application/Common/Behaviours/ValidationBehaviour.cs @@ -1,9 +1,6 @@ // Licensed to the .NET Foundation under one or more agreements. // The .NET Foundation licenses this file to you under the MIT license. -using Fluxor; -using System; - namespace CleanArchitecture.Blazor.Application.Common.Behaviours; public class ValidationBehaviour : IPipelineBehavior diff --git a/src/Application/DependencyInjection.cs b/src/Application/DependencyInjection.cs index 4638f4141..14446b9ec 100644 --- a/src/Application/DependencyInjection.cs +++ b/src/Application/DependencyInjection.cs @@ -33,10 +33,6 @@ public static IServiceCollection AddApplicationServices(this IServiceCollection }); - services.AddFluxor(options => { - options.ScanAssemblies(Assembly.GetExecutingAssembly()); - options.UseReduxDevTools(); - }); services.AddLazyCache(); services.AddScoped(); services.AddScoped(sp => { diff --git a/src/Application/Features/Fluxor/Reducers.cs b/src/Application/Features/Fluxor/Reducers.cs deleted file mode 100644 index af59c2ec2..000000000 --- a/src/Application/Features/Fluxor/Reducers.cs +++ /dev/null @@ -1,12 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CleanArchitecture.Blazor.Application.Features.Fluxor; -public static class Reducers -{ - [ReducerMethod] - public static UserProfileState ReduceUserProfileUpdateAction(UserProfileState state, UserProfileUpdateAction action) => new(action.UserProfile); -} diff --git a/src/Application/Features/Fluxor/UserProfileState.cs b/src/Application/Features/Fluxor/UserProfileState.cs deleted file mode 100644 index 26ae15f88..000000000 --- a/src/Application/Features/Fluxor/UserProfileState.cs +++ /dev/null @@ -1,40 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using CleanArchitecture.Blazor.Application.Features.Identity.Dto; - -namespace CleanArchitecture.Blazor.Application.Features.Fluxor; -[FeatureState] -public class UserProfileState -{ - public UserProfile UserProfile { get; } - public UserProfileState() - { - UserProfile = new() { Email= string.Empty, UserId=string.Empty,UserName= string.Empty }; - } - public UserProfileState(UserProfile userProfile) - { - UserProfile = userProfile; - } - public UserProfileState(ApplicationUserDto dto) - { - UserProfile = new UserProfile() - { - UserId = dto.Id, - ProfilePictureDataUrl = dto.ProfilePictureDataUrl, - Email = dto.Email, - PhoneNumber = dto.PhoneNumber, - DisplayName = dto.DisplayName, - Provider = dto.Provider, - UserName = dto.UserName, - TenantId = dto.TenantId, - TenantName = dto.TenantName, - SuperiorId = dto.SuperiorId, - SuperiorName = dto.SuperiorName, - AssignedRoles = dto.AssignedRoles, - DefaultRole = dto.DefaultRole - }; - } -} diff --git a/src/Application/Features/Fluxor/UserProfileUpdateAction.cs b/src/Application/Features/Fluxor/UserProfileUpdateAction.cs deleted file mode 100644 index b7b22843c..000000000 --- a/src/Application/Features/Fluxor/UserProfileUpdateAction.cs +++ /dev/null @@ -1,11 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace CleanArchitecture.Blazor.Application.Features.Fluxor; -public class UserProfileUpdateAction -{ - public required UserProfile UserProfile { get; set; } -} diff --git a/src/Application/Features/Identity/Notification/UpdateUserProfileCommand.cs b/src/Application/Features/Identity/Notification/UpdateUserProfileCommand.cs new file mode 100644 index 000000000..6cb7fa00a --- /dev/null +++ b/src/Application/Features/Identity/Notification/UpdateUserProfileCommand.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace CleanArchitecture.Blazor.Application.Features.Identity.Notification; +public class UpdateUserProfileCommand:INotification +{ + public UserProfile UserProfile { get; set; } = null!; +} +public class UpdateUserProfileEventArgs : EventArgs +{ + public UserProfile UserProfile { get; set; } = null!; +} diff --git a/src/Application/_Imports.cs b/src/Application/_Imports.cs index 9c3046cc6..ba057e1a9 100644 --- a/src/Application/_Imports.cs +++ b/src/Application/_Imports.cs @@ -1,5 +1,4 @@ global using MediatR; -global using Fluxor; global using MediatR.Pipeline; global using LazyCache; global using Microsoft.Extensions.Localization; diff --git a/src/Blazor.Server.UI/App.razor b/src/Blazor.Server.UI/App.razor index 247a224c4..961969357 100644 --- a/src/Blazor.Server.UI/App.razor +++ b/src/Blazor.Server.UI/App.razor @@ -1,7 +1,6 @@ @inject IStringLocalizer L - diff --git a/src/Blazor.Server.UI/Components/Shared/SideMenu.razor b/src/Blazor.Server.UI/Components/Shared/SideMenu.razor index 915a59d47..da2136d28 100644 --- a/src/Blazor.Server.UI/Components/Shared/SideMenu.razor +++ b/src/Blazor.Server.UI/Components/Shared/SideMenu.razor @@ -1,7 +1,6 @@ @using Blazor.Server.UI.Models.SideMenu @inject IStringLocalizer L -@inherits FluxorComponent - @if (string.IsNullOrEmpty(UserProfile.ProfilePictureDataUrl)) + @if (string.IsNullOrEmpty(UserProfile?.ProfilePictureDataUrl)) { - @UserProfile.UserName.ToUpper().FirstOrDefault() + @UserProfile?.UserName.ToUpper().FirstOrDefault() } else { - + } - @UserProfile.DisplayName - @UserProfile.DefaultRole + @UserProfile?.DisplayName + @UserProfile?.DefaultRole @@ -47,7 +46,7 @@ else {
- +
} diff --git a/src/Blazor.Server.UI/Components/Shared/SideMenu.razor.cs b/src/Blazor.Server.UI/Components/Shared/SideMenu.razor.cs index 248edaa03..f0fb8ea63 100644 --- a/src/Blazor.Server.UI/Components/Shared/SideMenu.razor.cs +++ b/src/Blazor.Server.UI/Components/Shared/SideMenu.razor.cs @@ -1,15 +1,14 @@ using Blazor.Server.UI.Models.SideMenu; using Blazor.Server.UI.Services; using Blazor.Server.UI.Services.Navigation; - +using CleanArchitecture.Blazor.Application.Features.Identity.Notification; namespace Blazor.Server.UI.Components.Shared; -public partial class SideMenu +public partial class SideMenu:INotificationHandler { - [Inject] - private IState UserProfileState { get; set; } = null!; - private UserProfile UserProfile => UserProfileState.Value.UserProfile; + + private UserProfile? UserProfile { get; set; } = null!; [EditorRequired] [Parameter] public bool SideMenuDrawerOpen { get; set; } @@ -24,7 +23,21 @@ [EditorRequired] [Parameter] [Inject] private LayoutService LayoutService { get; set; } = default!; - private string[] _roles => UserProfile.AssignedRoles??new string[] { }; + private string[] _roles => UserProfile?.AssignedRoles??new string[] { }; - + protected override void OnInitialized() + { + UserProfileChanged += (s, e) => + { + UserProfile = e.UserProfile; + InvokeAsync(() => StateHasChanged()); + }; + } + + public static event EventHandler UserProfileChanged=null!; + public Task Handle(UpdateUserProfileCommand notification, CancellationToken cancellationToken) + { + UserProfileChanged?.Invoke(this, new UpdateUserProfileEventArgs() { UserProfile = notification.UserProfile }); + return Task.CompletedTask; + } } \ No newline at end of file diff --git a/src/Blazor.Server.UI/Components/Shared/UserMenu.razor b/src/Blazor.Server.UI/Components/Shared/UserMenu.razor index 7ea78cf10..43424c24c 100644 --- a/src/Blazor.Server.UI/Components/Shared/UserMenu.razor +++ b/src/Blazor.Server.UI/Components/Shared/UserMenu.razor @@ -1,7 +1,6 @@ @using CleanArchitecture.Blazor.Infrastructure.Services.JWT; @inject IStringLocalizer L @inject TokenAuthProvider TokenProvider -@inherits FluxorComponent - @if (string.IsNullOrEmpty(UserProfile.ProfilePictureDataUrl)) + @if (string.IsNullOrEmpty(UserProfile?.ProfilePictureDataUrl)) { - @UserProfile.UserName.ToUpper().FirstOrDefault() + @UserProfile?.UserName.ToUpper().FirstOrDefault() } else { - + } - @UserProfile.DisplayName - @UserProfile.Email + @UserProfile?.DisplayName + @UserProfile?.Email diff --git a/src/Blazor.Server.UI/Components/Shared/UserMenu.razor.cs b/src/Blazor.Server.UI/Components/Shared/UserMenu.razor.cs index 299bdf14f..bfaf0792a 100644 --- a/src/Blazor.Server.UI/Components/Shared/UserMenu.razor.cs +++ b/src/Blazor.Server.UI/Components/Shared/UserMenu.razor.cs @@ -1,15 +1,15 @@ using Blazor.Server.UI.Components.Dialogs; +using CleanArchitecture.Blazor.Application.Features.Identity.Notification; using Microsoft.AspNetCore.Components.Web; namespace Blazor.Server.UI.Components.Shared; -public partial class UserMenu +public partial class UserMenu:INotificationHandler { - [Inject] - private IState UserProfileState { get; set; } = null!; - private UserProfile UserProfile => UserProfileState.Value.UserProfile; + + private UserProfile? UserProfile { get; set; } = null!; [Parameter] public EventCallback OnSettingClick { get; set; } [Inject] protected NavigationManager NavigationManager { get; set; } = null!; @@ -29,5 +29,20 @@ private async Task OnLogout() await TokenProvider.RemoveAuthDataFromStorage(); NavigationManager.NavigateTo("/", true); } - } + } + protected override void OnInitialized() + { + UserProfileChanged += (s, e) => + { + UserProfile = e.UserProfile; + InvokeAsync(() => StateHasChanged()); + }; + } + + public static event EventHandler UserProfileChanged = null!; + public Task Handle(UpdateUserProfileCommand notification, CancellationToken cancellationToken) + { + UserProfileChanged?.Invoke(this, new UpdateUserProfileEventArgs() { UserProfile = notification.UserProfile }); + return Task.CompletedTask; + } } \ No newline at end of file diff --git a/src/Blazor.Server.UI/ConfigureServices.cs b/src/Blazor.Server.UI/ConfigureServices.cs index bd015e29a..581b5bbb9 100644 --- a/src/Blazor.Server.UI/ConfigureServices.cs +++ b/src/Blazor.Server.UI/ConfigureServices.cs @@ -9,6 +9,8 @@ using MudBlazor.Services; using Toolbelt.Blazor.Extensions.DependencyInjection; using MudExtensions.Services; +using CleanArchitecture.Blazor.Application.Features.Identity.Notification; +using Blazor.Server.UI.Components.Shared; namespace Blazor.Server.UI; @@ -69,6 +71,8 @@ public static IServiceCollection AddBlazorUIServices(this IServiceCollection ser services.AddScoped(); services.AddGoogleAnalytics("G-PRYNCB61NV"); services.AddHealthChecks(); + services.AddScoped, SideMenu>(); + services.AddScoped, UserMenu>(); return services; } } diff --git a/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor b/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor index 875e84e1c..52c0e365b 100644 --- a/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor +++ b/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor @@ -1,6 +1,5 @@ @page "/user/profile" @using CleanArchitecture.Blazor.Application.Common.Interfaces.Identity -@using Fluxor.UnsupportedClasses; @using SixLabors.ImageSharp @using SixLabors.ImageSharp.Formats @using SixLabors.ImageSharp.Processing @@ -155,152 +154,4 @@ -@code { - [Inject] - private IState UserProfileState { get; set; } = null!; - [Inject] - private IDispatcher Dispatcher { get; set; } = null!; - private MudForm? _form = null!; - private MudForm? _passwordform = null!; - public string Title { get; set; } = "Profile"; - private bool submitting; - [CascadingParameter] - private Task _authState { get; set; } = default!; - [Inject] private IUploadService _uploadService { get; set; } = default!; - - private UserProfile model => UserProfileState.Value.UserProfile; - private UserProfileEditValidator _userValidator = new(); - private UserManager _userManager { get; set; } = default!; - [Inject] - private IIdentityService _identityService { get; set; } = default!; - public string Id => Guid.NewGuid().ToString(); - - public void ReRender() => StateHasChanged(); - - private ChangePasswordModel _changepassword { get; set; } = new(); - private ChangePasswordModelValidator _passwordValidator = new(); - private List _orgData = new(); - - - private async void ActivePanelIndexChanged(int index) - { - if(index==2){ - await LoadOrgData(); - await JS.InvokeVoidAsync("createOrgChart", this._orgData); - } - } - private async Task LoadOrgData() - { - var currerntuserName = (await _authState).User.GetUserName(); - var list = await _userManager.Users.Include(x => x.UserRoles).ThenInclude(x=>x.Role).Include(x => x.Superior).ToListAsync(); - foreach (var item in list) - { - var roles = await _userManager.GetRolesAsync(item); - var count = await _userManager.Users.Where(x => x.SuperiorId == item.Id).CountAsync(); - var orgitem = new OrgItem(); - orgitem.id = item.Id; - orgitem.name = item.DisplayName ?? item.UserName; - orgitem.area = item.TenantName; - orgitem.profileUrl = item.ProfilePictureDataUrl; - orgitem.imageUrl = item.ProfilePictureDataUrl; - if (currerntuserName == item.UserName) - orgitem.isLoggedUser = true; - orgitem.size = ""; - orgitem.tags = item.PhoneNumber ?? item.Email; - if (roles != null && roles.Count > 0) - orgitem.positionName = string.Join(',', roles); - orgitem.parentId = item.SuperiorId; - - orgitem._directSubordinates = count; - this._orgData.Add(orgitem); - } - - } - - protected override Task OnInitializedAsync() - { - _userManager = ScopedServices.GetRequiredService>(); - return base.OnInitializedAsync(); - - } - private async Task UploadPhoto(InputFileChangeEventArgs e) - { - var filestream = e.File.OpenReadStream(GlobalVariable.maxAllowedSize); - var imgstream = new MemoryStream(); - await filestream.CopyToAsync(imgstream); - imgstream.Position = 0; - using (var outStream = new MemoryStream()) - { - using (var image = Image.Load(imgstream)) - { - image.Mutate( - i => i.Resize(new ResizeOptions() { Mode = SixLabors.ImageSharp.Processing.ResizeMode.Crop, Size = new SixLabors.ImageSharp.Size(128, 128) })); - image.Save(outStream, SixLabors.ImageSharp.Formats.Png.PngFormat.Instance); - var filename = e.File.Name; - var fi = new FileInfo(filename); - var ext = fi.Extension; - var result = await _uploadService.UploadAsync(new UploadRequest(Guid.NewGuid().ToString() + ext, UploadType.ProfilePicture, outStream.ToArray())); - model.ProfilePictureDataUrl = result; - var user = await _userManager.FindByIdAsync(model.UserId!); - user!.ProfilePictureDataUrl = model.ProfilePictureDataUrl; - await _userManager.UpdateAsync(user); - Snackbar.Add(L["The avatar has been updated."], MudBlazor.Severity.Info); - Dispatcher.Dispatch(new UserProfileUpdateAction() { UserProfile = model }); - - } - } - } - private async Task Submit() - { - submitting=true; - try { - await _form!.Validate(); - if (_form.IsValid) - { - var state = await _authState; - var user = await _userManager.FindByIdAsync(model.UserId!); - user!.PhoneNumber = model.PhoneNumber; - user.DisplayName = model.DisplayName; - user.ProfilePictureDataUrl = model.ProfilePictureDataUrl; - await _userManager.UpdateAsync(user); - Snackbar.Add($"{ConstantString.UPDATESUCCESS}", MudBlazor.Severity.Info); - Dispatcher.Dispatch(new UserProfileUpdateAction() { UserProfile = model }); - } - } - finally - { - submitting = false; - } - - } - private async Task ChangePassword() - { - submitting=true; - try - { - await _passwordform!.Validate(); - if (_passwordform!.IsValid) - { - var user = await _userManager.FindByIdAsync(model.UserId!); - var result = await _userManager.ChangePasswordAsync(user!, _changepassword.CurrentPassword, _changepassword.NewPassword); - if (result.Succeeded) - { - Snackbar.Add($"{L["Changed password successfully."]}", MudBlazor.Severity.Info); - } - else - { - Snackbar.Add($"{string.Join(",", result.Errors.Select(x => x.Description).ToArray())}", MudBlazor.Severity.Error); - } - } - } - finally - { - submitting = false; - } - - } - - - -} diff --git a/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor.cs b/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor.cs new file mode 100644 index 000000000..408cb72dd --- /dev/null +++ b/src/Blazor.Server.UI/Pages/Identity/Users/Profile.razor.cs @@ -0,0 +1,155 @@ +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Identity; +using Microsoft.JSInterop; +using CleanArchitecture.Blazor.Application.Common.Interfaces.Identity; +using CleanArchitecture.Blazor.Application.Features.Identity.Notification; + +namespace Blazor.Server.UI.Pages.Identity.Users +{ + public partial class Profile + { + + [Inject] + private IMediator _mediator { get; set; } = default!; + [Inject] + private ICurrentUserService _currentUser { get; set; } = null!; + private MudForm? _form = null !; + private MudForm? _passwordform = null !; + public string Title { get; set; } = "Profile"; + private bool submitting; + [CascadingParameter] + private Task _authState { get; set; } = default !; + [Inject] + private IUploadService _uploadService { get; set; } = default !; + private UserProfile model { get; set; } = null!; + private UserProfileEditValidator _userValidator = new(); + private UserManager _userManager { get; set; } = default !; + [Inject] + private IIdentityService _identityService { get; set; } = default !; + public string Id => Guid.NewGuid().ToString(); + private ChangePasswordModel _changepassword { get; set; } = new(); + private ChangePasswordModelValidator _passwordValidator = new(); + private List _orgData = new(); + + + private async void ActivePanelIndexChanged(int index) + { + if (index == 2) + { + await LoadOrgData(); + await JS.InvokeVoidAsync("createOrgChart", this._orgData); + } + } + + private async Task LoadOrgData() + { + var currerntuserName = (await _authState).User.GetUserName(); + var list = await _userManager.Users.Include(x => x.UserRoles).ThenInclude(x => x.Role).Include(x => x.Superior).ToListAsync(); + foreach (var item in list) + { + var roles = await _userManager.GetRolesAsync(item); + var count = await _userManager.Users.Where(x => x.SuperiorId == item.Id).CountAsync(); + var orgitem = new OrgItem(); + orgitem.id = item.Id; + orgitem.name = item.DisplayName ?? item.UserName; + orgitem.area = item.TenantName; + orgitem.profileUrl = item.ProfilePictureDataUrl; + orgitem.imageUrl = item.ProfilePictureDataUrl; + if (currerntuserName == item.UserName) + orgitem.isLoggedUser = true; + orgitem.size = ""; + orgitem.tags = item.PhoneNumber ?? item.Email; + if (roles != null && roles.Count > 0) + orgitem.positionName = string.Join(',', roles); + orgitem.parentId = item.SuperiorId; + orgitem._directSubordinates = count; + this._orgData.Add(orgitem); + } + } + + protected override async Task OnInitializedAsync() + { + _userManager = ScopedServices.GetRequiredService>(); + var userDto = await _identityService.GetApplicationUserDto(_currentUser.UserId); + this.model = userDto.ToUserProfile(); + } + + private async Task UploadPhoto(InputFileChangeEventArgs e) + { + var filestream = e.File.OpenReadStream(GlobalVariable.maxAllowedSize); + var imgstream = new MemoryStream(); + await filestream.CopyToAsync(imgstream); + imgstream.Position = 0; + using (var outStream = new MemoryStream()) + { + using (var image = Image.Load(imgstream)) + { + image.Mutate(i => i.Resize(new ResizeOptions() { Mode = SixLabors.ImageSharp.Processing.ResizeMode.Crop, Size = new SixLabors.ImageSharp.Size(128, 128) })); + image.Save(outStream, SixLabors.ImageSharp.Formats.Png.PngFormat.Instance); + var filename = e.File.Name; + var fi = new FileInfo(filename); + var ext = fi.Extension; + var result = await _uploadService.UploadAsync(new UploadRequest(Guid.NewGuid().ToString() + ext, UploadType.ProfilePicture, outStream.ToArray())); + model.ProfilePictureDataUrl = result; + var user = await _userManager.FindByIdAsync(model.UserId!); + user!.ProfilePictureDataUrl = model.ProfilePictureDataUrl; + await _userManager.UpdateAsync(user); + Snackbar.Add(L["The avatar has been updated."], MudBlazor.Severity.Info); + await _mediator.Publish(new UpdateUserProfileCommand() { UserProfile = model }); + } + } + } + + private async Task Submit() + { + submitting = true; + try + { + await _form!.Validate(); + if (_form.IsValid) + { + var state = await _authState; + var user = await _userManager.FindByIdAsync(model.UserId!); + user!.PhoneNumber = model.PhoneNumber; + user.DisplayName = model.DisplayName; + user.ProfilePictureDataUrl = model.ProfilePictureDataUrl; + await _userManager.UpdateAsync(user); + Snackbar.Add($"{ConstantString.UPDATESUCCESS}", MudBlazor.Severity.Info); + await _mediator.Publish(new UpdateUserProfileCommand() { UserProfile = model }); + } + } + finally + { + submitting = false; + } + } + + private async Task ChangePassword() + { + submitting = true; + try + { + await _passwordform!.Validate(); + if (_passwordform!.IsValid) + { + var user = await _userManager.FindByIdAsync(model.UserId!); + var result = await _userManager.ChangePasswordAsync(user!, _changepassword.CurrentPassword, _changepassword.NewPassword); + if (result.Succeeded) + { + Snackbar.Add($"{L["Changed password successfully."]}", MudBlazor.Severity.Info); + } + else + { + Snackbar.Add($"{string.Join(",", result.Errors.Select(x => x.Description).ToArray())}", MudBlazor.Severity.Error); + } + } + } + finally + { + submitting = false; + } + } + + } +} \ No newline at end of file diff --git a/src/Blazor.Server.UI/Shared/UserLoginState.razor b/src/Blazor.Server.UI/Shared/UserLoginState.razor index 109d0accf..1395bf993 100644 --- a/src/Blazor.Server.UI/Shared/UserLoginState.razor +++ b/src/Blazor.Server.UI/Shared/UserLoginState.razor @@ -1,9 +1,9 @@ @using CleanArchitecture.Blazor.Application.Common.Interfaces.Identity @using CleanArchitecture.Blazor.Application.Common.Interfaces.MultiTenant; @using CleanArchitecture.Blazor.Application.Features.Identity.Dto +@using CleanArchitecture.Blazor.Application.Features.Identity.Notification; @using CleanArchitecture.Blazor.Infrastructure.Hubs -@inherits FluxorComponent @implements IAsyncDisposable @code{ [CascadingParameter] @@ -16,7 +16,7 @@ private IIdentityService _identityService { get; set; }=default!; [Inject] - public IDispatcher Dispatcher { get; set; } = null!; + private IMediator _mediator { get; set; } = default!; public async ValueTask DisposeAsync() { @@ -55,10 +55,10 @@ } }); } - private Task setProfile(ApplicationUserDto userDto) + private async Task setProfile(ApplicationUserDto userDto) { - Dispatcher.Dispatch(new UserProfileUpdateAction() { UserProfile=userDto.ToUserProfile()}); - return Task.CompletedTask; + await _mediator.Publish(new UpdateUserProfileCommand() { UserProfile = userDto.ToUserProfile() }); + } private void _client_Login(object? sender, string username) { diff --git a/src/Blazor.Server.UI/_Imports.cs b/src/Blazor.Server.UI/_Imports.cs index 40a1d28a0..42e1fb3bc 100644 --- a/src/Blazor.Server.UI/_Imports.cs +++ b/src/Blazor.Server.UI/_Imports.cs @@ -1,6 +1,4 @@ global using MediatR; -global using Fluxor; -global using Fluxor.Blazor.Web.Components; global using Microsoft.Extensions.Localization; global using AutoMapper; global using AutoMapper.QueryableExtensions; @@ -26,7 +24,6 @@ global using CleanArchitecture.Blazor.Application.Common.Exceptions; global using CleanArchitecture.Blazor.Infrastructure.Extensions; global using CleanArchitecture.Blazor.Application.Constants; -global using CleanArchitecture.Blazor.Application.Features.Fluxor; global using Microsoft.AspNetCore.Components; global using MudBlazor; diff --git a/src/Blazor.Server.UI/_Imports.razor b/src/Blazor.Server.UI/_Imports.razor index a835afe25..eb574ea68 100644 --- a/src/Blazor.Server.UI/_Imports.razor +++ b/src/Blazor.Server.UI/_Imports.razor @@ -29,14 +29,11 @@ @using CleanArchitecture.Blazor.Application.Common.Models @using CleanArchitecture.Blazor.Infrastructure.Extensions @using CleanArchitecture.Blazor.Infrastructure.Constants -@using CleanArchitecture.Blazor.Application.Features.Fluxor @using Blazor.Server.UI.Components.Common @using Blazor.Server.UI.Components.Dialogs @using Blazor.Server.UI.Pages.Authentication @using MudExtensions @using MudExtensions.Enums -@using Fluxor -@using Fluxor.Blazor.Web.Components @inject DashboardSettings Settings @inject ISnackbar Snackbar @inject IDialogService DialogService