142 lines
5.8 KiB
Plaintext
142 lines
5.8 KiB
Plaintext
@using TIAM.Entities.Products
|
|
@using TIAM.Entities.ServiceProviders
|
|
@using TIAM.Entities.Transfers
|
|
@using TIAM.Entities.Drivers
|
|
@using TIAM.Entities.Users
|
|
@using TIAM.Models.Dtos.Users
|
|
@using TIAM.Resources
|
|
@using TIAMWebApp.Shared.Application.Interfaces
|
|
@using TIAMWebApp.Shared.Application.Utility
|
|
@using AyCode.Services.Loggers
|
|
@using TIAM.Core.Loggers
|
|
@using Address = TIAM.Entities.Addresses.Address
|
|
@using Profile = TIAM.Entities.Profiles.Profile
|
|
@using TIAMSharedUI.Shared.Components.Grids
|
|
@using TIAMSharedUI.Pages.Components.EditComponents
|
|
@using TIAMWebApp.Shared.Application.Services
|
|
@using AyCode.Interfaces.Addresses
|
|
@inject IStringLocalizer<TIAMResources> Localizer
|
|
@inject IServiceProviderDataService serviceProviderDataService
|
|
@inject IUserDataService userDataService
|
|
@inject ITransferDataService transferDataService
|
|
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
|
@inject AdminSignalRClient AdminSignalRClient;
|
|
|
|
|
|
<ProductDetailGrid @ref="_productGrid"
|
|
ContextId="ContextId"
|
|
Logger="_logger"
|
|
SignalRClient="AdminSignalRClient"
|
|
OnGridEditModelSaving="DataItemSaving"
|
|
OnGridItemDeleting="DataItemDeleting"
|
|
OnGridItemChanged="DataItemChanged"
|
|
PageSize="5"
|
|
AutoExpandAllGroupRows="true"
|
|
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
|
KeyFieldName="Id"
|
|
ValidationEnabled="false"
|
|
EditMode="GridEditMode.EditForm"
|
|
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
|
ShowFilterRow="true">
|
|
<Columns>
|
|
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
|
|
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
|
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductName) FieldName="Name" />
|
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductType) FieldName="ProductType" Width="140" />
|
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.Price) FieldName="Price" Width="40" />
|
|
<DxGridDataColumn FieldName="ServiceProviderId" Width="40" />
|
|
<DxGridDataColumn Caption=@Localizer.GetString(ResourceKeys.ProductDescription) FieldName="Description" Width="40" />
|
|
</Columns>
|
|
<DetailRowTemplate>
|
|
<DxTabs>
|
|
<DxTabPage Text="Profile">
|
|
<ProfileGridComponent ProfileId="((Product)context.DataItem).ProfileId" KeyboardNavigationEnabled="true" />
|
|
</DxTabPage>
|
|
</DxTabs>
|
|
</DetailRowTemplate>
|
|
<EditFormTemplate Context="EditFormContext">
|
|
@{
|
|
var transfer2 = (Product)EditFormContext.EditModel;
|
|
}
|
|
<DxFormLayout CssClass="w-100">
|
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductName) ColSpanMd="4">
|
|
@EditFormContext.GetEditor("Name")
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductType) ColSpanMd="4">
|
|
@EditFormContext.GetEditor("ProductType")
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.Price) ColSpanMd="4">
|
|
@EditFormContext.GetEditor("Price")
|
|
</DxFormLayoutItem>
|
|
<DxFormLayoutItem Caption=@Localizer.GetString(ResourceKeys.ProductDescription) ColSpanMd="4">
|
|
@EditFormContext.GetEditor("Description")
|
|
</DxFormLayoutItem>
|
|
|
|
|
|
</DxFormLayout>
|
|
</EditFormTemplate>
|
|
|
|
</ProductDetailGrid>
|
|
|
|
@code {
|
|
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
|
[Parameter] public Guid? ContextId { get; set; }
|
|
|
|
private ProductDetailGrid _productGrid = null!;
|
|
private LoggerClient<ProductDetailGridComponent> _logger = null!;
|
|
protected override void OnInitialized()
|
|
{
|
|
_logger = new LoggerClient<ProductDetailGridComponent>(LogWriters.ToArray());
|
|
|
|
//DataSource = new List<Address>();
|
|
|
|
}
|
|
|
|
private void DataItemChanged(GridDataItemChangedEventArgs<Product> args)
|
|
{
|
|
_logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}");
|
|
|
|
_productGrid.SaveChangesAsync();
|
|
}
|
|
|
|
private void DataItemSaving(GridEditModelSavingEventArgs e)
|
|
{
|
|
_logger.Debug($"DataItemSaving");
|
|
((Product)e.EditModel).ServiceProviderId = (Guid)ContextId!;
|
|
Guid _profileId = Guid.NewGuid();
|
|
((Product)e.EditModel).Profile = new Profile();
|
|
((Product)e.EditModel).Profile.Id = _profileId;
|
|
((Product)e.EditModel).ProfileId = _profileId;
|
|
((Product)e.EditModel).Profile.Name = ((Product)e.EditModel).Name;
|
|
Guid _addressId = Guid.NewGuid();
|
|
((Product)e.EditModel).Profile.Address = new Address();
|
|
((Product)e.EditModel).Profile.AddressId = _addressId;
|
|
((Product)e.EditModel).Profile.Address.Id = _addressId;
|
|
|
|
|
|
|
|
_logger.Debug($"Saving: {((Product)e.EditModel).Name}, {((Product)e.EditModel).ServiceProviderId}");
|
|
|
|
//var result = serviceProviderDataService.CreateProductAsync((Product)e.EditModel);
|
|
_logger.Debug($"saved product: {((Product)e.EditModel).ServiceProviderId}");
|
|
}
|
|
|
|
private void DataItemDeleting(GridDataItemDeletingEventArgs obj)
|
|
{
|
|
_logger.Debug($"DataItemDeleting");
|
|
}
|
|
|
|
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
|
{
|
|
if (!e.IsNew) return;
|
|
|
|
var newProduct = (Product)e.EditModel;
|
|
newProduct.Id = Guid.NewGuid();
|
|
newProduct.Name = "Type a name";
|
|
newProduct.ServiceProviderId = (Guid)ContextId!;
|
|
newProduct.Price = 0;
|
|
newProduct.ProductType = TIAM.Core.Enums.ProductType.Hotel;
|
|
newProduct.Description = "Type a description";
|
|
}
|
|
|
|
} |