AddressDetailGridComponent improvements, fixes, etc
This commit is contained in:
parent
0708b0689c
commit
25febd28a4
|
|
@ -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<bool> AddUserAsync(User user) => TransactionAsync(ctx => ctx.AddUser(user));
|
||||
|
||||
//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 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 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<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)
|
||||
{
|
||||
|
|
@ -196,14 +176,25 @@ namespace TIAM.Database.DataLayers.Admins
|
|||
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)
|
||||
=> TransactionAsync(ctx => ctx.RemoveUserProductMapping(userId, productId));
|
||||
|
||||
#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
|
||||
public Task<EmailMessage?> GetEmailMessageByIdAsync(Guid emailMessageId) => SessionAsync(ctx => ctx.GetEmailMessageById(emailMessageId));
|
||||
public Task<List<EmailMessage>> GetEmailMessagesByContextIdAsync(Guid contextId) => SessionAsync(ctx => ctx.GetEmailMessagesByContextId(contextId).ToList());
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
@ -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;
|
||||
}
|
||||
@* <EditAddressComponent TModel="Address" Model="@bleh" OnAddressChanged="@((Address model) => SaveAddress(model))" /> *@
|
||||
<EditAddressComponent Model="@((Address)context.EditModel)" OnAddressChanged="@((Address model) => SaveAddress(model))" />
|
||||
<EditAddressComponent Model="@((Address)context.EditModel)" />
|
||||
</EditFormTemplate>
|
||||
|
||||
</AddressDetailGrid>
|
||||
|
||||
@code {
|
||||
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
||||
[Parameter] public IList<Address> DataSource { get; set; } = null!;
|
||||
|
||||
private AddressDetailGrid _addressGrid;
|
||||
private LoggerClient<AddressDetailGridComponent> _logger;
|
||||
|
||||
[Parameter]
|
||||
public IList<Address> DataSource { get; set; }
|
||||
|
||||
public void SaveAddress(object addressOwnerToSave)
|
||||
{
|
||||
_addressGrid.SaveChangesAsync();
|
||||
}
|
||||
private AddressDetailGrid _addressGrid = null!;
|
||||
private LoggerClient<AddressDetailGridComponent> _logger = null!;
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<AddressDetailGridComponent>(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");
|
||||
|
|
|
|||
|
|
@ -147,23 +147,14 @@
|
|||
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6" ColSpanLg="6" ColSpanSm="12">
|
||||
@EditFormContext.GetEditor("CommissionPercent")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
|
||||
</CompanyGrid>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
</Animation>
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-6">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,10 @@ public class AddressGrid : TiamGrid<Address>
|
|||
{
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -132,9 +132,9 @@ namespace TIAMSharedUI.Shared.Components.Grids
|
|||
|
||||
public virtual Task RefreshDataSourceAsync()
|
||||
{
|
||||
Logger.Info($"{_gridLogName} UpdateAllDataAsync called");
|
||||
if (GetAllMessageTag == 0) return Task.CompletedTask;
|
||||
|
||||
//if (GetAllMessageTag == 0) return Task.CompletedTask;
|
||||
Logger.Info($"{_gridLogName} UpdateAllDataAsync called");
|
||||
|
||||
return SignalRClient.GetAllAsync<IList<TDataItem>>(GetAllMessageTag, response =>
|
||||
{
|
||||
|
|
@ -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 =>
|
||||
|
|
|
|||
|
|
@ -8,8 +8,6 @@ public class TransferToDriversGrid : TiamGrid<TransferToDriver>
|
|||
{
|
||||
public TransferToDriversGrid() : base()
|
||||
{
|
||||
GridName = nameof(TransferToDriver);
|
||||
|
||||
GetAllMessageTag = SignalRTags.GetTransferToDrivers;
|
||||
AddMessageTag = SignalRTags.AddTransferToDrivers;
|
||||
UpdateMessageTag = SignalRTags.UpdateTransferToDrivers;
|
||||
|
|
|
|||
|
|
@ -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,6 +163,22 @@ public class DevAdminSignalRHub : Hub<ISignalRHubItemServer>, IAcSignalRHubServe
|
|||
|
||||
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:
|
||||
// await ResponseToCaller(messageTag, new SignalResponseJsonMessage(SignalResponseStatus.Success, await _transferDataApiController.GetTransfers()), requestId);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue