price management basics
This commit is contained in:
parent
9412a02d82
commit
4cf5a50a41
|
|
@ -75,4 +75,18 @@ public class SignalRTags : AcSignalRTags
|
|||
public const int AddProduct = 74;
|
||||
public const int RemoveProduct = 75;
|
||||
public const int GetProductsById = 76;
|
||||
public const int GetAllProducts = 77;
|
||||
|
||||
public const int CreateTransferDestination = 80;
|
||||
public const int UpdateTransferDestination = 81;
|
||||
public const int DeleteTransferDestination = 82; //set permissions to 0
|
||||
public const int GetAllTransferDestinations = 83;
|
||||
|
||||
public const int CreateTransferDestinationToProduct = 90;
|
||||
public const int UpdateTransferDestinationToProduct = 91;
|
||||
public const int DeleteTransferDestinationToProduct = 92; //set permissions to 0
|
||||
public const int GetAllTransferDestinationToProducts = 93;
|
||||
public const int GetTransferDestinationToProductByProductId = 94;
|
||||
public const int GetTransferDestinationToProductByTransferDestinationId = 95;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,10 +14,10 @@
|
|||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject IServiceProviderDataService ServiceProviderDataService
|
||||
|
||||
<!--div class="text-center m-5">
|
||||
<div class="text-center m-5">
|
||||
<h1>Service management</h1>
|
||||
<h2 style="font-size:small">Manage your services here!</h2>
|
||||
</!--div-->
|
||||
</div>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
|
|
@ -31,7 +31,7 @@
|
|||
IconCssClass="btn-column-chooser"
|
||||
Click="ColumnChooserButton_Click" />
|
||||
</div>
|
||||
<ProductGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllUserProductMappings"></ProductGridComponent>
|
||||
<ProductGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllProducts"></ProductGridComponent>
|
||||
|
||||
</div>
|
||||
|
||||
|
|
@ -64,13 +64,6 @@
|
|||
public MessageWizardModel MessageWizardModel = new();
|
||||
|
||||
|
||||
//List<ProductWizardModel> _productArray =
|
||||
//[
|
||||
// new ProductWizardModel(new Company(), ProductType.Hotel, "XY hotel", "XYHotel description is here ", 10.0f, ""),
|
||||
// new ProductWizardModel(new Company(), ProductType.Hotel, "XY hotel", "XYHotel description is here ", 10.0f, ""),
|
||||
// new ProductWizardModel(new Company(), ProductType.Hotel, "XY hotel", "XYHotel description is here ", 10.0f, "")
|
||||
//];
|
||||
|
||||
private readonly List<ProductWizardModel> _productWizardModels = [];
|
||||
|
||||
void CancelCreateClick()
|
||||
|
|
|
|||
|
|
@ -0,0 +1,168 @@
|
|||
@page "/sysadmin/prices"
|
||||
@using BlazorAnimation
|
||||
@using TIAM.Models.Dtos.Users
|
||||
@using TIAM.Resources
|
||||
@using TIAM.Services
|
||||
@using TIAMSharedUI.Pages.Components
|
||||
@using TIAMSharedUI.Shared
|
||||
@using TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||
@using TIAMWebApp.Shared.Application.Models.PageModels
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@layout AdminLayout
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject IStringLocalizer<TIAMResources> Localizer
|
||||
@inject ISessionService SessionService
|
||||
@inject IWizardProcessor WizardProcessor
|
||||
@inject IUserDataService UserDataService
|
||||
<PageTitle>User permissions</PageTitle>
|
||||
|
||||
<div class="text-center m-5">
|
||||
<h1>User permissions</h1>
|
||||
<h2 style="font-size:small">Manage transfers here!</h2>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<div class=" col-12">
|
||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
||||
<div class="card">
|
||||
<div class="d-flex flex-column mb-4 pb-2">
|
||||
<div class="align-self-end pl-2 pb-2">
|
||||
<DxButton Text="Column Chooser"
|
||||
RenderStyle="ButtonRenderStyle.Secondary"
|
||||
IconCssClass="btn-column-chooser"
|
||||
Click="ColumnChooserButton_Click" />
|
||||
</div>
|
||||
|
||||
<TransferDestinationToProductGridComponent DetailExpandButtonDisplayMode="GridDetailExpandButtonDisplayMode.Auto" GetAllTag="SignalRTags.GetAllTransferDestinationToProducts"></TransferDestinationToProductGridComponent>
|
||||
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</Animation>
|
||||
</div>
|
||||
|
||||
<div class=" col-12 col-xl-6">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private LoggerClient<ManageUserProductMappings> _logger;
|
||||
//public UserModelDtoDetail UserModelDtoDetail = new();
|
||||
|
||||
|
||||
bool PopupVisible { get; set; }
|
||||
|
||||
IGrid Grid { get; set; }
|
||||
//object? MasterGridData { get; set; }
|
||||
bool AutoCollapseDetailRow { get; set; }
|
||||
|
||||
public List<string> IgnoreList =
|
||||
[
|
||||
"ReceiverEmailAddress",
|
||||
"ReceiverId",
|
||||
"SenderEmailAddress",
|
||||
"SenderId",
|
||||
"ContextId"
|
||||
];
|
||||
|
||||
|
||||
|
||||
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
|
||||
{
|
||||
if (e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1)
|
||||
{
|
||||
e.CssClass = "bg-alt";
|
||||
}
|
||||
else if (e.ElementType == GridElementType.HeaderCell)
|
||||
{
|
||||
e.Style = "background-color: rgba(0, 0, 0, 0.08); font-style=bold";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
{
|
||||
if (!e.IsNew) return;
|
||||
|
||||
var userEditModel = (UserModelDtoDetail)e.EditModel; //TODO not valid cast
|
||||
userEditModel.Id = Guid.NewGuid();
|
||||
|
||||
userEditModel.UserDto = new UserDtoDetail
|
||||
{
|
||||
AffiliateId = Guid.NewGuid(),
|
||||
EmailAddress = "",
|
||||
PhoneNumber = ""
|
||||
};
|
||||
|
||||
userEditModel.ProfileDto = new TIAM.Entities.Profiles.Profile
|
||||
{
|
||||
Name = "New user"
|
||||
};
|
||||
|
||||
userEditModel.Products = [];
|
||||
userEditModel.ServiceProviders = [];
|
||||
userEditModel.UserProductMappings = [];
|
||||
}
|
||||
|
||||
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
{
|
||||
var userModelDtoDetail = ((UserModelDtoDetail)e.EditModel);
|
||||
|
||||
if (e.IsNew)
|
||||
{
|
||||
//add new orderData to orderData array
|
||||
var registration = new RegistrationModel();
|
||||
//TODO: Refractor to userDataService
|
||||
|
||||
var random = new Random();
|
||||
const string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
|
||||
var password = new string(Enumerable.Repeat(chars, 10)
|
||||
.Select(s => s[random.Next(s.Length)]).ToArray());
|
||||
|
||||
registration.Email = userModelDtoDetail.UserDto.EmailAddress;
|
||||
registration.PhoneNumber = userModelDtoDetail.UserDto.PhoneNumber;
|
||||
registration.Password = password;
|
||||
registration.ReferralId = null;
|
||||
|
||||
await UserDataService.CreateGuestUser(registration);
|
||||
_logger.Info("New user created added");
|
||||
}
|
||||
else
|
||||
{
|
||||
_logger.Info("orderData updated at id " + userModelDtoDetail.Id);
|
||||
|
||||
//await transferDataService.UpdateTransferAsync((TransferWizardModel)e.EditModel);
|
||||
//modify transferData where transferData.Id == e.EditModel.Id
|
||||
}
|
||||
//get transfer from TransferData by Id
|
||||
|
||||
// foreach (var transferToModify in (List<Transfer>)TransferData)
|
||||
// {
|
||||
// myModel = (Transfer)e.EditModel;
|
||||
|
||||
// if (transferToModify.Id == myModel.Id)
|
||||
// {
|
||||
// //transferToModify.Driver = myModel.Driver;
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
protected override void OnInitialized()
|
||||
{
|
||||
_logger = new LoggerClient<ManageUserProductMappings>(LogWriters.ToArray());
|
||||
|
||||
base.OnInitialized();
|
||||
}
|
||||
|
||||
void ColumnChooserButton_Click()
|
||||
{
|
||||
Grid.ShowColumnChooser();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,143 @@
|
|||
@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 TIAMWebApp.Shared.Application.Interfaces
|
||||
@using TIAMWebApp.Shared.Application.Services
|
||||
@using TIAMWebApp.Shared.Application.Utility
|
||||
@using AyCode.Services.Loggers
|
||||
@using TIAM.Core.Loggers
|
||||
@using AyCode.Core
|
||||
@using TIAMSharedUI.Shared.Components.Grids
|
||||
@inject IServiceProviderDataService ServiceProviderDataService
|
||||
@inject IEnumerable<IAcLogWriterClientBase> LogWriters
|
||||
@inject AdminSignalRClient AdminSignalRClient;
|
||||
|
||||
<TransferDestinationToProductGrid
|
||||
Logger="_logger"
|
||||
SignalRClient="AdminSignalRClient"
|
||||
ContextIds="ContextIds"
|
||||
PageSize="5"
|
||||
AutoExpandAllGroupRows="true"
|
||||
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
|
||||
KeyFieldName="Id"
|
||||
ValidationEnabled="false"
|
||||
EditMode="GridEditMode.EditForm"
|
||||
ColumnResizeMode="GridColumnResizeMode.NextColumn"
|
||||
ShowFilterRow="true">
|
||||
<Columns>
|
||||
<DxGridCommandColumn Width="135" MinWidth="135" FixedPosition="GridColumnFixedPosition.Left" />
|
||||
<DxGridDataColumn FieldName="Id" GroupIndex="0" ShowInColumnChooser="AcDomain.IsDeveloperVersion" Visible="AcDomain.IsDeveloperVersion" />
|
||||
<DxGridDataColumn FieldName="ProductId" />
|
||||
<DxGridDataColumn FieldName="TransferDestinationId"/>
|
||||
<DxGridDataColumn FieldName="Price" />
|
||||
<DxGridDataColumn FieldName="Price2" />
|
||||
<DxGridDataColumn FieldName="Price3" />
|
||||
<DxGridDataColumn FieldName="ProductCommis" />
|
||||
</Columns>
|
||||
<DetailRowTemplate>
|
||||
|
||||
<DxTabs>
|
||||
<DxTabPage Text="Partner">
|
||||
|
||||
</DxTabPage>
|
||||
|
||||
</DxTabs>
|
||||
|
||||
|
||||
</DetailRowTemplate>
|
||||
<EditFormTemplate Context="EditFormContext">
|
||||
@{
|
||||
var serviceProvider = (Company)EditFormContext.EditModel;
|
||||
}
|
||||
<DxFormLayout CssClass="w-100">
|
||||
<DxFormLayoutItem Caption="Price" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Price2" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price2")
|
||||
</DxFormLayoutItem>
|
||||
<DxFormLayoutItem Caption="Price3" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("Price3")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
<DxFormLayoutItem Caption="Commission rate" ColSpanMd="4">
|
||||
@EditFormContext.GetEditor("ProductCommis")
|
||||
</DxFormLayoutItem>
|
||||
|
||||
|
||||
|
||||
</DxFormLayout>
|
||||
</EditFormTemplate>
|
||||
|
||||
</TransferDestinationToProductGrid>
|
||||
|
||||
@code {
|
||||
[Parameter] public bool KeyboardNavigationEnabled { get; set; }
|
||||
|
||||
[Parameter] public Guid? ContextId { get; set; }
|
||||
|
||||
[Parameter] public int GetAllTag { get; set; }
|
||||
|
||||
public Guid[]? ContextIds = new Guid[1];
|
||||
|
||||
private LoggerClient<TransferDestinationToProductGridComponent> _logger = null!;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
_logger = new LoggerClient<TransferDestinationToProductGridComponent>(LogWriters.ToArray());
|
||||
|
||||
// ReSharper disable once NullCoalescingConditionIsAlwaysNotNullAccordingToAPIContract
|
||||
//_detailGridData = UserModelDtoDetail.ServiceProviders ?? [];
|
||||
//_availableServices = await ServiceProviderDataService.GetServiceProvidersAsync();
|
||||
|
||||
//_logger.Info($"DetailGridData: {_detailGridData.Count}");
|
||||
}
|
||||
|
||||
protected override void OnParametersSet()
|
||||
{
|
||||
ContextIds[0] = (Guid)ContextId!;
|
||||
base.OnParametersSet();
|
||||
}
|
||||
|
||||
// void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
|
||||
// {
|
||||
// if (!e.IsNew) return;
|
||||
|
||||
// var newProductMapping = new UserProductMapping
|
||||
// {
|
||||
// ProductId = Guid.NewGuid(),
|
||||
// UserId = UserModelDtoDetail.Id,
|
||||
// Permissions = 1
|
||||
// };
|
||||
|
||||
// e.EditModel = newProductMapping;
|
||||
// }
|
||||
|
||||
// async Task EditModelSaving(GridEditModelSavingEventArgs e)
|
||||
// {
|
||||
// if (e.IsNew)
|
||||
// //add new orderData to orderData array
|
||||
// _logger.Info("New orderData added");
|
||||
// else
|
||||
// _logger.Info("orderData updated");
|
||||
|
||||
// await UpdateDataAsync();
|
||||
// }
|
||||
|
||||
// async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
|
||||
// {
|
||||
// //remove orderData from orderData array
|
||||
// _logger.Info("orderData deleted");
|
||||
// //await UpdateDataAsync();
|
||||
// }
|
||||
|
||||
// async Task UpdateDataAsync()
|
||||
// {
|
||||
// //refresh grid
|
||||
// _logger.Info("orderData grid refreshed");
|
||||
// }
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
using Microsoft.AspNetCore.Components;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Services;
|
||||
|
||||
namespace TIAMSharedUI.Shared.Components.Grids;
|
||||
|
||||
public class TransferDestinationToProductGrid : TiamGrid<TransferDestinationToProduct>
|
||||
{
|
||||
public TransferDestinationToProductGrid() : base()
|
||||
{
|
||||
GetAllMessageTag = SignalRTags.GetProductsByContextId;
|
||||
AddMessageTag = SignalRTags.AddProduct;
|
||||
UpdateMessageTag = SignalRTags.UpdateProduct;
|
||||
RemoveMessageTag = SignalRTags.RemoveProduct;
|
||||
}
|
||||
|
||||
protected override Task SetParametersAsyncCore(ParameterView parameters)
|
||||
{
|
||||
if (!IsFirstInitializeParameters)
|
||||
{
|
||||
//ShowFilterRow = true;
|
||||
//ShowGroupPanel = true;
|
||||
//AllowSort = false;
|
||||
|
||||
//etc...
|
||||
}
|
||||
|
||||
return base.SetParametersAsyncCore(parameters);
|
||||
}
|
||||
}
|
||||
|
|
@ -18,6 +18,7 @@
|
|||
<DxMenuItem NavigateUrl="user/sysadmin" Text="Dashboard" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/transfers" Text="Transfers" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/companies" Text="Companies" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/prices" Text="Partner prices" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/products" Text="Services" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/drivers" Text="Drivers" />
|
||||
<DxMenuItem NavigateUrl="sysadmin/cars" Text="Cars" />
|
||||
|
|
|
|||
|
|
@ -438,12 +438,13 @@ namespace TIAMWebApp.Server.Controllers
|
|||
[HttpGet]
|
||||
[Route(APIUrls.GetAllProductsRouteName)]
|
||||
[Tags("In-Progress", "Product")]
|
||||
public Task<string> GetAllProducts()
|
||||
[SignalR(SignalRTags.GetAllProducts)]
|
||||
public async Task<string> GetAllProducts()
|
||||
{
|
||||
_logger.Info("GetAllProducts called");
|
||||
|
||||
var products = adminDal.GetProductsJson();
|
||||
return Task.FromResult(products);
|
||||
return products;
|
||||
}
|
||||
|
||||
[AllowAnonymous]
|
||||
|
|
|
|||
Loading…
Reference in New Issue