diff --git a/TIAM.Database/DataLayers/Admins/AdminDal.cs b/TIAM.Database/DataLayers/Admins/AdminDal.cs index 9e539024..d669d65b 100644 --- a/TIAM.Database/DataLayers/Admins/AdminDal.cs +++ b/TIAM.Database/DataLayers/Admins/AdminDal.cs @@ -6,6 +6,7 @@ using AyCode.Models.Enums; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using System; +using AyCode.Database.DbSets.Addresses; using AyCode.Database.DbSets.Companies; using TIAM.Core; //using TIAM.Database.DataLayers.ServiceProviders; @@ -27,6 +28,7 @@ using TIAM.Entities.Transfers; using TIAM.Entities.Users; using TIAM.Models.Dtos.Products; using TIAM.Models.Dtos.Users; +using AyCode.Database.DbSets.Profiles; namespace TIAM.Database.DataLayers.Admins { @@ -111,30 +113,9 @@ namespace TIAM.Database.DataLayers.Admins public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson()); public string GetUsersJson() => Session(ctx => ctx.Users.ToJson()); - //public Task AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user)); - - //public Task AddUserAsync(User user, string profileName, Address address, string? firstName = null, string? lastName = null) - //{ - // return TransactionAsync(ctx => - // { - // var profile = new Profile - // { - // Id = Guid.NewGuid(), - // Name = profileName, - // FirstName = firstName, - // LastName = lastName, - // Address = address, - // AddressId = address.Id - // }; - - // user.Profile= profile; - - // return ctx.AddUser(user); - // }); - //} - - //public Task RemoveUserAsync(User user) => TransactionAsync(ctx => ctx.RemoveUser(user)); - //public Task RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); + public Task AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user)); + public Task UpdateUserAsync(User user) => TransactionAsync(ctx => ctx.UpdateUser(user)); + public Task RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers)); @@ -179,8 +160,7 @@ namespace TIAM.Database.DataLayers.Admins return isSucces ? userProductMapping : null; } - public Task UpdateUserProductMappingAsync(UserProductMapping userProductMapping) - => TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping)); + public Task UpdateUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping)); public async Task UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) { @@ -196,14 +176,25 @@ namespace TIAM.Database.DataLayers.Admins return isSucces ? userProductMapping : null; } - public Task RemoveUserProductMappingAsync(Guid userProductMappingId) - => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId)); + public Task RemoveUserProductMappingAsync(Guid userProductMappingId) => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId)); public Task RemoveUserProductMappingAsync(Guid userId, Guid productId) => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId)); #endregion UserProductMapping + #region Address + public Task GetAddressByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetAddressById(addressId)); + public Task UpdateAddressAsync(Address adress) => TransactionAsync(ctx => ctx.UpdateAddress(adress)); + #endregion Address + + #region Profile + public Task GetProfileByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetProfileById(addressId)); + public Task UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile)); + //public Task AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J. + //public Task RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J. + #endregion Profile + #region EmailMessage public Task GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId)); public Task> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList()); diff --git a/TIAM.Services/SignalRTags.cs b/TIAM.Services/SignalRTags.cs index 688b29da..3b19f2d0 100644 --- a/TIAM.Services/SignalRTags.cs +++ b/TIAM.Services/SignalRTags.cs @@ -22,9 +22,13 @@ public class SignalRTags : AcSignalRTags public const int UpdateTransferToDrivers = 16; public const int RemoveTransferToDrivers = 17; - public const int GetAddressesByContextId = 18; - public const int AddAddressToContextId = 19; - public const int UpdateAddressByContextId = 20; - public const int RemoveAddressByContextId = 21; + public const int GetAddressById = 18; + public const int UpdateAddress = 19; + //public const int AddAddress = 20; + //public const int RemoveAddress = 21; + public const int GetProfileById = 22; + public const int UpdateProfile = 23; + //public const int AddAddress = 24; + //public const int RemoveAddress = 25; } \ No newline at end of file diff --git a/TIAMSharedUI/Pages/User/SysAdmins/AddressDetailGridComponent.razor b/TIAMSharedUI/Pages/User/SysAdmins/AddressDetailGridComponent.razor index 3d5c7099..556a201e 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/AddressDetailGridComponent.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/AddressDetailGridComponent.razor @@ -25,7 +25,7 @@ SignalRClient="AdminSignalRClient" OnDataItemSaving="DataItemSaving" OnDataItemDeleting="DataItemDeleting" - + OnDataItemChanged="DataItemChanged" PageSize="5" AutoExpandAllGroupRows="true" KeyboardNavigationEnabled="KeyboardNavigationEnabled" @@ -50,30 +50,28 @@ Address bleh = (Address)context.EditModel; } @* *@ - + @code { [Parameter] public bool KeyboardNavigationEnabled { get; set; } + [Parameter] public IList
DataSource { get; set; } = null!; - private AddressDetailGrid _addressGrid; - private LoggerClient _logger; - - [Parameter] - public IList
DataSource { get; set; } - - public void SaveAddress(object addressOwnerToSave) - { - _addressGrid.SaveChangesAsync(); - } + private AddressDetailGrid _addressGrid = null!; + private LoggerClient _logger = null!; protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); } + private void DataItemChanged(Address address) + { + //TODO: itt kell visszaírni a Model-be az address-t! - J. + } + private void DataItemSaving(GridEditModelSavingEventArgs obj) { _logger.Debug($"DataItemSaving"); diff --git a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor index d2964571..1f2cc766 100644 --- a/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor +++ b/TIAMSharedUI/Pages/User/SysAdmins/ManageServiceProviders.razor @@ -147,23 +147,14 @@ @EditFormContext.GetEditor("CommissionPercent") - - - - - - - -
- diff --git a/TIAMSharedUI/Shared/Components/Grids/AdressGrid.cs b/TIAMSharedUI/Shared/Components/Grids/AdressGrid.cs index dfb0e78e..0b40fe95 100644 --- a/TIAMSharedUI/Shared/Components/Grids/AdressGrid.cs +++ b/TIAMSharedUI/Shared/Components/Grids/AdressGrid.cs @@ -9,12 +9,10 @@ public class AddressGrid : TiamGrid
{ public AddressGrid() : base() { - GridName = nameof(Address); - - GetAllMessageTag = SignalRTags.GetAddressesByContextId; - AddMessageTag = SignalRTags.AddAddressToContextId; - UpdateMessageTag = SignalRTags.UpdateAddressByContextId; - RemoveMessageTag = SignalRTags.RemoveAddressByContextId; + //GetAllMessageTag = SignalRTags.GetAddressesById; + //AddMessageTag = SignalRTags.AddAddress; + UpdateMessageTag = SignalRTags.UpdateAddress; + //RemoveMessageTag = SignalRTags.RemoveAddress; - nem törlünk címet - J. } protected override Task SetParametersAsyncCore(ParameterView parameters) diff --git a/TIAMSharedUI/Shared/Components/Grids/TiamGrid.cs b/TIAMSharedUI/Shared/Components/Grids/TiamGrid.cs index 2025d244..ca48c8ed 100644 --- a/TIAMSharedUI/Shared/Components/Grids/TiamGrid.cs +++ b/TIAMSharedUI/Shared/Components/Grids/TiamGrid.cs @@ -132,10 +132,10 @@ namespace TIAMSharedUI.Shared.Components.Grids public virtual Task RefreshDataSourceAsync() { + if (GetAllMessageTag == 0) return Task.CompletedTask; + Logger.Info($"{_gridLogName} UpdateAllDataAsync called"); - //if (GetAllMessageTag == 0) return Task.CompletedTask; - return SignalRClient.GetAllAsync>(GetAllMessageTag, response => { if (response.Status == SignalResponseStatus.Error) @@ -151,13 +151,14 @@ namespace TIAMSharedUI.Shared.Components.Grids protected virtual async Task PostDataToServerAsync(TDataItem dataItem, int messageTag, bool isDelete = false) { - Logger.Info($"{_gridLogName} PostDataToServerAsync called; transferId " + dataItem.Id); - - //if (messageTag == 0) return; - await OnDataItemChanging.InvokeAsync(dataItem); + if (messageTag == 0) return; + + Logger.Info($"{_gridLogName} PostDataToServerAsync called; transferId " + dataItem.Id); + if (dataItem.Id.IsNullOrEmpty()) dataItem.Id = Guid.NewGuid(); + RefreshDataItem(dataItem, isDelete); //egyből látszódik a változás a grid-ben, nem csak a callback lefutásakor! felhasználóbarátabb... - J. SignalRClient.PostDataAsync(messageTag, dataItem, async repsonse => diff --git a/TIAMSharedUI/Shared/Components/Grids/TransferToDriversGrid.cs b/TIAMSharedUI/Shared/Components/Grids/TransferToDriversGrid.cs index 233741e7..0c85790c 100644 --- a/TIAMSharedUI/Shared/Components/Grids/TransferToDriversGrid.cs +++ b/TIAMSharedUI/Shared/Components/Grids/TransferToDriversGrid.cs @@ -8,8 +8,6 @@ public class TransferToDriversGrid : TiamGrid { public TransferToDriversGrid() : base() { - GridName = nameof(TransferToDriver); - GetAllMessageTag = SignalRTags.GetTransferToDrivers; AddMessageTag = SignalRTags.AddTransferToDrivers; UpdateMessageTag = SignalRTags.UpdateTransferToDrivers; diff --git a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs index e19b1a63..15a10e2b 100644 --- a/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs +++ b/TIAMWebApp/Server/Services/DevAdminSignalRhub.cs @@ -18,6 +18,8 @@ using MessagePack; using System.Security.Cryptography.Xml; using DevExpress.XtraPrinting.Native.WebClientUIControl; using DevExpress.XtraReports.Parameters; +using TIAM.Entities.Addresses; +using TIAM.Entities.Profiles; namespace TIAMWebApp.Server.Services; @@ -161,9 +163,25 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe return; + case SignalRTags.UpdateAddress: + var address = message!.MessagePackTo>().PostData; + + await _adminDal.UpdateAddressAsync(address); + await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, address), requestId); + + return; + + case SignalRTags.UpdateProfile: + var profile = message!.MessagePackTo>().PostData; + + await _adminDal.UpdateProfileAsync(profile); + await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, profile), requestId); + + return; + //case SignalRTags.GetTransfersAsync: // await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, await _transferDataApiController.GetTransfers()), requestId); - + // return; //case SignalRTags.GetPropertiesByOwnerIdAsync: @@ -188,10 +206,10 @@ public class DevAdminSignalRHub : Hub, IAcSignalRHubServe //case SignalRTags.UpdateCompanyAsync: // var updateCompany = message!.MessagePackTo>().PostData; - + // await _serviceProviderApiController.UpdateServiceProvider(updateCompany); // await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, updateCompany), requestId); - + // return; default: