Compare commits

..

No commits in common. "25febd28a41c69b1805f0de96090b6535b5ba868" and "6cc32c8f84f517ff5fe7f270641a0504af7af1b8" have entirely different histories.

8 changed files with 71 additions and 73 deletions

View File

@ -6,7 +6,6 @@ using AyCode.Models.Enums;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using System; using System;
using AyCode.Database.DbSets.Addresses;
using AyCode.Database.DbSets.Companies; using AyCode.Database.DbSets.Companies;
using TIAM.Core; using TIAM.Core;
//using TIAM.Database.DataLayers.ServiceProviders; //using TIAM.Database.DataLayers.ServiceProviders;
@ -28,7 +27,6 @@ using TIAM.Entities.Transfers;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Products; using TIAM.Models.Dtos.Products;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
using AyCode.Database.DbSets.Profiles;
namespace TIAM.Database.DataLayers.Admins namespace TIAM.Database.DataLayers.Admins
{ {
@ -113,9 +111,30 @@ namespace TIAM.Database.DataLayers.Admins
public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson()); public string? GetUserJsonById(Guid userId, bool onlyConfirmed) => Session(ctx => ctx.GetUserById(userId, onlyConfirmed)?.ToJson());
public string GetUsersJson() => Session(ctx => ctx.Users.ToJson()); public string GetUsersJson() => Session(ctx => ctx.Users.ToJson());
public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user)); //public Task<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user));
public Task<bool> UpdateUserAsync(User user) => TransactionAsync(ctx => ctx.UpdateUser(user));
public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId)); //public Task<bool> 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<bool> RemoveUserAsync(User user) => TransactionAsync(ctx => ctx.RemoveUser(user));
//public Task<bool> RemoveUserAsync(Guid userId) => TransactionAsync(ctx => ctx.RemoveUser(userId));
public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers)); public Product? GetProductById(Guid contextId, bool includeUsers = true) => Session(ctx => ctx.GetProductById(contextId, includeUsers));
@ -160,7 +179,8 @@ namespace TIAM.Database.DataLayers.Admins
return isSucces ? userProductMapping : null; return isSucces ? userProductMapping : null;
} }
public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping) => TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping)); public Task<bool> UpdateUserProductMappingAsync(UserProductMapping userProductMapping)
=> TransactionAsync(ctx => ctx.UpdateUserProductMapping(userProductMapping));
public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null) public async Task<UserProductMapping?> UpdateUserProductMappingAsync(Guid userProductMappingId, int permissions = 1, UserProductJsonDetailModel? userProductToCars = null)
{ {
@ -176,25 +196,14 @@ namespace TIAM.Database.DataLayers.Admins
return isSucces ? userProductMapping : null; return isSucces ? userProductMapping : null;
} }
public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId) => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId)); public Task<bool> RemoveUserProductMappingAsync(Guid userProductMappingId)
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userProductMappingId));
public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId) public Task<bool> RemoveUserProductMappingAsync(Guid userId, Guid productId)
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId)); => TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId));
#endregion UserProductMapping #endregion UserProductMapping
#region Address
public Task<Address?> GetAddressByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetAddressById(addressId));
public Task<bool> UpdateAddressAsync(Address adress) => TransactionAsync(ctx => ctx.UpdateAddress(adress));
#endregion Address
#region Profile
public Task<Profile?> GetProfileByIdAsync(Guid addressId) => SessionAsync(ctx => ctx.GetProfileById(addressId));
public Task<bool> UpdateProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.UpdateProfile(profile));
//public Task<bool> AddProfileAsync(Profile profile) => TransactionAsync(ctx => ctx.AddProfile(profile)); //Nem Add-olunk önmagában Profile-t! - J.
//public Task<bool> RemoveProfileAsync(Guid profileId) => TransactionAsync(ctx => ctx.RemoveProfile(profileId)); //Nem törlünk Profile-t! - J.
#endregion Profile
#region EmailMessage #region EmailMessage
public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId)); public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId));
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList()); public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList());

View File

@ -22,13 +22,9 @@ public class SignalRTags : AcSignalRTags
public const int UpdateTransferToDrivers = 16; public const int UpdateTransferToDrivers = 16;
public const int RemoveTransferToDrivers = 17; public const int RemoveTransferToDrivers = 17;
public const int GetAddressById = 18; public const int GetAddressesByContextId = 18;
public const int UpdateAddress = 19; public const int AddAddressToContextId = 19;
//public const int AddAddress = 20; public const int UpdateAddressByContextId = 20;
//public const int RemoveAddress = 21; public const int RemoveAddressByContextId = 21;
public const int GetProfileById = 22;
public const int UpdateProfile = 23;
//public const int AddAddress = 24;
//public const int RemoveAddress = 25;
} }

View File

@ -20,12 +20,11 @@
<AddressDetailGrid @ref="_addressGrid" <AddressDetailGrid @ref="_addressGrid"
DataSource="DataSource"
Logger="_logger" Logger="_logger"
SignalRClient="AdminSignalRClient" SignalRClient="AdminSignalRClient"
OnDataItemSaving="DataItemSaving" OnDataItemSaving="DataItemSaving"
OnDataItemDeleting="DataItemDeleting" OnDataItemDeleting="DataItemDeleting"
OnDataItemChanged="DataItemChanged"
PageSize="5" PageSize="5"
AutoExpandAllGroupRows="true" AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled" KeyboardNavigationEnabled="KeyboardNavigationEnabled"
@ -50,26 +49,27 @@
Address bleh = (Address)context.EditModel; Address bleh = (Address)context.EditModel;
} }
@* <EditAddressComponent TModel="Address" Model="@bleh" OnAddressChanged="@((Address model) => SaveAddress(model))" /> *@ @* <EditAddressComponent TModel="Address" Model="@bleh" OnAddressChanged="@((Address model) => SaveAddress(model))" /> *@
<EditAddressComponent Model="@((Address)context.EditModel)" /> <EditAddressComponent Model="@((Address)context.EditModel)" OnAddressChanged="@((Address model) => SaveAddress(model))" />
</EditFormTemplate> </EditFormTemplate>
</AddressDetailGrid> </AddressDetailGrid>
@code { @code {
[Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public bool KeyboardNavigationEnabled { get; set; }
[Parameter] public IList<Address> DataSource { get; set; } = null!;
private AddressDetailGrid _addressGrid = null!; private AddressDetailGrid _addressGrid;
private LoggerClient<AddressDetailGridComponent> _logger = null!; private LoggerClient<AddressDetailGridComponent> _logger;
protected override void OnInitialized() public void SaveAddress(object addressOwnerToSave)
{ {
_logger = new LoggerClient<AddressDetailGridComponent>(LogWriters.ToArray()); _addressGrid.SaveChangesAsync();
} }
private void DataItemChanged(Address address) protected override Task OnInitializedAsync()
{ {
//TODO: itt kell visszaírni a Model-be az address-t! - J. _logger = new LoggerClient<AddressDetailGridComponent>(LogWriters.ToArray());
return Task.CompletedTask;
} }
private void DataItemSaving(GridEditModelSavingEventArgs obj) private void DataItemSaving(GridEditModelSavingEventArgs obj)

View File

@ -20,7 +20,6 @@
@using MessagePack.Resolvers @using MessagePack.Resolvers
@using AyCode.Core.Extensions; @using AyCode.Core.Extensions;
@using AyCode.Utils.Extensions @using AyCode.Utils.Extensions
@using TIAM.Entities.Addresses
@using TIAMSharedUI.Shared.Components.Grids @using TIAMSharedUI.Shared.Components.Grids
@layout AdminLayout @layout AdminLayout
@inject IEnumerable<IAcLogWriterClientBase> LogWriters @inject IEnumerable<IAcLogWriterClientBase> LogWriters
@ -134,7 +133,7 @@
<CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" /> <CompaniesNestedUserProductMapping CurrentCompany="(TIAM.Entities.ServiceProviders.Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate> *@ </DetailRowTemplate> *@
<DetailRowTemplate> <DetailRowTemplate>
<AddressDetailGridComponent DataSource="new List<Address> { ((Company)context.DataItem).Profile.Address }" KeyboardNavigationEnabled="true" /> <AddressDetailGridComponent AddressContext="(Company)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate> </DetailRowTemplate>
<EditFormTemplate Context="EditFormContext"> <EditFormTemplate Context="EditFormContext">
@{ @{
@ -147,14 +146,23 @@
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6" ColSpanLg="6" ColSpanSm="12"> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6" ColSpanLg="6" ColSpanSm="12">
@EditFormContext.GetEditor("CommissionPercent") @EditFormContext.GetEditor("CommissionPercent")
</DxFormLayoutItem> </DxFormLayoutItem>
</DxFormLayout> </DxFormLayout>
</EditFormTemplate> </EditFormTemplate>
</CompanyGrid> </CompanyGrid>
</div> </div>
</Animation> </Animation>
</div> </div>
<div class=" col-12 col-xl-6"> <div class=" col-12 col-xl-6">
</div> </div>
</div> </div>
</div> </div>

View File

@ -9,10 +9,12 @@ public class AddressGrid : TiamGrid<Address>
{ {
public AddressGrid() : base() public AddressGrid() : base()
{ {
//GetAllMessageTag = SignalRTags.GetAddressesById; GridName = nameof(Address);
//AddMessageTag = SignalRTags.AddAddress;
UpdateMessageTag = SignalRTags.UpdateAddress; GetAllMessageTag = SignalRTags.GetAddressesByContextId;
//RemoveMessageTag = SignalRTags.RemoveAddress; - nem törlünk címet - J. AddMessageTag = SignalRTags.AddAddressToContextId;
UpdateMessageTag = SignalRTags.UpdateAddressByContextId;
RemoveMessageTag = SignalRTags.RemoveAddressByContextId;
} }
protected override Task SetParametersAsyncCore(ParameterView parameters) protected override Task SetParametersAsyncCore(ParameterView parameters)

View File

@ -81,7 +81,7 @@ namespace TIAMSharedUI.Shared.Components.Grids
{ {
await base.OnAfterRenderAsync(firstRender); await base.OnAfterRenderAsync(firstRender);
if (firstRender && DataSource == null) RefreshDataSourceAsync().Forget(); if (firstRender) RefreshDataSourceAsync().Forget();
} }
public Task AddDataItem(TDataItem dataItem) => PostDataToServerAsync(dataItem, AddMessageTag); public Task AddDataItem(TDataItem dataItem) => PostDataToServerAsync(dataItem, AddMessageTag);
@ -132,10 +132,10 @@ namespace TIAMSharedUI.Shared.Components.Grids
public virtual Task RefreshDataSourceAsync() public virtual Task RefreshDataSourceAsync()
{ {
if (GetAllMessageTag == 0) return Task.CompletedTask;
Logger.Info($"{_gridLogName} UpdateAllDataAsync called"); Logger.Info($"{_gridLogName} UpdateAllDataAsync called");
//if (GetAllMessageTag == 0) return Task.CompletedTask;
return SignalRClient.GetAllAsync<IList<TDataItem>>(GetAllMessageTag, response => return SignalRClient.GetAllAsync<IList<TDataItem>>(GetAllMessageTag, response =>
{ {
if (response.Status == SignalResponseStatus.Error) if (response.Status == SignalResponseStatus.Error)
@ -151,14 +151,13 @@ namespace TIAMSharedUI.Shared.Components.Grids
protected virtual async Task PostDataToServerAsync(TDataItem dataItem, int messageTag, bool isDelete = false) protected virtual async Task PostDataToServerAsync(TDataItem dataItem, int messageTag, bool isDelete = false)
{ {
await OnDataItemChanging.InvokeAsync(dataItem);
if (messageTag == 0) return;
Logger.Info($"{_gridLogName} PostDataToServerAsync called; transferId " + dataItem.Id); Logger.Info($"{_gridLogName} PostDataToServerAsync called; transferId " + dataItem.Id);
if (dataItem.Id.IsNullOrEmpty()) dataItem.Id = Guid.NewGuid(); //if (messageTag == 0) return;
await OnDataItemChanging.InvokeAsync(dataItem);
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. 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 => SignalRClient.PostDataAsync(messageTag, dataItem, async repsonse =>

View File

@ -8,6 +8,8 @@ public class TransferToDriversGrid : TiamGrid<TransferToDriver>
{ {
public TransferToDriversGrid() : base() public TransferToDriversGrid() : base()
{ {
GridName = nameof(TransferToDriver);
GetAllMessageTag = SignalRTags.GetTransferToDrivers; GetAllMessageTag = SignalRTags.GetTransferToDrivers;
AddMessageTag = SignalRTags.AddTransferToDrivers; AddMessageTag = SignalRTags.AddTransferToDrivers;
UpdateMessageTag = SignalRTags.UpdateTransferToDrivers; UpdateMessageTag = SignalRTags.UpdateTransferToDrivers;

View File

@ -18,8 +18,6 @@ using MessagePack;
using System.Security.Cryptography.Xml; using System.Security.Cryptography.Xml;
using DevExpress.XtraPrinting.Native.WebClientUIControl; using DevExpress.XtraPrinting.Native.WebClientUIControl;
using DevExpress.XtraReports.Parameters; using DevExpress.XtraReports.Parameters;
using TIAM.Entities.Addresses;
using TIAM.Entities.Profiles;
namespace TIAMWebApp.Server.Services; namespace TIAMWebApp.Server.Services;
@ -163,22 +161,6 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
return; return;
case SignalRTags.UpdateAddress:
var address = message!.MessagePackTo<SignalPostJsonDataMessage<Address>>().PostData;
await _adminDal.UpdateAddressAsync(address);
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, address), requestId);
return;
case SignalRTags.UpdateProfile:
var profile = message!.MessagePackTo<SignalPostJsonDataMessage<Profile>>().PostData;
await _adminDal.UpdateProfileAsync(profile);
await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, profile), requestId);
return;
//case SignalRTags.GetTransfersAsync: //case SignalRTags.GetTransfersAsync:
// await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, await _transferDataApiController.GetTransfers()), requestId); // await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, await _transferDataApiController.GetTransfers()), requestId);