This commit is contained in:
jozsef.b@aycode.com 2024-04-24 18:24:44 +02:00
commit a8e835b252
46 changed files with 1645 additions and 473 deletions

View File

@ -37,6 +37,7 @@ namespace TIAM.Database.DataLayers.Users
public Task<UserModelDto?> GetUserModelDtoByIdAsync(Guid userId, bool onlyConfirmed) => SessionAsync(x => x.GetUserModelDtoById(userId, onlyConfirmed));
public Task<UserModelDto?> GetUserModelDtoByEmailAsync(string email, bool onlyConfirmed) => SessionAsync(x => x.GetUserModelDtoByEmail(email, onlyConfirmed));
public Task<List<UserModelDto>> GetAllUsersModelDtoAsync() => SessionAsync(x => x.GetAllUsersModelDto().ToList());
public Task<List<UserModelDtoDetail>> GetAllUsersModelDtoDetailAsync() => SessionAsync(x => x.GetAllUsersModelDetailDto().ToList());
public Task<User?> GetUserByPhoneNumberAsync(string phoneNumber)
{

View File

@ -1,6 +1,7 @@
using System.Collections.Specialized;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using AyCode.Entities.Messages;
using AyCode.Interfaces.Entities;
using AyCode.Interfaces.TimeStampInfo;
using AyCode.Interfaces.Users;
@ -8,7 +9,7 @@ using AyCode.Interfaces.Users;
namespace TIAM.Entities.Emails;
[Table(nameof(EmailMessage))]
public class EmailMessage : IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation, IEmailAddress
public class EmailMessage : NoticeBase, IEntityGuid, ITimeStampInfo, IEmailRecipientsRelation, IEmailAddress
{
public EmailMessage()
{

View File

@ -147,9 +147,14 @@ namespace TIAMMobileApp.Services
return (isSuccess, user);
}
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
public async Task<List<UserModelDto>?> GetUsersAsync()
{
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
return await http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers);
}
public async Task<List<UserModelDtoDetail>?> GetUsersWithDetailsAsync()
{
return await http.GetFromJsonAsync<List<UserModelDtoDetail>>(APIUrls.GetUsersWithDetails);
}
public async Task<UserModelDto?> GetUserByEmailAsync(string email)

View File

@ -132,6 +132,15 @@ namespace TIAM.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Comment.
/// </summary>
public static string Comment {
get {
return ResourceManager.GetString("Comment", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Confirm Email.
/// </summary>
@ -231,6 +240,15 @@ namespace TIAM.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to Flight or train number.
/// </summary>
public static string FlightNumber {
get {
return ResourceManager.GetString("FlightNumber", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Forgot password?.
/// </summary>
@ -294,6 +312,15 @@ namespace TIAM.Resources {
}
}
/// <summary>
/// Looks up a localized string similar to (if applicable).
/// </summary>
public static string Optional {
get {
return ResourceManager.GetString("Optional", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Password.
/// </summary>

View File

@ -141,6 +141,9 @@
<data name="ButtonSend" xml:space="preserve">
<value>Küldés</value>
</data>
<data name="Comment" xml:space="preserve">
<value>Megjegyzés</value>
</data>
<data name="ConfirmEmail" xml:space="preserve">
<value>E-mail cím megerősítése</value>
</data>
@ -174,6 +177,9 @@
<data name="EmailAddress" xml:space="preserve">
<value>E-mail</value>
</data>
<data name="FlightNumber" xml:space="preserve">
<value>Járatszám</value>
</data>
<data name="ForgotPassword" xml:space="preserve">
<value>Elfelejtett jelszó</value>
</data>
@ -195,6 +201,9 @@
<data name="NumberOfPassengers" xml:space="preserve">
<value>Utasok száma</value>
</data>
<data name="Optional" xml:space="preserve">
<value>(ha van)</value>
</data>
<data name="Password" xml:space="preserve">
<value>Jelszó</value>
</data>

View File

@ -141,6 +141,9 @@
<data name="ButtonSend" xml:space="preserve">
<value>Send</value>
</data>
<data name="Comment" xml:space="preserve">
<value>Comment</value>
</data>
<data name="ConfirmEmail" xml:space="preserve">
<value>Confirm Email</value>
</data>
@ -174,6 +177,9 @@
<data name="EmailAddress" xml:space="preserve">
<value>Email</value>
</data>
<data name="FlightNumber" xml:space="preserve">
<value>Flight or train number</value>
</data>
<data name="ForgotPassword" xml:space="preserve">
<value>Forgot password?</value>
</data>
@ -195,6 +201,9 @@
<data name="NumberOfPassengers" xml:space="preserve">
<value>Passengers</value>
</data>
<data name="Optional" xml:space="preserve">
<value>(if applicable)</value>
</data>
<data name="Password" xml:space="preserve">
<value>Password</value>
</data>

View File

@ -0,0 +1,21 @@
<h3>
@NullText
</h3>
<DxTextBox @ref="firstNameTextField"
TextChanged="@((newValue) => OnFirstNameChanged(newValue))"
TextExpression="@(() => FirstName)"
CssClass="form-field w-100"
NullText="First name">
</DxTextBox>
<DxTextBox @ref="lastNameTextField"
TextChanged="@((newValue) => OnLastNameChanged(newValue))"
TextExpression="@(() => LastName)"
CssClass="form-field w-100"
NullText="Last name">
</DxTextBox>
@code {
}

View File

@ -0,0 +1,66 @@
using DevExpress.Blazor;
using Microsoft.AspNetCore.Components;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TIAMSharedUI.Pages.Components
{
public partial class FullNameEditor : ComponentBase
{
[Parameter]
public string FirstName { get; set; }
[Parameter]
public string LastName { get; set; }
public string FullName { get; set; }
[Parameter]
public string NullText { get; set; }
[Parameter]
public EventCallback<string> FirstNameChanged { get; set; }
[Parameter]
public EventCallback<string> LastNameChanged { get; set; }
public int InputDelay { get; set; } = 500;
public DxTextBox firstNameTextField;
public DxTextBox lastNameTextField;
void OnFirstNameChanged(string newValue)
{
if (!string.IsNullOrEmpty(newValue))
{
FirstName = newValue;
FullName = $"{newValue} {LastName}";
}
else
{
FirstName = null;
firstNameTextField.Text = "Invalid data";
}
FirstNameChanged.InvokeAsync(newValue);
}
void OnLastNameChanged(string newValue)
{
if (!string.IsNullOrEmpty(newValue))
{
LastName = newValue;
FullName = $"{FirstName} {newValue}";
}
else
{
LastName = null;
lastNameTextField.Text = "Invalid data";
}
LastNameChanged.InvokeAsync(newValue);
}
}
}

View File

@ -268,6 +268,8 @@ namespace TIAMSharedUI.Pages.Components
editor.OpenComponent<DxDateEdit<DateTime>>(j);
editor.AddAttribute(j++, "Date", property.GetValue(Data));
editor.AddAttribute(j++, "DateExpression", lambda);
editor.AddAttribute(j++, "TimeSectionVisible", true);
editor.AddAttribute(j++, "TimeSectionScrollPickerFormat", "tt h m");
editor.AddAttribute(j++, "CssClass", "form-field");
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); }));
editor.CloseComponent();
@ -378,6 +380,67 @@ namespace TIAMSharedUI.Pages.Components
}
else if (property.PropertyType == typeof(string) && string.Compare(attrList.CustomDataType, "FullName", true) == 0)
{
editor.OpenComponent<FullNameEditor>(j);
editor.AddAttribute(j++, "NullText", "Please tell us your name.");
editor.AddAttribute(j++, "FirstNameChanged", EventCallback.Factory.Create<string>(this, result =>
{
LogToBrowserConsole.LogToBC($"FirstName changed to {result}");
//find property with name FirstName
PropertyInfo firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName");
firstNameProperty.SetValue(Data, result);
//find property with name LastName
PropertyInfo lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName");
//combine the two values, if they are not null
if (firstNameProperty != null && lastNameProperty != null)
{
string firstName = result;
string lastName = (string)lastNameProperty.GetValue(Data);
string fullName = $"{firstName} {lastName}";
property.SetValue(Data, fullName);
}
}));
editor.AddAttribute(j++, "LastNameChanged", EventCallback.Factory.Create<string>(this, result =>
{
LogToBrowserConsole.LogToBC($"LastName changed to {result}");
//find property with name FirstName
PropertyInfo firstNameProperty = propertyList.FirstOrDefault(p => p.Name == "FirstName");
//find property with name LastName
PropertyInfo lastNameProperty = propertyList.FirstOrDefault(p => p.Name == "LastName");
lastNameProperty.SetValue(Data, result);
//combine the two values, if they are not null
if (firstNameProperty != null && lastNameProperty != null)
{
string firstName = (string)firstNameProperty.GetValue(Data);
string lastName = result;
string fullName = $"{firstName} {lastName}";
property.SetValue(Data, fullName);
}
LogToBrowserConsole.LogToBC($"bleh: {property.Name} = {property.GetValue(Data)}");
StateHasChanged(); // Add this line to refresh the UI
}));
editor.CloseComponent();
editor.OpenComponent<DxTextBox>(j++);
/*editor.AddAttribute(j++, "CssClass", "form-field");*/
editor.AddAttribute(j++, "NullText", "Please type in the above fields");
editor.AddAttribute(j++, "Enabled", false);
editor.AddAttribute(j++, "Text", property.GetValue(Data));
editor.AddAttribute(j++, "TextExpression", lambda);
editor.AddAttribute(j++, "TextChanged", EventCallback.Factory.Create<string>(this, str =>
{
property.SetValue(Data, str);
LogToBrowserConsole.LogToBC($"bleh: {property.Name} = {property.GetValue(Data)}");
}));
editor.CloseComponent();
}
break;
}

View File

@ -378,12 +378,14 @@ new HeroSliderItem
public List<string> TransferIgnorList = new List<string>
{
"Id",
"Id",
"UserId",
"Destination",
"PickupAddress",
"ProductId",
"TripDate",
"FirstName",
"LastName",
"UserProductMappingId",
"UserProductToCarId",
"ReferralId",

View File

@ -125,15 +125,15 @@
public List<string> TransferIgnorList = new List<string>
{
"Id",
"UserId",
"ProductId",
"Id",
"UserId",
"ProductId",
"FirstName",
"LastName",
"UserProductMappingId",
"UserProductToCarId",
"ReferralId",
"Price",
"Driver",
"Comment"
"Price"
};
/*protected override void OnAfterRender(bool isFirst)

View File

@ -25,6 +25,7 @@
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
<DxGridDataColumn FieldName="CarId" Width="40%" />
<DxGridDataColumn FieldName="LicencePlate" />
@ -35,7 +36,7 @@
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter]
public TIAM.Entities.Transfers.Transfer Customer { get; set; }
public Transfer Customer { get; set; }
List<TransferToDriver> DetailGridData { get; set; }

View File

@ -0,0 +1,7 @@
<h3>ManageMessages</h3>
<Messages/>
@code {
}

View File

@ -1,4 +1,4 @@

@page "/user/products"
@using AyCode.Models.Messages
@using TIAM.Entities.ServiceProviders
@using TIAM.Resources
@ -8,6 +8,7 @@
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
@using TIAMWebApp.Shared.Application.Utility
@layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole
@inject IStringLocalizer<TIAMResources> localizer
@ -97,5 +98,6 @@
@code {
}

View File

@ -11,15 +11,21 @@ using Microsoft.AspNetCore.Components;
using TIAM.Entities.ServiceProviders;
using TIAM.Core.Enums;
using TIAMWebApp.Shared.Application.Services;
using TIAMWebApp.Shared.Application.Utility;
namespace TIAMSharedUI.Pages.User.SysAdmins
{
public partial class Products :ComponentBase
public partial class ManageProducts :ComponentBase
{
IGrid Grid { get; set; }
object? ProductData { get; set; }
public void ColumnChooserButton_Click()
{
Grid.ShowColumnChooser();
}
public ProductWizardModel myModel = new ProductWizardModel();
@ -158,10 +164,5 @@ namespace TIAMSharedUI.Pages.User.SysAdmins
}
}
void ColumnChooserButton_Click()
{
Grid.ShowColumnChooser();
}
}
}

View File

@ -0,0 +1,421 @@
@page "/user/transfers"
@using AyCode.Models.Messages
@using BlazorAnimation
@using TIAM.Core.Enums
@using TIAM.Entities.ServiceProviders
@using TIAM.Entities.Transfers
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole
@inject IStringLocalizer<TIAMResources> localizer
@inject IWizardProcessor wizardProcessor
@inject ITransferDataService transferDataService
<PageTitle>Transfers</PageTitle>
<div class="text-center m-5">
<h1>Transfer management</h1>
<h2 style="font-size:small">Manage transfers here!</h2>
</div>
<DxPopup CssClass="popup-demo-events"
@bind-Visible="@PopupVisible"
ShowFooter="true"
CloseOnEscape="true"
CloseOnOutsideClick="false"
ShowCloseButton="false"
HeaderText="MessageBox"
Closing="EulaPopupClosing"
Closed="EulaPopupClosed">
<BodyContentTemplate>
<InputWizard Data=@messageWizardModel
OnSubmit="SubmitForm"
IgnoreReflection=@ignoreList
TitleResourceString="NewMessage"
SubtitleResourceString="NewMessageSubtitle"
SubmitButtonText="ButtonSend"></InputWizard>
</BodyContentTemplate>
<FooterContentTemplate Context="Context">
<div class="popup-demo-events-footer">
<!--DxCheckBox CssClass="popup-demo-events-checkbox" @bind-Checked="@EulaAccepted">I accept the terms of the EULA</!--DxCheckBox-->
<!--DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="Context.CloseCallback" /-->
<DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Secondary" Text="Cancel" Click="CancelCreateClick" />
</div>
</FooterContentTemplate>
</DxPopup>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.Pulse" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<DxTabs>
<DxTabPage Text="DataGrid">
<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>
<DxGrid @ref="Grid2"
Data="TransferData"
AutoCollapseDetailRow="AutoCollapseDetailRow"
KeyboardNavigationEnabled="true"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"
KeyFieldName="Id">
<Columns>
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" />
<DxGridDataColumn FieldName="OrderId" />
<DxGridDataColumn FieldName="FromAddress" />
<DxGridDataColumn FieldName="ToAddress" />
<DxGridDataColumn FieldName="Appointment" DisplayFormat="f" />
<DxGridDataColumn FieldName="FullName" />
<DxGridDataColumn FieldName="ContactPhone" />
<DxGridDataColumn FieldName="ContactEmail">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (Transfer)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="PassengerCount" />
<DxGridDataColumn FieldName="TransferStatusType">
<CellDisplayTemplate>
@{
TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == Convert.ToInt16(context.Value));
string transferStatusText = keyField.StatusName;
<p>@transferStatusText</p>
}
</CellDisplayTemplate>
</DxGridDataColumn>
</Columns>
<DetailRowTemplate>
<Grid_MasterDetail_NestedGrid_DetailContent Customer="(TIAM.Entities.Transfers.Transfer)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
@{
var transfer2 = (Transfer)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.FirstName) ColSpanMd="6">
@EditFormContext.GetEditor("FirstName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6">
@EditFormContext.GetEditor("LastName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("ToAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PickupAddress) ColSpanMd="6">
@EditFormContext.GetEditor("FromAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Trip date:" ColSpanMd="6">
<DxDateEdit @bind-Date="@transfer2.Appointment"
TimeSectionVisible="true"
TimeSectionScrollPickerFormat="tt h m">
</DxDateEdit>
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Passengers:" ColSpanMd="6">
@EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Status:" ColSpanMd="6">
@EditFormContext.GetEditor("TransferStatusType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</div>
</DxTabPage>
<DxTabPage Text="Calendar">
<div class="d-flex flex-column mb-4 pb-2">
<DxScheduler @bind-StartDate="@StartDate"
DataStorage="@DataStorage"
CssClass="w-100">
<DxSchedulerTimelineView Duration="@TimeSpan.FromHours(48)" CellMinWidth="80">
<Scales>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Day" UnitCount="1"></DxSchedulerTimeScale>
<DxSchedulerTimeScale Unit="@SchedulerTimeScaleUnit.Hour" UnitCount="2"></DxSchedulerTimeScale>
</Scales>
</DxSchedulerTimelineView>
<DxSchedulerWeekView ShowWorkTimeOnly="false"></DxSchedulerWeekView>
<DxSchedulerDayView DayCount="1" ShowWorkTimeOnly="false"></DxSchedulerDayView>
</DxScheduler>
</div>
</DxTabPage>
</DxTabs>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
public Transfer myModel = new Transfer();
public List<Transfer> TransferData { get; set; }
bool PopupVisible { get; set; }
public List<string> ignoreList = new List<string>
{
"ReceiverEmailAddress",
"ReceiverId",
"SenderEmailAddress",
"SenderId",
"ContextId"
};
public List<TransferStatusModel>? Statuses { get; set; }
public MessageWizardModel messageWizardModel = new MessageWizardModel();
public List<AppointmentModel>? AppoinmentData { get; set; }
DateTime StartDate { get; set; } = DateTime.Today;
DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage();
void SendMail(Transfer Item)
{
logToBrowserConsole.LogToBC($"Sending mail to {Item.ContactEmail}");
PopupVisible = true;
}
void CancelCreateClick()
{
PopupVisible = false;
}
void EulaPopupClosed()
{
//cancel clicked
}
void EulaPopupClosing(PopupClosingEventArgs args)
{
//myModel = new TransferWizardModel();
messageWizardModel = new MessageWizardModel();
}
//-----------------------------------------------------------------------------------
public async Task SubmitForm(object Result)
{
var email = await wizardProcessor.ProcessWizardAsync<MessageWizardModel>(Result.GetType(), Result);
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow && (System.Byte)e.Grid.GetRowValue(e.VisibleIndex, "TransferStatusType") == 5)
{
e.CssClass = "bg-important";
}
else if (e.ElementType == GridElementType.DataRow && (System.Byte)e.Grid.GetRowValue(e.VisibleIndex, "TransferStatusType") > 5 && (System.Byte)e.Grid.GetRowValue(e.VisibleIndex, "TransferStatusType") < 35)
{
e.CssClass = "bg-attention";
}
else if (e.ElementType == GridElementType.DataRow && (System.Byte)e.Grid.GetRowValue(e.VisibleIndex, "TransferStatusType") == 35)
{
e.CssClass = "bg-finished";
}
else if (e.ElementType == GridElementType.DataRow && (System.Byte)e.Grid.GetRowValue(e.VisibleIndex, "TransferStatusType") > 35)
{
e.CssClass = "bg-cancel";
}
if (e.ElementType == GridElementType.HeaderCell)
{
e.Style = "background-color: rgba(0, 0, 0, 0.08)";
e.CssClass = "header-bold";
}
}
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (e.IsNew)
{
var transferEditModel = (Transfer)e.EditModel; //TODO not valid cast
transferEditModel.Id = Guid.NewGuid();
transferEditModel.ToAddress = "Where to?";
transferEditModel.FromAddress = "From where?";
transferEditModel.Appointment = DateTime.UtcNow.AddDays(3);
transferEditModel.PassengerCount = 1;
transferEditModel.FirstName = "John";
transferEditModel.LastName = "Doe";
transferEditModel.ContactPhone = "+00000000000";
transferEditModel.ContactEmail = "your@email.address";
}
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{
bool success = false;
if (e.IsNew)
{
//add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added");
//await transferDataService.CreateTransfer((TransferWizardModel)e.EditModel);
}
else
{
logToBrowserConsole.LogToBC("orderData updated at id " + ((Transfer)e.EditModel).Id);
success = await transferDataService.UpdateTransferAsync((Transfer)e.EditModel);
}
//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;
// }
// }
if (success)
await UpdateDataAsync();
}
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
logToBrowserConsole.LogToBC("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//refresh grid
TransferData = await transferDataService.GetTransfersAsync();
logToBrowserConsole.LogToBC("orderData grid refreshed");
}
protected override async Task OnInitializedAsync()
{
Statuses = new List<TransferStatusModel>
{
new TransferStatusModel(Convert.ToInt16(TransferStatusType.OrderSubmitted), "Order submitted"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.OrderConfirmed), "Order confirmed"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.AssignedToDriver), "Assigned to driver"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.DriverConfirmed), "Driver confirmed"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.DriverEnRoute), "Driver enroute"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.PassengerPickup), "Passenger in car"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.Finished), "Finished"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.UserCanceled), "User cancelled"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.AdminDenied), "Admin cancelled")
};
TransferData = (await transferDataService.GetTransfersAsync()).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList();
AppoinmentData = new List<AppointmentModel>();
foreach (var transfer in TransferData)
{
// var bnm = DataStorage.CreateAppointmentItem();
// bnm.Start = transfer.Appointment;
// bnm.Description = $"{transfer.FullName}, {transfer.ToAddress}";
// bnm.Location = transfer.FromAddress;
// bnm.Subject = "Simple transfer";
AppoinmentData.Add(new AppointmentModel { StartDate = transfer.Appointment, EndDate=transfer.Appointment.AddMinutes(30), Description = $"{transfer.FullName}, {transfer.ToAddress}", Location = transfer.FromAddress, Caption = "Simple transfer" });
}
DataStorage = new DxSchedulerDataStorage();
DataStorage.AppointmentMappings = new DxSchedulerAppointmentMappings()
{
Type = "AppointmentType",
Start = "StartDate",
End = "EndDate",
Subject = "Caption",
AllDay = "AllDay",
Location = "Location",
Description = "Description",
LabelId = "Label",
StatusId = "Status",
RecurrenceInfo = "Recurrence"
};
DataStorage.AppointmentsSource = AppoinmentData;
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid2.ShowColumnChooser();
}
IGrid Grid2 { get; set; }
object MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
Grid2.ExpandDetailRow(0);
}
}
void AutoCollapseDetailRow_Changed(bool newValue)
{
AutoCollapseDetailRow = newValue;
if (newValue)
{
Grid2.BeginUpdate();
Grid2.CollapseAllDetailRows();
Grid2.ExpandDetailRow(0);
Grid2.EndUpdate();
}
}
}

View File

@ -0,0 +1,337 @@
@page "/user/users"
@using AyCode.Models.Messages
@using BlazorAnimation
@using TIAM.Core.Enums
@using TIAM.Entities.Products
@using TIAM.Entities.ServiceProviders
@using TIAM.Entities.Transfers
@using TIAM.Entities.Users
@using TIAM.Models.Dtos.Profiles
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility
@layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole
@inject IStringLocalizer<TIAMResources> localizer
@inject ISessionService sessionService
@inject IWizardProcessor wizardProcessor
@inject IUserDataService userDataService
<PageTitle>Transfers</PageTitle>
<div class="text-center m-5">
<h1>User management</h1>
<h2 style="font-size:small">Manage transfers here!</h2>
</div>
<DxPopup CssClass="popup-demo-events"
@bind-Visible="@PopupVisible"
ShowFooter="true"
CloseOnEscape="true"
CloseOnOutsideClick="false"
ShowCloseButton="false"
HeaderText="MessageBox"
Closing="EulaPopupClosing"
Closed="EulaPopupClosed">
<BodyContentTemplate>
<InputWizard Data=@messageWizardModel
OnSubmit="SubmitForm"
IgnoreReflection=@ignoreList
TitleResourceString="NewMessage"
SubtitleResourceString="NewMessageSubtitle"
SubmitButtonText="ButtonSend"></InputWizard>
</BodyContentTemplate>
<FooterContentTemplate Context="Context">
<div class="popup-demo-events-footer">
<!--DxCheckBox CssClass="popup-demo-events-checkbox" @bind-Checked="@EulaAccepted">I accept the terms of the EULA</!--DxCheckBox-->
<!--DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Primary" Text="OK" Click="Context.CloseCallback" /-->
<DxButton CssClass="popup-demo-events-button ms-2" RenderStyle="ButtonRenderStyle.Secondary" Text="Cancel" Click="CancelCreateClick" />
</div>
</FooterContentTemplate>
</DxPopup>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" 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>
<DxGrid @ref="Grid"
Data="UserData"
AutoCollapseDetailRow="AutoCollapseDetailRow"
KeyboardNavigationEnabled="true"
CustomizeElement="Grid_CustomizeElement"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"
KeyFieldName="Id">
<Columns>
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" />
<DxGridDataColumn FieldName="Profile.FullName" />
<DxGridDataColumn FieldName="UserDto.PhoneNumber" />
<DxGridDataColumn FieldName="UserDto.Created" />
<DxGridDataColumn FieldName="UserDto.EmailConfirmed" />
<DxGridDataColumn FieldName="UserDto.RefferalId" />
<DxGridDataColumn FieldName="UserDto.EmailAddress">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (UserModelDtoDetail)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>
</Columns>
<DetailRowTemplate>
<UserGrid_MasterDetail_NestedGrid_UserProductMapping Customer="(UserModelDtoDetail)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
@{
var transfer2 = (UserModelDtoDetail)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.EmailAddress) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.EmailAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.EmailAddress) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.EmailAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.ConfirmEmail) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.EmailConfirmed")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PhoneNumber) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.PhoneNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.FirstName) ColSpanMd="4">
@EditFormContext.GetEditor("Profile.FirstName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="4">
@EditFormContext.GetEditor("Profile.LastName")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
public UserModelDtoDetail myModel = new UserModelDtoDetail();
public List<UserModelDtoDetail>? UserData { get; set; }
bool PopupVisible { get; set; }
IGrid? Grid { get; set; }
object? MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
public List<string> ignoreList = new List<string>
{
"ReceiverEmailAddress",
"ReceiverId",
"SenderEmailAddress",
"SenderId",
"ContextId"
};
public MessageWizardModel messageWizardModel = new MessageWizardModel();
async void SendMail(UserModelDtoDetail Item)
{
var user = await userDataService.GetUserDetailByIdAsync(Item.Id);
logToBrowserConsole.LogToBC($"Sending mail to {user.UserDto.EmailAddress}");
messageWizardModel.ReceiverId = user.Id;
messageWizardModel.ReceiverEmailAddress = user.UserDto.EmailAddress;
messageWizardModel.SenderId = sessionService.User.UserId;
messageWizardModel.SenderEmailAddress = sessionService.User.Email;
logToBrowserConsole.LogToBC($"Sending mail to {messageWizardModel.ReceiverEmailAddress} from {messageWizardModel.SenderId}");
PopupVisible = true;
}
void CancelCreateClick()
{
PopupVisible = false;
}
void EulaPopupClosed()
{
//cancel clicked
}
void EulaPopupClosing(PopupClosingEventArgs args)
{
//myModel = new TransferWizardModel();
messageWizardModel = new MessageWizardModel();
}
//-----------------------------------------------------------------------------------
public async Task SubmitForm(object Result)
{
var email = await wizardProcessor.ProcessWizardAsync<MessageWizardModel>(Result.GetType(), Result);
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
}
void Grid_CustomizeElement(GridCustomizeElementEventArgs e)
{
if (e.ElementType == GridElementType.DataRow && e.VisibleIndex % 2 == 1)
{
e.CssClass = "bg-alt";
}
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)
{
var userEditModel = (UserModelDtoDetail)e.EditModel; //TODO not valid cast
userEditModel.Id = Guid.NewGuid();
userEditModel.UserDto = new UserDtoDetail();
userEditModel.UserDto.AffiliateId = Guid.NewGuid();
userEditModel.UserDto.EmailAddress = "";
userEditModel.UserDto.PhoneNumber = "";
userEditModel.Profile = new ProfileDto();
userEditModel.Profile.Name = "New user";
userEditModel.Products = new List<Product>();
userEditModel.ServiceProviders = new List<TiamServiceProvider>();
userEditModel.UserProductMappings = new List<UserProductMapping>();
}
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
{
//add new orderData to orderData array
RegistrationModel registration = new RegistrationModel();
//TODO: Refractor to userDataService
Random random = new Random();
string chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890";
string password = new string(Enumerable.Repeat(chars, 10)
.Select(s => s[random.Next(s.Length)]).ToArray());
registration.Email = ((UserModelDtoDetail)e.EditModel).UserDto.EmailAddress;
registration.PhoneNumber = ((UserModelDtoDetail)e.EditModel).UserDto.PhoneNumber;
registration.Password = password;
registration.ReferralId = null;
await userDataService.CreateGuestUser(registration);
logToBrowserConsole.LogToBC("New user created added");
}
else
{
logToBrowserConsole.LogToBC("orderData updated at id " + ((UserModelDtoDetail)e.EditModel).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;
// }
// }
await UpdateDataAsync();
}
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
logToBrowserConsole.LogToBC("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//refresh grid
UserData = await userDataService.GetUsersWithDetailsAsync();
logToBrowserConsole.LogToBC("orderData grid refreshed");
}
protected override async Task OnInitializedAsync()
{
UserData = (await userDataService.GetUsersWithDetailsAsync())?.OrderBy(x => x.Profile?.Name).ToList();
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid?.ShowColumnChooser();
}
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
Grid?.ExpandDetailRow(0);
}
}
void AutoCollapseDetailRow_Changed(bool newValue)
{
AutoCollapseDetailRow = newValue;
if (newValue)
{
Grid?.BeginUpdate();
Grid?.CollapseAllDetailRows();
Grid?.ExpandDetailRow(0);
Grid?.EndUpdate();
}
}
}

View File

@ -1,393 +0,0 @@
@page "/user/transfers"
@using AyCode.Models.Messages
@using BlazorAnimation
@using TIAM.Core.Enums
@using TIAM.Entities.ServiceProviders
@using TIAM.Entities.Transfers
@using TIAM.Models.Dtos.Users
@using TIAM.Resources
@using TIAMSharedUI.Pages.Components
@using TIAMSharedUI.Shared
@using TIAMWebApp.Shared.Application.Interfaces
@using TIAMWebApp.Shared.Application.Models
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
@using TIAMWebApp.Shared.Application.Utility
@layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole
@inject IStringLocalizer<TIAMResources> localizer
@inject IWizardProcessor wizardProcessor
@inject ITransferDataService transferDataService
<PageTitle>Transfers</PageTitle>
<div class="text-center m-5">
<h1>Transfer management</h1>
<h2 style="font-size:small">Manage transfers here!</h2>
</div>
<div class="container">
<div class="row">
<div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card">
<div class="d-flex flex-column mb-4 pb-2">
<DxGrid @ref="Grid2"
Data="TransferData"
AutoCollapseDetailRow="AutoCollapseDetailRow"
KeyboardNavigationEnabled="true"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true"
KeyFieldName="Id">
<Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" SortIndex="0" />
<DxGridDataColumn FieldName="OrderId" />
<DxGridDataColumn FieldName="FromAddress" />
<DxGridDataColumn FieldName="ToAddress" />
<DxGridDataColumn FieldName="Appointment" />
<DxGridDataColumn FieldName="PassengerCount" />
<DxGridDataColumn FieldName="TransferStatusType">
<CellDisplayTemplate>
@{
TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == Convert.ToInt16(context.Value));
string driverText = keyField.StatusName;
<p>@driverText</p>
}
</CellDisplayTemplate>
</DxGridDataColumn>
</Columns>
<DetailRowTemplate>
<Grid_MasterDetail_NestedGrid_DetailContent Customer="(TIAM.Entities.Transfers.Transfer)context.DataItem" KeyboardNavigationEnabled="true" />
</DetailRowTemplate>
<EditFormTemplate Context="EditFormContext">
@{
var transfer2 = (Transfer)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("ToAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PickupAddress) ColSpanMd="6">
@EditFormContext.GetEditor("FromAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Trip date:" ColSpanMd="6">
@EditFormContext.GetEditor("Appointment")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Passengers:" ColSpanMd="6">
@EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Status:" ColSpanMd="6">
@EditFormContext.GetEditor("TransferStatusType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</div>
<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>
<DxGrid @ref="Grid"
Data="TransferData"
PageSize="8"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="Grid_CustomizeEditModel"
EditModelSaving="Grid_EditModelSaving"
DataItemDeleting="Grid_DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
KeyboardNavigationEnabled="true"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" MinWidth="80" Width="20%" Visible="false" />
<DxGridDataColumn FieldName="ToAddress" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80">
<CellDisplayTemplate>
@{
var keyField = context.Value;
<a class="d-block text-left" href="transferdetails">@context.Value</a>
}
</CellDisplayTemplate>
</DxGridDataColumn>
<DxGridDataColumn FieldName="FromAddress" FixedPosition="GridColumnFixedPosition.Left" MinWidth="80" />
<DxGridDataColumn FieldName="Appointment" MinWidth="80" Width="20%" />
<DxGridDataColumn FieldName="PassengerCount" MinWidth="40" Width="3%" />
@* <DxGridDataColumn FieldName="Drivers" MinWidth="80" /> *@
@*<DxGridDataColumn FieldName="PhoneNumber" MinWidth="80" Width="10%" />
<DxGridDataColumn FieldName="EmailAddress" MinWidth="80" Width="10%">
<CellDisplayTemplate>
@{
var keyField = context.Value;
var keyItem = (TransferWizardModel)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
}
</CellDisplayTemplate>
</DxGridDataColumn>*@
@* <DxGridDataColumn FieldName="Driver" FixedPosition="GridColumnFixedPosition.Right" MinWidth="80" Width="15%">
<CellDisplayTemplate>
@{
DriverModel keyField = (DriverModel)context.Value;
string driverText = keyField.Name;
<p>@driverText</p>
}
</CellDisplayTemplate>
</DxGridDataColumn> *@
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer = (TransferWizardModel)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
@EditFormContext.GetEditor("ToAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PickupAddress) ColSpanMd="6">
@EditFormContext.GetEditor("FromAddress")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Trip date:" ColSpanMd="6">
@EditFormContext.GetEditor("Appointment")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Passengers:" ColSpanMd="6">
@EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
@* <DxFormLayoutItem Caption="Full name:" ColSpanMd="6">
@EditFormContext.GetEditor("FullName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Phone number:" ColSpanMd="6">
@EditFormContext.GetEditor("PhoneNumber")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Email:" ColSpanMd="6">
@EditFormContext.GetEditor("EmailAddress")
</DxFormLayoutItem> *@
@*<DxFormLayoutItem Caption="Driver:" ColSpanMd="6">
<DxComboBox Data="@drivers"
NullText="Select driver..."
FilteringMode="DataGridFilteringMode.Contains"
TextFieldName="Name"
ValueFieldName="Name"
Value="@transfer.Driver.Name"
ValueChanged="(string newCellValue) => {
transfer.Driver = drivers.FirstOrDefault(x => x.Name == newCellValue);
logToBrowserConsole.LogToBC(newCellValue);
}">
</DxComboBox>
</DxFormLayoutItem> *@
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
</div>
</div>
</Animation>
</div>
<div class=" col-12 col-xl-6">
</div>
</div>
</div>
@code {
IGrid Grid { get; set; }
//object? TransferData { get; set; }
public TransferWizardModel myModel = new TransferWizardModel();
public List<Transfer> TransferData { get; set; }
bool PopupVisible { get; set; }
public List<string> ignoreList = new List<string>
{
"ReceiverEmailAddress",
"ReceiverId",
"SenderEmailAddress",
"SenderId",
"ContextId"
};
public List<TransferStatusModel> Statuses { get; set; }
public MessageWizardModel messageWizardModel = new MessageWizardModel();
//IEnumerable<DriverModel> drivers { get; set; }
void SendMail(TransferWizardModel Item)
{
logToBrowserConsole.LogToBC($"Sending mail to {Item.EmailAddress}");
PopupVisible = true;
}
void CancelCreateClick()
{
PopupVisible = false;
}
void EulaPopupClosed()
{
//cancel clicked
}
void EulaPopupClosing(PopupClosingEventArgs args)
{
//myModel = new TransferWizardModel();
messageWizardModel = new MessageWizardModel();
}
//-----------------------------------------------------------------------------------
public async Task SubmitForm(object Result)
{
var email = await wizardProcessor.ProcessWizardAsync<MessageWizardModel>(Result.GetType(), Result);
logToBrowserConsole.LogToBC($"Submitted nested form: {Result.GetType().FullName}");
}
protected override async Task OnAfterRenderAsync(bool firstRender)
{
//if (firstRender)
// await Grid.StartEditRowAsync(0);
}
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (e.IsNew)
{
var newEmployee = (TransferWizardModel)e.EditModel;
newEmployee.Id = Guid.NewGuid();
newEmployee.Destination = "ghjgkg hkgh ghjkghgkjgh";
newEmployee.PickupAddress = "ghjgkg hkgh ghjkghgkjgh";
newEmployee.TripDate = DateTime.UtcNow.AddDays(3);
newEmployee.NumberOfPassengers = 1;
newEmployee.FullName = "ghjgkg hkgh ghjkghgkjgh";
newEmployee.PhoneNumber = "+13021234567";
newEmployee.EmailAddress = "ghjgkg hkgh ghjkghgkjgh";
}
}
async Task Grid_EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
//add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added");
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
else
logToBrowserConsole.LogToBC("orderData updated");
//modify transferData where transferData.Id == e.EditModel.Id
//get transfer from TransferData by Id
foreach (var transferToModify in (List<Transfer>)TransferData)
{
myModel = (TransferWizardModel)e.EditModel;
if (transferToModify.Id == myModel.Id)
{
//transferToModify.Driver = myModel.Driver;
}
}
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
await UpdateDataAsync();
}
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
logToBrowserConsole.LogToBC("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
//refresh grid
logToBrowserConsole.LogToBC("orderData grid refreshed");
}
protected override async Task OnInitializedAsync()
{
Statuses = new List<TransferStatusModel>
{
new TransferStatusModel(Convert.ToInt16(TransferStatusType.OrderSubmitted), "Order submitted"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.OrderConfirmed), "Order confirmed"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.AssignedToDriver), "Assigned to driver"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.DriverConfirmed), "Driver confirmed"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.DriverEnRoute), "Driver enroute"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.PassengerPickup), "Passenger in car"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.Finished), "Finished"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.UserCanceled), "User cancelled"),
new TransferStatusModel(Convert.ToInt16(TransferStatusType.AdminDenied), "Admin cancelled")
};
TransferData = (await transferDataService.GetTransfersAsync()).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList();
base.OnInitialized();
}
void ColumnChooserButton_Click()
{
Grid2.ShowColumnChooser();
}
IGrid Grid2 { get; set; }
object MasterGridData { get; set; }
bool AutoCollapseDetailRow { get; set; }
protected override void OnAfterRender(bool firstRender)
{
if (firstRender)
{
Grid2.ExpandDetailRow(0);
}
}
void AutoCollapseDetailRow_Changed(bool newValue)
{
AutoCollapseDetailRow = newValue;
if (newValue)
{
Grid2.BeginUpdate();
Grid2.CollapseAllDetailRows();
Grid2.ExpandDetailRow(0);
Grid2.EndUpdate();
}
}
}

View File

@ -0,0 +1,122 @@
@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.Utility
@inject IUserDataService NwindDataService
@inject IServiceProviderDataService serviceProviderDataService
@inject LogToBrowserConsole logToBrowserConsole
<div class="mb-2">
UserProductMapping
</div>
<DxGrid Data="DetailGridData"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditModelSaving="EditModelSaving"
DataItemDeleting="DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer2 = (UserProductMapping)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanMd="4">
@EditFormContext.GetEditor("UserId")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
<DxComboBox Data="@AvailableServices" TextFieldName="Name" @bind-Value="((UserProductMapping)EditFormContext.EditModel).ProductId" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
@EditFormContext.GetEditor("Permissions")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter]
public UserModelDtoDetail Customer { get; set; }
List<TiamServiceProvider> DetailGridData;
List<TiamServiceProvider> AvailableServices;
public UserModelDtoDetail UserInfo;
protected override async Task OnInitializedAsync()
{
//get userproductmappings by customer id
if (Customer.ServiceProviders == null)
DetailGridData = new List<TiamServiceProvider>();
else
DetailGridData = Customer.ServiceProviders;
AvailableServices = await serviceProviderDataService.GetServiceProvidersAsync();
logToBrowserConsole.LogToBC($"DetailGridData: {DetailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (e.IsNew)
{
UserProductMapping newProductMapping = new UserProductMapping();
newProductMapping.ProductId = Guid.NewGuid();
newProductMapping.UserId = Customer.Id;
newProductMapping.Permissions = 1;
e.EditModel = newProductMapping;
}
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
//add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added");
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
else
logToBrowserConsole.LogToBC("orderData updated");
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
logToBrowserConsole.LogToBC("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
//refresh grid
logToBrowserConsole.LogToBC("orderData grid refreshed");
}
}

View File

@ -0,0 +1,121 @@
@using TIAM.Entities.Products
@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.Utility
@inject IUserDataService NwindDataService
@inject IServiceProviderDataService serviceProviderDataService
@inject LogToBrowserConsole logToBrowserConsole
<div class="mb-2">
UserProductMapping
</div>
<DxGrid Data="DetailGridData"
PageSize="5"
AutoExpandAllGroupRows="true"
KeyboardNavigationEnabled="KeyboardNavigationEnabled"
KeyFieldName="Id"
ValidationEnabled="false"
CustomizeEditModel="CustomizeEditModel"
EditModelSaving="EditModelSaving"
DataItemDeleting="DataItemDeleting"
EditMode="GridEditMode.EditForm"
ColumnResizeMode="GridColumnResizeMode.NextColumn"
ShowFilterRow="true">
<Columns>
<DxGridCommandColumn NewButtonVisible="true" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" GroupIndex="0" />
<DxGridDataColumn FieldName="UserId" />
<DxGridDataColumn FieldName="ProductId" Width="40%" />
<DxGridDataColumn FieldName="Permissions" />
</Columns>
<EditFormTemplate Context="EditFormContext">
@{
var transfer2 = (UserProductMapping)EditFormContext.EditModel;
}
<DxFormLayout CssClass="w-100">
<DxFormLayoutItem Caption="UserId" ColSpanMd="4">
@EditFormContext.GetEditor("UserId")
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Product:" ColSpanMd="4">
<DxComboBox Data="@AvailableProducts" TextFieldName="Name" @bind-Value="((UserProductMapping)EditFormContext.EditModel).ProductId" />
</DxFormLayoutItem>
<DxFormLayoutItem Caption="Permissions" ColSpanMd="4">
@EditFormContext.GetEditor("Permissions")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid>
@code {
[Parameter]
public bool KeyboardNavigationEnabled { get; set; }
[Parameter]
public UserModelDtoDetail Customer { get; set; }
List<UserProductMapping> DetailGridData;
List<Product> AvailableProducts;
public UserModelDtoDetail UserInfo;
protected override async Task OnInitializedAsync()
{
//get userproductmappings by customer id
if (Customer.UserProductMappings == null)
DetailGridData = new List<UserProductMapping>();
else
DetailGridData = Customer.UserProductMappings;
AvailableProducts = await serviceProviderDataService.GetAllProductsAsync();
logToBrowserConsole.LogToBC($"DetailGridData: {DetailGridData.Count}");
}
void CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{
if (e.IsNew)
{
UserProductMapping newProductMapping = new UserProductMapping();
newProductMapping.ProductId = Guid.NewGuid();
newProductMapping.UserId = Customer.Id;
newProductMapping.Permissions = 1;
e.EditModel = newProductMapping;
}
}
async Task EditModelSaving(GridEditModelSavingEventArgs e)
{
if (e.IsNew)
//add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added");
//await NwindDataService.InsertEmployeeAsync((EditableEmployee)e.EditModel);
else
logToBrowserConsole.LogToBC("orderData updated");
//await NwindDataService.UpdateEmployeeAsync((EditableEmployee)e.DataItem, (EditableEmployee)e.EditModel);
await UpdateDataAsync();
}
async Task DataItemDeleting(GridDataItemDeletingEventArgs e)
{
//await NwindDataService.RemoveEmployeeAsync((EditableEmployee)e.DataItem);
//remove orderData from orderData array
logToBrowserConsole.LogToBC("orderData deleted");
//await UpdateDataAsync();
}
async Task UpdateDataAsync()
{
//DataSource = await NwindDataService.GetEmployeesEditableAsync();
//refresh grid
logToBrowserConsole.LogToBC("orderData grid refreshed");
}
}

View File

@ -66,6 +66,11 @@
Transfers
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="user/users">
Users
</NavLink>
</div>
<div class="nav-item px-3">
<NavLink class="nav-link" href="user/destinations">
Destinations

View File

@ -60,10 +60,9 @@ select {
.card {
border-radius: 16px;
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.57 );
-webkit-box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.57 );
overflow: hidden;
min-height: 300px;
/*min-height: 300px;*/
background-color: rgba( 255, 255, 255, 0.15 );
/*color: #58457b;*/
font-size: small;
@ -75,6 +74,8 @@ select {
background: rgba( 255, 255, 255, 0.25 ) !important;
backdrop-filter: blur( 8px );
-webkit-backdrop-filter: blur( 8px );
box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.57 );
-webkit-box-shadow: 0 8px 32px 0 rgba( 31, 38, 135, 0.57 );
--dxbl-fl-caption-color: #fff !important;
/*color: #58457b;*/
}
@ -102,6 +103,23 @@ select {
background-color: #f7279f !important;
}
.bg-important {
background-color: #fb9e9e !important;
}
.bg-attention {
background-color: #fbf89e !important;
}
.bg-finished {
background-color: #9efba1 !important;
}
.bg-cancel {
background-color: #999 !important;
color: #666 !important;
}
.bg-gradient {
color: #fff !important;

View File

@ -40,7 +40,7 @@ namespace TIAMWebApp.Client.Services
public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
{
//api call to get user
var userModelDto = await GetUserByIdAsync(id);
var userModelDto = await GetUserDetailByIdAsync(id);
if (userModelDto != null)
{
@ -156,9 +156,22 @@ namespace TIAMWebApp.Client.Services
}
public async Task<IEnumerable<UserModelDto>?> GetUsersAsync()
public async Task<List<UserModelDto>?> GetUsersAsync()
{
return await http.GetFromJsonAsync<IEnumerable<UserModelDto>>(APIUrls.GetUsers);
return await http.GetFromJsonAsync<List<UserModelDto>>(APIUrls.GetUsers);
}
public async Task<List<UserModelDtoDetail>?> GetUsersWithDetailsAsync()
{
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetUsersWithDetails}";
logToBrowserConsole.LogToBC("GetUserByEmailAsync url: " + url + "!");
var response = await http.GetFromJsonAsync<List<UserModelDtoDetail>>(APIUrls.GetUsersWithDetails);
//var result = await response.Content.ReadAsStringAsync();
//var user = JsonConvert.DeserializeObject<UserModelDto>(result);
return response;
}
public async Task<UserModelDto?> GetUserByEmailAsync(string email)

View File

@ -1,8 +1,8 @@
using AyCode.Interfaces.Enums;
using AyCode.Interfaces.Messages;
using AyCode.Models.Messages;
using System.Diagnostics;
using TIAM.Entities.Transfers;
using TIAM.Entities.Emails;
//using TIAM.Entities.TransferDestinations;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
@ -40,7 +40,8 @@ namespace TIAMWebApp.Client.Services
return transferResult as TModelType;
case "MessageWizardModel":
var messageResult = await MessageSenderService.SendNoticeAsync((EmailMessage)data, 1);
EmailMessage emailMessage = ((MessageWizardModel)data).CopyToEmailMessage();
var messageResult = await MessageSenderService.SendNoticeAsync(emailMessage, 1);
return messageResult as TModelType;
case "ServiceProvider":

View File

@ -17,6 +17,7 @@ using System.Text;
using Microsoft.AspNetCore.Hosting;
using Microsoft.EntityFrameworkCore;
using TIAM.Database.DataLayers.Users;
using AyCode.Core.Helpers;
using TIAM.Entities.Users;
using TIAMWebApp.Server.ModelsTIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Utility;
@ -27,6 +28,7 @@ using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
using AyCode.Models.Messages;
using AyCode.Models.Enums;
using TIAM.Database.DataLayers.Admins;
using TIAM.Models.Dtos.Users;
namespace TIAMWebApp.Server.Controllers
{
@ -55,19 +57,22 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous]
[HttpPost]
[Route("SendEmail")]
public async Task<IActionResult> SendEmail([FromBody] EmailMessageSenderModel SerializedMessageSenderModel)
[Route(APIUrls.SendEmailRouteName)]
public async Task<IActionResult> SendEmail([FromBody] JsonElement SerializedMessageSenderModel)
{
Console.WriteLine("SendEmail called!");
var message = JObject.Parse(SerializedMessageSenderModel.GetRawText()).ToObject<MessageSenderModel<EmailMessage>>();
if (SerializedMessageSenderModel != null)
if (message != null)
{
if (SerializedMessageSenderModel.MessageType == MessageTypesEnum.email && SerializedMessageSenderModel.Message is EmailMessage)
if (message.MessageType == MessageTypesEnum.email)
{
Console.WriteLine($@"EmailMessage!!!");
var result = await _messageSenderService.SendMessageAsync(SerializedMessageSenderModel.Message, (int)SerializedMessageSenderModel.MessageType);
Console.WriteLine($"EmailMessage!!!");
var messageElement = message.Message;
Console.WriteLine(message.Message);
var result = await _messageSenderService.SendMessageAsync(messageElement, (int)message.MessageType);
//_adminDal.AddEmailMessageAsync((TIAM.Entities.Emails.EmailMessage)SerializedMessageSenderModel.Message);
Console.WriteLine("SendEmail result: " + result);
return Ok(result);

View File

@ -242,5 +242,25 @@ namespace TIAMWebApp.Server.Controllers
}
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetAllProductsRouteName)]
[Tags("In-Progress", "Product")]
public async Task<string> GetAllProducts()
{
Console.WriteLine("GetAllProducts called");
var products = _adminDal.GetProductsJson();
if (products != null)
{
return products;
}
else
{
return null;
}
}
}
}

View File

@ -321,5 +321,15 @@ namespace TIAMWebApp.Server.Controllers
return result;
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateTransferRouteName)]
public async Task<bool> UpdateTransfer(Transfer transferToModify)
{
Console.WriteLine("UpdateTransfer called!");
return await _adminDal.UpdateTransferAsync(transferToModify);
}
}
}

