@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 Localizer @inject IServiceProviderDataService serviceProviderDataService @inject IUserDataService userDataService @inject ITransferDataService transferDataService @inject IEnumerable LogWriters @inject AdminSignalRClient AdminSignalRClient; @{ var transfer2 = (Product)EditFormContext.EditModel; } @EditFormContext.GetEditor("Name") @EditFormContext.GetEditor("ProductType") @EditFormContext.GetEditor("Price") @EditFormContext.GetEditor("Description") @code { [Parameter] public bool KeyboardNavigationEnabled { get; set; } [Parameter] public Guid? ContextId { get; set; } [Parameter] public IProductsRelation ParentData { get; set; } = null!; [Parameter] public EventCallback OnGridEditModelSaving { get; set; } private ProductDetailGrid _productGrid = null!; private LoggerClient _logger = null!; protected override void OnInitialized() { _logger = new LoggerClient(LogWriters.ToArray()); //DataSource = new List
(); } private void DataItemChanged(GridDataItemChangedEventArgs args) { _logger.Debug($"Saving: {args.DataItem.Name}, {args.DataItem.ServiceProviderId}"); //ProductGrid.SaveChangesAsync(); } public async Task DataItemSaving(GridEditModelSavingEventArgs e) { await OnGridEditModelSaving.InvokeAsync(e); if (e.Cancel) return; var product = ((Product)e.EditModel); if (e.IsNew) { _logger.Debug($"DataItemSaving"); var profileId = Guid.NewGuid(); product.Profile = new Profile(profileId, product.Name); product.ProfileId = profileId; var addressId = Guid.NewGuid(); product.Profile.Address = new Address(addressId); product.Profile.AddressId = addressId; //((Product)e.EditModel).UserProductMappings.Add(new UserProductMapping(Guid.NewGuid, ParentData.)); } else { } _logger.Debug($"Saving: {product.Name}, {product.ServiceProviderId}"); //var result = serviceProviderDataService.CreateProductAsync((Product)e.EditModel); //_logger.Debug($"saved product: {product.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"; } }