View File

@ -222,6 +222,46 @@ namespace TIAMWebApp.Server.Controllers
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateUser)]
public async Task<IActionResult> UpdateUser([FromBody] JsonElement SerializedUserModel)
{
Console.WriteLine("UpdateUser called");
if (string.IsNullOrEmpty(SerializedUserModel.GetRawText()))
{
return BadRequest("SerializedUserModel is required");
}
else
{
var user = JObject.Parse(SerializedUserModel.GetRawText()).ToObject<UserModelDtoDetail>();
if (user != null)
{
var userId = user.Id;
var email = user.UserDto.EmailAddress;
var phoneNumber = user.UserDto.PhoneNumber;
if (email is null || phoneNumber is null)
{
return BadRequest("Invalid request");
}
else
{
Console.WriteLine($"User to be updated: {userId}");
Console.WriteLine($"User to be updated: {email}");
Console.WriteLine($"User to be updated: {phoneNumber}");
await _userDal.UpdateUserAsync(new User(userId, email, phoneNumber));
}
}
return Ok("yes");
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreateGuestUserRouteName)]
@ -297,6 +337,17 @@ namespace TIAMWebApp.Server.Controllers
return _userDal.GetAllUsersModelDtoAsync();
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetUsersWithDetailsRouteName)]
public Task<List<UserModelDtoDetail>> GetUsersWithDetails()
{
Console.WriteLine("GetUsersWithDetails called");
//var users = await _userDal.Ctx.Users.ToListAsync();//.GetUsersAsync();
//return users;
return _userDal.GetAllUsersModelDtoDetailAsync();
}
[AllowAnonymous]
[HttpPost]
[Route("GetUserByEmail")]

View File

@ -5,6 +5,7 @@ using AyCode.Models.Enums;
using AyCode.Entities.Messages;
using AyCode.Models.Messages;
using TIAM.Database.DataLayers.Users;
using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
namespace TIAMWebApp.Server.Services
@ -27,12 +28,12 @@ namespace TIAMWebApp.Server.Services
switch (messageType)
{
case (int)MessageTypesEnum.email:
if (message is EmailMessage emailMessage)
if (message is MessageSenderModel<EmailMessage> emailMessage)
{
Console.WriteLine($@"EmailMessage!!!");
// Access DerivedClass properties
var _subject = emailMessage.Subject;
result = await SendMailWithSendgrid(emailMessage);
var _subject = emailMessage.Message.Subject;
result = await SendMailWithSendgrid(emailMessage.Message);
}
else
{

View File

@ -1,4 +1,5 @@
using AyCode.Interfaces.Messages;
using TIAM.Entities.Emails;
using System;
using System.Collections.Generic;
using System.Linq;
@ -10,7 +11,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
{
public interface IClientNoticeSenderService
{
public Task<string> SendNoticeAsync<TNotice>(TNotice message, int messageType) where TNotice : class, INoticeBase;
public Task<string> SendNoticeAsync<TNotice>(TNotice message, int messageType) where TNotice : EmailMessage;
}
}

View File

@ -54,5 +54,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
public Task<IEnumerable<Product>> GetProductsForServiceProviderAsync(Guid serviceProviderId);
public Task<List<Product>> GetAllProductsAsync();
}
}

View File

@ -18,5 +18,6 @@ namespace TIAMWebApp.Shared.Application.Interfaces
Task<Transfer?> GetTransferByIdAsync(Guid id);
Task<List<Transfer>> GetTransfersAsync();
Task<bool> UpdateTransferAsync(Transfer model);
}
}

View File

@ -23,7 +23,9 @@ namespace TIAMWebApp.Shared.Application.Interfaces
//public Task<Dictionary<int, string>> GetUserRolesAsync(UserModel userModel);
public Task<IEnumerable<UserModelDto>?> GetUsersAsync();
public Task<List<UserModelDto>?> GetUsersAsync();
public Task<List<UserModelDtoDetail>?> GetUsersWithDetailsAsync();
public Task<UserModelDto?> GetUserByIdAsync(Guid id);
public Task<UserModelDtoDetail?> GetUserDetailByIdAsync(Guid id);

View File

@ -14,6 +14,7 @@ namespace TIAMWebApp.Shared.Application.Models
public const string ServiceProviderAPI = BaseUrlWithSlashAndVersion + "ServiceProviderAPI/";
public const string UserPermissionAPI = BaseUrlWithSlashAndVersion + "UserPermissionAPI/";
public const string FileAPI = BaseUrlWithSlashAndVersion + "FileAPI/";
public const string MessageAPI = BaseUrlWithSlashAndVersion + "MessageAPI/";
//userdata
public const string UserTestRouteName = "test1";
@ -31,6 +32,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string GetUsersRouteName = "GetUsers";
public const string GetUsers = UserAPI + GetUsersRouteName;
public const string GetUsersWithDetailsRouteName = "GetUsersWithDetails/";
public const string GetUsersWithDetails = UserAPI + GetUsersWithDetailsRouteName;
public const string AuthenticateUserRouteName = "AuthenticateUser";
public const string AuthenticateUser = UserAPI + AuthenticateUserRouteName;
@ -43,6 +47,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string CreateGuestUserRouteName = "CreateGuestUser";
public const string CreateGuestUser = UserAPI + CreateGuestUserRouteName;
public const string UpdateUserRouteName = "UpdateUser";
public const string UpdateUser = UserAPI + UpdateUserRouteName;
public const string RefreshTokenRouteName = "RefreshToken";
public const string RefreshToken = UserAPI + RefreshTokenRouteName;
@ -82,7 +89,10 @@ namespace TIAMWebApp.Shared.Application.Models
public const string CreateTransfersRouteName = "CreateTransfers";
public const string CreateTransfers = TransferDataAPI+CreateTransfersRouteName;
public const string UpdateTransferDestinationRouteName = "UpdateTransfer";
public const string UpdateTransferRouteName = "UpdateTransfer";
public const string UpdateTransfer = TransferDataAPI+UpdateTransferRouteName;
public const string UpdateTransferDestinationRouteName = "UpdateTransferDestintion";
public const string UpdateTransferDestination = TransferDataAPI + UpdateTransferDestinationRouteName;
//serviceprovider
@ -101,6 +111,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string AddProductRouteName = "AddProduct";
public const string AddProductRouteUrl = ServiceProviderAPI + AddProductRouteName;
public const string GetAllProductsRouteName = "GetAllProducts/";
public const string GetAllProducts = ServiceProviderAPI + GetAllProductsRouteName;
public const string GetProductsByServiceProviderIdRouteName = "GetProductsByServiceProviderId";
public const string GetProductsByServiceProviderId = ServiceProviderAPI + GetProductsByServiceProviderIdRouteName;
@ -141,5 +154,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string GetImageRouteName = "GetImage";
public const string GetImage = FileAPI+GetImageRouteName;
//email
public const string SendEmailRouteName = "SendEmail";
public const string SendEmail = MessageAPI+SendEmailRouteName;
}
}

View File

@ -4,7 +4,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AyCode.Models.Messages;
using TIAM.Entities.Emails;
namespace TIAMWebApp.Shared.Application.Models.ClientSide.Messages
{

View File

@ -13,6 +13,8 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide
public const string ApiBaseUrl = "https://localhost:7116";
//public const string BaseUrl = "https://touriam.mangoweb.hu";
//public const string ApiBaseUrl = "https://touriam.mangoweb.hu";
//public const string BaseUrl = "https://test.touriam.com";
//public const string ApiBaseUrl = "https://test.touriam.com";
public const bool DarkMode = false;
public static string Locale { get; set; }
}

View File

@ -21,7 +21,7 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
public Guid ContextId { get; set; }
[Required(ErrorMessage = "The subject value should be specified.")]
[DataType(DataType.Text)]
[Display(Name = "Subject", ResourceType = typeof(TIAMResources))]
[Display(Name = ResourceKeys.Subject, ResourceType = typeof(TIAMResources))]
public string Subject { get; set; }
[Required(ErrorMessage = "The content value should be specified.")]
[DataType(DataType.MultilineText)]
@ -37,24 +37,6 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
SenderId = senderId;
Subject = subject;
Content = content;
}
public static EmailMessage ConvertToNewEmailMessage(MessageWizardModel message)
{
var id = Guid.NewGuid();
return new EmailMessage
{
Id = id,
SenderId = message.SenderId,
ContextId = message.ContextId,
Subject = message.Subject,
Text = message.Content,
EmailAddress = message.SenderEmailAddress,
Recipients = new List<EmailRecipient> { new EmailRecipient(
Guid.NewGuid(), message.ReceiverId, id, "recipient@aycode.com") }
};
}
}
}
}

View File

@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TIAM.Entities.Emails;
namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
{
public static class MessageWizardModelExtensions
{
public static MessageWizardModel Clone(this MessageWizardModel obj)
{
return new MessageWizardModel()
{
ReceiverEmailAddress = obj.ReceiverEmailAddress,
ReceiverId = obj.ReceiverId,
SenderEmailAddress = obj.SenderEmailAddress,
SenderId = obj.SenderId,
ContextId = obj.ContextId,
Subject = obj.Subject,
Content = obj.Content
};
}
public static EmailMessage CopyToEmailMessage(this MessageWizardModel obj)
{
var id = Guid.NewGuid();
return new EmailMessage
{
Id = id,
SenderId = obj.SenderId,
ContextId = obj.ContextId,
Subject = obj.Subject,
Text = obj.Content,
EmailAddress = obj.SenderEmailAddress,
Recipients = new List<EmailRecipient> { new EmailRecipient(
Guid.NewGuid(), obj.ReceiverId, id, "recipient@aycode.com") }
};
}
}
}

View File

@ -23,8 +23,6 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
public Guid? ReferralId { get; set; }
public string ? Comment { get; set; }
#region wizard fields
[Destination(ErrorMessage = "The destination value is invalid.")]
[DataType("TransferDestination")]
@ -36,6 +34,11 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Display(Name = ResourceKeys.PickupAddress, ResourceType = typeof(TIAMResources))]
public string? PickupAddress { get; set; }
//Flight number
[DataType(DataType.Text)]
[Display(Name = ResourceKeys.FlightNumber + " " + ResourceKeys.Optional, ResourceType = typeof(TIAMResources))]
public string? FlightNumber { get; set; }
[Required(ErrorMessage = "The pickup time should be specified.")]
[DataType(DataType.Date)]
[Display(Name = ResourceKeys.PickupTime, ResourceType = typeof(TIAMResources))]
@ -46,11 +49,19 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Display(Name = ResourceKeys.NumberOfPassengers, ResourceType = typeof(TIAMResources))]
public int NumberOfPassengers { get; set; } = 1;
[Required(ErrorMessage = "The amount of luggage should be specified.")]
[DataType("Int")]
[Display(Name = ResourceKeys.NumberOfLuggage, ResourceType = typeof(TIAMResources))]
public int NumberOfLuggage { get; set; } = 1;
//full name
[Required(ErrorMessage = "The full name should be specified.")]
[DataType(DataType.Text)]
[Required(ErrorMessage = "The name should be specified.")]
[DataType("FullName")]
[Display(Name = ResourceKeys.FullName, ResourceType = typeof(TIAMResources))]
public string? FullName { get; set; }
public string? FullName => GetFullName();
public string? FirstName { get; set; }
public string? LastName { get; set; }
//phone number
[Required(ErrorMessage = "The phone number should be specified.")]
@ -68,6 +79,10 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
public double? Price { get; set;}
[DataType(DataType.MultilineText)]
[Display(Name = ResourceKeys.Comment, ResourceType = typeof(TIAMResources))]
public string? Comment { get; set; }
//[DataType("Driver")]
//[Display(Name = ResourceKeys.Driver, ResourceType = typeof(TIAMResources))]
//public DriverModel Driver { get; set; }
@ -83,39 +98,44 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
PickupAddress = pickupAddress;
}
public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, fullName, phoneNumber, emailAddress) { }
public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string firstName, string lastName, string phoneNumber, string emailAddress) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, firstName, lastName, phoneNumber, emailAddress) { }
public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress)
public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string firstName, string lastName, string phoneNumber, string emailAddress)
{
Id = id;
Destination = destination;
PickupAddress = pickupAddress;
TripDate = tripDate;
NumberOfPassengers = numberOfPassengers;
FullName = fullName;
FirstName = firstName;
LastName = lastName;
PhoneNumber = phoneNumber;
EmailAddress = emailAddress;
}
public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress, DriverModel driver) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, fullName, phoneNumber, emailAddress, driver) { }
public TransferWizardModel(string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string firstName, string lastName, string phoneNumber, string emailAddress, DriverModel driver) : this(Guid.NewGuid(), destination, pickupAddress, tripDate, numberOfPassengers, firstName, lastName, phoneNumber, emailAddress, driver) { }
public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string fullName, string phoneNumber, string emailAddress, DriverModel driver)
public TransferWizardModel(Guid id, string destination, string pickupAddress, DateTime tripDate, int numberOfPassengers, string firstName, string lastName, string phoneNumber, string emailAddress, DriverModel driver)
{
Id = id;
Destination = destination;
PickupAddress = pickupAddress;
TripDate = tripDate;
NumberOfPassengers = numberOfPassengers;
FullName = fullName;
FirstName = firstName;
LastName = lastName;
PhoneNumber = phoneNumber;
EmailAddress = emailAddress;
//Driver = driver;
}
public string GetFullName()
{
return FirstName + " " + LastName;
}
}
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)]

View File

@ -24,7 +24,10 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
PickupAddress = obj.PickupAddress,
TripDate = obj.TripDate,
NumberOfPassengers = obj.NumberOfPassengers,
FullName = obj.FullName,
NumberOfLuggage = obj.NumberOfLuggage,
FlightNumber = obj.FlightNumber,
FirstName = obj.FirstName,
LastName = obj.LastName,
PhoneNumber = obj.PhoneNumber,
EmailAddress = obj.EmailAddress,
Price = obj.Price,
@ -43,10 +46,12 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
FromAddress = obj.PickupAddress,
Appointment = obj.TripDate,
PassengerCount = Convert.ToByte(obj.NumberOfPassengers),
//TODO: ContactName = obj.FullName,
FirstName = obj.FirstName,
LastName = obj.LastName,
ContactPhone = obj.PhoneNumber,
ContactEmail = obj.EmailAddress,
Price = obj.Price,
LuggageCount = Convert.ToByte(obj.NumberOfLuggage),
//UserProductMappingId = Guid.NewGuid(),
TransferStatusType = TIAM.Core.Enums.TransferStatusType.OrderSubmitted,
Comment = "Transfer order",
@ -55,5 +60,10 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
return transfer;
}
public static string GetFullName(this TransferWizardModel obj)
{
return obj.FirstName + " " + obj.LastName;
}
}
}

View File

@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TIAMWebApp.Shared.Application.Models.PageModels
{
public class AppointmentModel
{
public AppointmentModel() { }
public int AppointmentType { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
public string Caption { get; set; }
public string Description { get; set; }
public string Location { get; set; }
public int? Label { get; set; }
public int Status { get; set; }
public bool AllDay { get; set; }
public string Recurrence { get; set; }
public int? ResourceId { get; set; }
public bool Accepted { get; set; }
public AppointmentModel(int appointmentType, DateTime startDate, DateTime endDate, string caption, string description, string location, int? label, int status, bool allDay, string recurrence, int? resourceId, bool accepted)
{
AppointmentType = appointmentType;
StartDate = startDate;
EndDate = endDate;
Caption = caption;
Description = description;
Location = location;
Label = label;
Status = status;
AllDay = allDay;
Recurrence = recurrence;
ResourceId = resourceId;
Accepted = accepted;
}
}
}

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using AyCode.Models.Messages;
using Microsoft.IdentityModel.Tokens;
using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users;
@ -8,8 +9,10 @@ namespace TIAMWebApp.Shared.Application.Models
public class UserSessionModel
{
//TODO: add user class
public UserModelDto UserModelDto { get; set; }
public UserModelDtoDetail UserModelDto { get; set; }
public Guid UserId { get; set; }
public string Email => UserModelDto.UserDto.EmailAddress;
public UserType UserType { get; set; }
public string? UserName => UserModelDto?.Profile?.Name;
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
@ -18,9 +21,9 @@ namespace TIAMWebApp.Shared.Application.Models
public int UserRoles { get; set; }
public Dictionary<int, string> UserRolesDictionary { get; set; }
public UserSessionModel(Guid userId, UserType userType, UserModelDto userModelDto, Dictionary<Guid, string>? hasProperties, int userRoles)
public UserSessionModel(Guid userId, UserType userType, UserModelDtoDetail userModelDto, Dictionary<Guid, string>? hasProperties, int userRoles)
{
UserId = userId;
UserId = userId;
UserType = userType;
UserModelDto = userModelDto;
HasProperties = hasProperties;

View File

@ -3,15 +3,67 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using TIAM.Entities.Transfers;
using TIAMWebApp.Shared.Application.Interfaces;
using static System.Net.WebRequestMethods;
using TIAMWebApp.Shared.Application.Models.ClientSide;
using TIAMWebApp.Shared.Application.Models;
using System.Net.Http.Json;
//using AyCode.Models.Messages;
using TIAM.Entities.Emails;
using TIAMWebApp.Shared.Application.Utility;
using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
namespace TIAMWebApp.Shared.Application.Services
{
public class ClientNoticeSenderService : IClientNoticeSenderService
{
Task<string> IClientNoticeSenderService.SendNoticeAsync<TNotice>(TNotice message, int messageType)
private readonly HttpClient http;
public ClientNoticeSenderService(HttpClient http)
{
throw new NotImplementedException();
this.http = http;
}
public async Task<string> SendNoticeAsync<TNotice>(TNotice message, int messageType) where TNotice : TIAM.Entities.Emails.EmailMessage
{
var url = $"{Setting.ApiBaseUrl}/{APIUrls.SendEmail}";
if (message != null)
{
EmailMessage? bleh = new EmailMessage();
bleh.Subject = message.Subject;
bleh.SenderId = message.SenderId;
if(messageType == (int)AyCode.Models.Enums.MessageTypesEnum.email)
{
MessageSenderModel<EmailMessage> messageModel = new EmailMessageSenderModel(bleh, (AyCode.Models.Enums.MessageTypesEnum)messageType);
messageModel.Message = message as EmailMessage;
var response = await http.PostAsJsonAsync(url, messageModel);
if (!response.IsSuccessStatusCode)
return null;
var result = (string)(await response.Content.ReadFromJsonAsync(typeof(string)));
return result;
}
else
{
return "Error sending the message";
}
}
else
{
return "Error sending the message";
}
}
}
}

View File

@ -9,6 +9,7 @@ using TIAM.Entities.ServiceProviders;
using TIAM.Entities.Users;
using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models;
using TIAMWebApp.Shared.Application.Models.ClientSide;
using TIAMWebApp.Shared.Application.Utility;
namespace TIAMWebApp.Shared.Application.Services
@ -153,5 +154,19 @@ namespace TIAMWebApp.Shared.Application.Services
return null;
}
}
public async Task<List<Product>> GetAllProductsAsync()
{
var url = $"{Setting.ApiBaseUrl}/{APIUrls.GetAllProducts}";
var response = await http.GetFromJsonAsync(url, typeof (List<Product>));
if (response != null)
{
return (List<Product>)response;
}
else
{
return null;
}
}
}
}

View File

@ -178,5 +178,26 @@ namespace TIAMWebApp.Shared.Application.Services
return new List<Transfer>();
return response;
}
public async Task<bool> UpdateTransferAsync(Transfer model)
{
var url = $"{Setting.ApiBaseUrl}/{APIUrls.UpdateTransfer}";
var response = await http.PostAsJsonAsync(url, model);
//var result = new WizardProcessorResult();
//if (response.IsSuccessStatusCode)
//{
// result.IsSucces = true;
// result.ResultJson = await response.Content.ReadAsStringAsync();
//}
if (!response.IsSuccessStatusCode)
return false;
var result = (bool)(await response.Content.ReadFromJsonAsync(typeof(bool)))!;
return result;
}
}
}

View File

@ -10,6 +10,9 @@
public const string ButtonDelete = "ButtonDelete";
public const string ButtonEdit = "ButtonEdit";
public const string FullName = "FullName";
public const string FirstName = "FirstName";
public const string LastName = "LastName";
public const string Comment = "Comment";
public const string EmailAddress = "EmailAddress";
public const string PhoneNumber = "PhoneNumber";
public const string Password = "Password";
@ -45,11 +48,17 @@
public const string Destination = "Destination";
public const string PickupTime = "PickupTime";
public const string NumberOfPassengers = "NumberOfPassengers";
public const string NumberOfLuggage = "NumberOfLuggage";
public const string FlightNumber = "FlightNumber";
public const string Optional = "Optional";
public const string ProductType = "ProductType";
public const string ProductName = "ProductName";
public const string ProductDescription = "ProductDescription";
public const string Subject = "Subject";
public const string HtmlContent = "HtmlContent";
}