a lot of changes in frontend, APIS, and design

This commit is contained in:
Adam 2024-04-24 17:49:32 +02:00
parent 9d11b8756c
commit f953cd8b2c
30 changed files with 748 additions and 165 deletions

View File

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

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> /// <summary>
/// Looks up a localized string similar to Confirm Email. /// Looks up a localized string similar to Confirm Email.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Forgot password?. /// Looks up a localized string similar to Forgot password?.
/// </summary> /// </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> /// <summary>
/// Looks up a localized string similar to Password. /// Looks up a localized string similar to Password.
/// </summary> /// </summary>

View File

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

View File

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

@ -267,6 +267,8 @@ namespace TIAMSharedUI.Pages.Components
editor.OpenComponent<DxDateEdit<DateTime>>(j); editor.OpenComponent<DxDateEdit<DateTime>>(j);
editor.AddAttribute(j++, "Date", property.GetValue(Data)); editor.AddAttribute(j++, "Date", property.GetValue(Data));
editor.AddAttribute(j++, "DateExpression", lambda); 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++, "CssClass", "form-field");
editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); })); editor.AddAttribute(j++, "DateChanged", EventCallback.Factory.Create<DateTime>(this, str => { property.SetValue(Data, str); }));
editor.CloseComponent(); editor.CloseComponent();
@ -377,6 +379,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; break;
} }

View File

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

View File

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

View File

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

View File

@ -13,6 +13,7 @@
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI @using TIAMWebApp.Shared.Application.Models.ClientSide.UI
@using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels @using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
@using TIAMWebApp.Shared.Application.Models.ClientSide.Messages @using TIAMWebApp.Shared.Application.Models.ClientSide.Messages
@using TIAMWebApp.Shared.Application.Models.PageModels
@using TIAMWebApp.Shared.Application.Utility @using TIAMWebApp.Shared.Application.Utility
@layout AdminLayout @layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole @inject LogToBrowserConsole logToBrowserConsole
@ -26,6 +27,7 @@
<h2 style="font-size:small">Manage transfers here!</h2> <h2 style="font-size:small">Manage transfers here!</h2>
</div> </div>
<DxPopup CssClass="popup-demo-events" <DxPopup CssClass="popup-demo-events"
@bind-Visible="@PopupVisible" @bind-Visible="@PopupVisible"
ShowFooter="true" ShowFooter="true"
@ -55,94 +57,134 @@
<div class="container"> <div class="container">
<div class="row"> <div class="row">
<div class=" col-12"> <div class=" col-12">
<Animation Effect="@Effect.FadeInUp" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> <Animation Effect="@Effect.Pulse" Class="glass" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
<div class="card"> <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="Grid2" <DxTabs>
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> <DxTabPage Text="DataGrid">
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" /> <div class="d-flex flex-column mb-4 pb-2">
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" /> <div class="align-self-end pl-2 pb-2">
<DxGridDataColumn FieldName="OrderId" /> <DxButton Text="Column Chooser"
<DxGridDataColumn FieldName="FromAddress" /> RenderStyle="ButtonRenderStyle.Secondary"
<DxGridDataColumn FieldName="ToAddress" /> IconCssClass="btn-column-chooser"
<DxGridDataColumn FieldName="Appointment" /> Click="ColumnChooserButton_Click" />
<DxGridDataColumn FieldName="ContactName" /> </div>
<DxGridDataColumn FieldName="ContactPhone" />
<DxGridDataColumn FieldName="ContactEmail"> <DxGrid @ref="Grid2"
<CellDisplayTemplate> 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 keyField = context.Value; var transfer2 = (Transfer)EditFormContext.EditModel;
var keyItem = (Transfer)context.DataItem;
string buttonText = "Contact";
<DxButton Click="() => SendMail(keyItem)" Text="@buttonText" RenderStyle="ButtonRenderStyle.Primary" />
} }
</CellDisplayTemplate> <DxFormLayout CssClass="w-100">
</DxGridDataColumn> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.FirstName) ColSpanMd="6">
<DxGridDataColumn FieldName="PassengerCount" /> @EditFormContext.GetEditor("FirstName")
<DxGridDataColumn FieldName="TransferStatusType"> </DxFormLayoutItem>
<CellDisplayTemplate> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="6">
@{ @EditFormContext.GetEditor("LastName")
</DxFormLayoutItem>
TransferStatusModel keyField = Statuses.FirstOrDefault(x => x.StatusValue == Convert.ToInt16(context.Value)); <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.DestinationAddress) ColSpanMd="6">
string transferStatusText = keyField.StatusName; @EditFormContext.GetEditor("ToAddress")
<p>@transferStatusText</p> </DxFormLayoutItem>
} <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PickupAddress) ColSpanMd="6">
</CellDisplayTemplate> @EditFormContext.GetEditor("FromAddress")
</DxGridDataColumn> </DxFormLayoutItem>
</Columns> <DxFormLayoutItem Caption="Trip date:" ColSpanMd="6">
<DetailRowTemplate>
<Grid_MasterDetail_NestedGrid_DetailContent Customer="(TIAM.Entities.Transfers.Transfer)context.DataItem" KeyboardNavigationEnabled="true" /> <DxDateEdit @bind-Date="@transfer2.Appointment"
</DetailRowTemplate> TimeSectionVisible="true"
<EditFormTemplate Context="EditFormContext"> TimeSectionScrollPickerFormat="tt h m">
@{ </DxDateEdit>
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"> </DxFormLayoutItem>
@EditFormContext.GetEditor("TransferStatusType") <DxFormLayoutItem Caption="Passengers:" ColSpanMd="6">
</DxFormLayoutItem> @EditFormContext.GetEditor("PassengerCount")
</DxFormLayoutItem>
</DxFormLayout> <DxFormLayoutItem Caption="Status:" ColSpanMd="6">
</EditFormTemplate> @EditFormContext.GetEditor("TransferStatusType")
</DxFormLayoutItem>
</DxFormLayout>
</EditFormTemplate>
</DxGrid> </DxGrid>
</div> </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> </div>
</Animation> </Animation>
</div> </div>
@ -170,11 +212,14 @@
"ContextId" "ContextId"
}; };
public List<TransferStatusModel>? Statuses { get; set; } public List<TransferStatusModel>? Statuses { get; set; }
public MessageWizardModel messageWizardModel = new MessageWizardModel(); public MessageWizardModel messageWizardModel = new MessageWizardModel();
//IEnumerable<DriverModel> drivers { get; set; } public List<AppointmentModel>? AppoinmentData { get; set; }
DateTime StartDate { get; set; } = DateTime.Today;
DxSchedulerDataStorage DataStorage = new DxSchedulerDataStorage();
void SendMail(Transfer Item) void SendMail(Transfer Item)
@ -234,12 +279,6 @@
} }
} }
protected override async Task OnAfterRenderAsync(bool firstRender)
{
//if (firstRender)
// await Grid.StartEditRowAsync(0);
}
void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e) void Grid_CustomizeEditModel(GridCustomizeEditModelEventArgs e)
{ {
if (e.IsNew) if (e.IsNew)
@ -250,7 +289,8 @@
transferEditModel.FromAddress = "From where?"; transferEditModel.FromAddress = "From where?";
transferEditModel.Appointment = DateTime.UtcNow.AddDays(3); transferEditModel.Appointment = DateTime.UtcNow.AddDays(3);
transferEditModel.PassengerCount = 1; transferEditModel.PassengerCount = 1;
transferEditModel.ContactName = "Full name"; transferEditModel.FirstName = "John";
transferEditModel.LastName = "Doe";
transferEditModel.ContactPhone = "+00000000000"; transferEditModel.ContactPhone = "+00000000000";
transferEditModel.ContactEmail = "your@email.address"; transferEditModel.ContactEmail = "your@email.address";
} }
@ -264,13 +304,13 @@
//add new orderData to orderData array //add new orderData to orderData array
logToBrowserConsole.LogToBC("New orderData added"); logToBrowserConsole.LogToBC("New orderData added");
//await transferDataService.CreateTransfer((TransferWizardModel)e.EditModel); //await transferDataService.CreateTransfer((TransferWizardModel)e.EditModel);
} }
else else
{ {
logToBrowserConsole.LogToBC("orderData updated at id " + ((Transfer)e.EditModel).Id); logToBrowserConsole.LogToBC("orderData updated at id " + ((Transfer)e.EditModel).Id);
success = await transferDataService.UpdateTransferAsync((Transfer)e.EditModel); success = await transferDataService.UpdateTransferAsync((Transfer)e.EditModel);
} }
//get transfer from TransferData by Id //get transfer from TransferData by Id
@ -283,7 +323,7 @@
// //transferToModify.Driver = myModel.Driver; // //transferToModify.Driver = myModel.Driver;
// } // }
// } // }
if(success) if (success)
await UpdateDataAsync(); await UpdateDataAsync();
} }
async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e) async Task Grid_DataItemDeleting(GridDataItemDeletingEventArgs e)
@ -315,6 +355,35 @@
new TransferStatusModel(Convert.ToInt16(TransferStatusType.AdminDenied), "Admin cancelled") new TransferStatusModel(Convert.ToInt16(TransferStatusType.AdminDenied), "Admin cancelled")
}; };
TransferData = (await transferDataService.GetTransfersAsync()).OrderBy(x => x.TransferStatusType).ThenByDescending(x => x.OrderId).ToList(); 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(); base.OnInitialized();
} }

View File

@ -21,12 +21,13 @@
@layout AdminLayout @layout AdminLayout
@inject LogToBrowserConsole logToBrowserConsole @inject LogToBrowserConsole logToBrowserConsole
@inject IStringLocalizer<TIAMResources> localizer @inject IStringLocalizer<TIAMResources> localizer
@inject ISessionService sessionService
@inject IWizardProcessor wizardProcessor @inject IWizardProcessor wizardProcessor
@inject IUserDataService userDataService @inject IUserDataService userDataService
<PageTitle>Transfers</PageTitle> <PageTitle>Transfers</PageTitle>
<div class="text-center m-5"> <div class="text-center m-5">
<h1>Transfer management</h1> <h1>User management</h1>
<h2 style="font-size:small">Manage transfers here!</h2> <h2 style="font-size:small">Manage transfers here!</h2>
</div> </div>
@ -85,7 +86,7 @@
<Columns> <Columns>
<DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" /> <DxGridCommandColumn NewButtonVisible="false" Width="8%" FixedPosition="GridColumnFixedPosition.Left" />
<DxGridDataColumn FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" /> <DxGridDataColumn FieldName="Id" ShowInColumnChooser="false" SortIndex="0" Visible="false" />
<DxGridDataColumn FieldName="Profile.Name" /> <DxGridDataColumn FieldName="Profile.FullName" />
<DxGridDataColumn FieldName="UserDto.PhoneNumber" /> <DxGridDataColumn FieldName="UserDto.PhoneNumber" />
<DxGridDataColumn FieldName="UserDto.Created" /> <DxGridDataColumn FieldName="UserDto.Created" />
<DxGridDataColumn FieldName="UserDto.EmailConfirmed" /> <DxGridDataColumn FieldName="UserDto.EmailConfirmed" />
@ -110,6 +111,9 @@
var transfer2 = (UserModelDtoDetail)EditFormContext.EditModel; var transfer2 = (UserModelDtoDetail)EditFormContext.EditModel;
} }
<DxFormLayout CssClass="w-100"> <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"> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.EmailAddress) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.EmailAddress") @EditFormContext.GetEditor("UserDto.EmailAddress")
</DxFormLayoutItem> </DxFormLayoutItem>
@ -119,8 +123,11 @@
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PhoneNumber) ColSpanMd="4"> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.PhoneNumber) ColSpanMd="4">
@EditFormContext.GetEditor("UserDto.PhoneNumber") @EditFormContext.GetEditor("UserDto.PhoneNumber")
</DxFormLayoutItem> </DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.FullName) ColSpanMd="4"> <DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.FirstName) ColSpanMd="4">
@EditFormContext.GetEditor("Profile.Name") @EditFormContext.GetEditor("Profile.FirstName")
</DxFormLayoutItem>
<DxFormLayoutItem Caption=@localizer.GetString(ResourceKeys.LastName) ColSpanMd="4">
@EditFormContext.GetEditor("Profile.LastName")
</DxFormLayoutItem> </DxFormLayoutItem>
@ -172,6 +179,11 @@
var user = await userDataService.GetUserDetailByIdAsync(Item.Id); var user = await userDataService.GetUserDetailByIdAsync(Item.Id);
logToBrowserConsole.LogToBC($"Sending mail to {user.UserDto.EmailAddress}"); 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; PopupVisible = true;
} }

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

@ -60,10 +60,9 @@ select {
.card { .card {
border-radius: 16px; 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; overflow: hidden;
min-height: 300px; /*min-height: 300px;*/
background-color: rgba( 255, 255, 255, 0.15 ); background-color: rgba( 255, 255, 255, 0.15 );
/*color: #58457b;*/ /*color: #58457b;*/
font-size: small; font-size: small;
@ -75,6 +74,8 @@ select {
background: rgba( 255, 255, 255, 0.25 ) !important; background: rgba( 255, 255, 255, 0.25 ) !important;
backdrop-filter: blur( 8px ); backdrop-filter: blur( 8px );
-webkit-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; --dxbl-fl-caption-color: #fff !important;
/*color: #58457b;*/ /*color: #58457b;*/
} }

View File

@ -40,7 +40,7 @@ namespace TIAMWebApp.Client.Services
public async Task<UserSessionModel> IsLoggedInAsync(Guid id) public async Task<UserSessionModel> IsLoggedInAsync(Guid id)
{ {
//api call to get user //api call to get user
var userModelDto = await GetUserByIdAsync(id); var userModelDto = await GetUserDetailByIdAsync(id);
if (userModelDto != null) if (userModelDto != null)
{ {

View File

@ -1,8 +1,8 @@
using AyCode.Interfaces.Enums; using AyCode.Interfaces.Enums;
using AyCode.Interfaces.Messages; using AyCode.Interfaces.Messages;
using AyCode.Models.Messages;
using System.Diagnostics; using System.Diagnostics;
using TIAM.Entities.Transfers; using TIAM.Entities.Transfers;
using TIAM.Entities.Emails;
//using TIAM.Entities.TransferDestinations; //using TIAM.Entities.TransferDestinations;
using TIAMWebApp.Shared.Application.Interfaces; using TIAMWebApp.Shared.Application.Interfaces;
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels; using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
@ -40,7 +40,8 @@ namespace TIAMWebApp.Client.Services
return transferResult as TModelType; return transferResult as TModelType;
case "MessageWizardModel": 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; return messageResult as TModelType;
case "ServiceProvider": case "ServiceProvider":

View File

@ -28,6 +28,7 @@ using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
using AyCode.Models.Messages; using AyCode.Models.Messages;
using AyCode.Models.Enums; using AyCode.Models.Enums;
using TIAM.Database.DataLayers.Admins; using TIAM.Database.DataLayers.Admins;
using TIAM.Models.Dtos.Users;
namespace TIAMWebApp.Server.Controllers namespace TIAMWebApp.Server.Controllers
{ {
@ -56,19 +57,22 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous] [AllowAnonymous]
[HttpPost] [HttpPost]
[Route("SendEmail")] [Route(APIUrls.SendEmailRouteName)]
public async Task<IActionResult> SendEmail([FromBody] EmailMessageSenderModel SerializedMessageSenderModel) 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!!!"); Console.WriteLine($"EmailMessage!!!");
var messageElement = message.Message;
var result = await _messageSenderService.SendMessageAsync(SerializedMessageSenderModel.Message, (int)SerializedMessageSenderModel.MessageType); Console.WriteLine(message.Message);
var result = await _messageSenderService.SendMessageAsync(messageElement, (int)message.MessageType);
//_adminDal.AddEmailMessageAsync((TIAM.Entities.Emails.EmailMessage)SerializedMessageSenderModel.Message); //_adminDal.AddEmailMessageAsync((TIAM.Entities.Emails.EmailMessage)SerializedMessageSenderModel.Message);
Console.WriteLine("SendEmail result: " + result); Console.WriteLine("SendEmail result: " + result);
return Ok(result); return Ok(result);

View File

@ -328,11 +328,10 @@ namespace TIAMWebApp.Server.Controllers
if (user != null) if (user != null)
{ {
var userId = user.Id; var userId = user.Id;
var email = user.Email; var email = user.UserDto.EmailAddress;
var phoneNumber = user.PhoneNumber; var phoneNumber = user.UserDto.PhoneNumber;
var password = user.Password;
if (email is null || phoneNumber is null || password is null) if (email is null || phoneNumber is null)
{ {
return BadRequest("Invalid request"); return BadRequest("Invalid request");
} }
@ -340,10 +339,9 @@ namespace TIAMWebApp.Server.Controllers
{ {
Console.WriteLine($"User to be updated: {userId}"); Console.WriteLine($"User to be updated: {userId}");
Console.WriteLine($"User to be updated: {email}"); Console.WriteLine($"User to be updated: {email}");
Console.WriteLine($"User to be updated: {phoneNumber}"); Console.WriteLine($"User to be updated: {phoneNumber}");
Console.WriteLine($"User to be updated: {password}");
await _userDal.UpdateUserAsync(new User(userId, email, phoneNumber, password)); await _userDal.UpdateUserAsync(new User(userId, email, phoneNumber));
} }
} }

View File

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

View File

@ -1,4 +1,5 @@
using AyCode.Interfaces.Messages; using AyCode.Interfaces.Messages;
using TIAM.Entities.Emails;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -10,7 +11,7 @@ namespace TIAMWebApp.Shared.Application.Interfaces
{ {
public interface IClientNoticeSenderService 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

@ -14,6 +14,7 @@ namespace TIAMWebApp.Shared.Application.Models
public const string ServiceProviderAPI = BaseUrlWithSlashAndVersion + "ServiceProviderAPI/"; public const string ServiceProviderAPI = BaseUrlWithSlashAndVersion + "ServiceProviderAPI/";
public const string UserPermissionAPI = BaseUrlWithSlashAndVersion + "UserPermissionAPI/"; public const string UserPermissionAPI = BaseUrlWithSlashAndVersion + "UserPermissionAPI/";
public const string FileAPI = BaseUrlWithSlashAndVersion + "FileAPI/"; public const string FileAPI = BaseUrlWithSlashAndVersion + "FileAPI/";
public const string MessageAPI = BaseUrlWithSlashAndVersion + "MessageAPI/";
//userdata //userdata
public const string UserTestRouteName = "test1"; public const string UserTestRouteName = "test1";
@ -150,5 +151,9 @@ namespace TIAMWebApp.Shared.Application.Models
public const string GetImageRouteName = "GetImage"; public const string GetImageRouteName = "GetImage";
public const string GetImage = FileAPI+GetImageRouteName; 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.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using AyCode.Models.Messages; using TIAM.Entities.Emails;
namespace TIAMWebApp.Shared.Application.Models.ClientSide.Messages namespace TIAMWebApp.Shared.Application.Models.ClientSide.Messages
{ {

View File

@ -21,7 +21,7 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
public Guid ContextId { get; set; } public Guid ContextId { get; set; }
[Required(ErrorMessage = "The subject value should be specified.")] [Required(ErrorMessage = "The subject value should be specified.")]
[DataType(DataType.Text)] [DataType(DataType.Text)]
[Display(Name = "Subject", ResourceType = typeof(TIAMResources))] [Display(Name = ResourceKeys.Subject, ResourceType = typeof(TIAMResources))]
public string Subject { get; set; } public string Subject { get; set; }
[Required(ErrorMessage = "The content value should be specified.")] [Required(ErrorMessage = "The content value should be specified.")]
[DataType(DataType.MultilineText)] [DataType(DataType.MultilineText)]
@ -37,24 +37,6 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
SenderId = senderId; SenderId = senderId;
Subject = subject; Subject = subject;
Content = content; 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 Guid? ReferralId { get; set; }
public string ? Comment { get; set; }
#region wizard fields #region wizard fields
[Destination(ErrorMessage = "The destination value is invalid.")] [Destination(ErrorMessage = "The destination value is invalid.")]
[DataType("TransferDestination")] [DataType("TransferDestination")]
@ -36,6 +34,11 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
[Display(Name = ResourceKeys.PickupAddress, ResourceType = typeof(TIAMResources))] [Display(Name = ResourceKeys.PickupAddress, ResourceType = typeof(TIAMResources))]
public string? PickupAddress { get; set; } 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.")] [Required(ErrorMessage = "The pickup time should be specified.")]
[DataType(DataType.Date)] [DataType(DataType.Date)]
[Display(Name = ResourceKeys.PickupTime, ResourceType = typeof(TIAMResources))] [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))] [Display(Name = ResourceKeys.NumberOfPassengers, ResourceType = typeof(TIAMResources))]
public int NumberOfPassengers { get; set; } = 1; 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 //full name
[Required(ErrorMessage = "The full name should be specified.")] [Required(ErrorMessage = "The name should be specified.")]
[DataType(DataType.Text)] [DataType("FullName")]
[Display(Name = ResourceKeys.FullName, ResourceType = typeof(TIAMResources))] [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 //phone number
[Required(ErrorMessage = "The phone number should be specified.")] [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))] [Display(Name = ResourceKeys.Price, ResourceType = typeof(TIAMResources))]
public double? Price { get; set;} public double? Price { get; set;}
[DataType(DataType.MultilineText)]
[Display(Name = ResourceKeys.Comment, ResourceType = typeof(TIAMResources))]
public string? Comment { get; set; }
//[DataType("Driver")] //[DataType("Driver")]
//[Display(Name = ResourceKeys.Driver, ResourceType = typeof(TIAMResources))] //[Display(Name = ResourceKeys.Driver, ResourceType = typeof(TIAMResources))]
//public DriverModel Driver { get; set; } //public DriverModel Driver { get; set; }
@ -83,39 +98,44 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
PickupAddress = pickupAddress; 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; Id = id;
Destination = destination; Destination = destination;
PickupAddress = pickupAddress; PickupAddress = pickupAddress;
TripDate = tripDate; TripDate = tripDate;
NumberOfPassengers = numberOfPassengers; NumberOfPassengers = numberOfPassengers;
FullName = fullName; FirstName = firstName;
LastName = lastName;
PhoneNumber = phoneNumber; PhoneNumber = phoneNumber;
EmailAddress = emailAddress; 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; Id = id;
Destination = destination; Destination = destination;
PickupAddress = pickupAddress; PickupAddress = pickupAddress;
TripDate = tripDate; TripDate = tripDate;
NumberOfPassengers = numberOfPassengers; NumberOfPassengers = numberOfPassengers;
FullName = fullName; FirstName = firstName;
LastName = lastName;
PhoneNumber = phoneNumber; PhoneNumber = phoneNumber;
EmailAddress = emailAddress; EmailAddress = emailAddress;
//Driver = driver; //Driver = driver;
} }
public string GetFullName()
{
return FirstName + " " + LastName;
}
} }
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Parameter, AllowMultiple = false)] [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, PickupAddress = obj.PickupAddress,
TripDate = obj.TripDate, TripDate = obj.TripDate,
NumberOfPassengers = obj.NumberOfPassengers, NumberOfPassengers = obj.NumberOfPassengers,
FullName = obj.FullName, NumberOfLuggage = obj.NumberOfLuggage,
FlightNumber = obj.FlightNumber,
FirstName = obj.FirstName,
LastName = obj.LastName,
PhoneNumber = obj.PhoneNumber, PhoneNumber = obj.PhoneNumber,
EmailAddress = obj.EmailAddress, EmailAddress = obj.EmailAddress,
Price = obj.Price, Price = obj.Price,
@ -43,10 +46,12 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
FromAddress = obj.PickupAddress, FromAddress = obj.PickupAddress,
Appointment = obj.TripDate, Appointment = obj.TripDate,
PassengerCount = Convert.ToByte(obj.NumberOfPassengers), PassengerCount = Convert.ToByte(obj.NumberOfPassengers),
ContactName = obj.FullName, FirstName = obj.FirstName,
LastName = obj.LastName,
ContactPhone = obj.PhoneNumber, ContactPhone = obj.PhoneNumber,
ContactEmail = obj.EmailAddress, ContactEmail = obj.EmailAddress,
Price = obj.Price, Price = obj.Price,
LuggageCount = Convert.ToByte(obj.NumberOfLuggage),
//UserProductMappingId = Guid.NewGuid(), //UserProductMappingId = Guid.NewGuid(),
TransferStatusType = TIAM.Core.Enums.TransferStatusType.OrderSubmitted, TransferStatusType = TIAM.Core.Enums.TransferStatusType.OrderSubmitted,
Comment = "Transfer order", Comment = "Transfer order",
@ -55,5 +60,10 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
return transfer; 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 System.Collections.Generic;
using AyCode.Models.Messages;
using Microsoft.IdentityModel.Tokens; using Microsoft.IdentityModel.Tokens;
using TIAM.Entities.Users; using TIAM.Entities.Users;
using TIAM.Models.Dtos.Users; using TIAM.Models.Dtos.Users;
@ -8,8 +9,10 @@ namespace TIAMWebApp.Shared.Application.Models
public class UserSessionModel public class UserSessionModel
{ {
//TODO: add user class //TODO: add user class
public UserModelDto UserModelDto { get; set; } public UserModelDtoDetail UserModelDto { get; set; }
public Guid UserId { get; set; } public Guid UserId { get; set; }
public string Email => UserModelDto.UserDto.EmailAddress;
public UserType UserType { get; set; } public UserType UserType { get; set; }
public string? UserName => UserModelDto?.Profile?.Name; public string? UserName => UserModelDto?.Profile?.Name;
public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName; public string DisplayName => string.IsNullOrWhiteSpace(UserName) ? UserId.ToString() : UserName;
@ -18,9 +21,9 @@ namespace TIAMWebApp.Shared.Application.Models
public int UserRoles { get; set; } public int UserRoles { get; set; }
public Dictionary<int, string> UserRolesDictionary { 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; UserType = userType;
UserModelDto = userModelDto; UserModelDto = userModelDto;
HasProperties = hasProperties; HasProperties = hasProperties;

View File

@ -3,15 +3,67 @@ using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
using TIAM.Entities.Transfers;
using TIAMWebApp.Shared.Application.Interfaces; 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 namespace TIAMWebApp.Shared.Application.Services
{ {
public class ClientNoticeSenderService : IClientNoticeSenderService 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

@ -10,6 +10,9 @@
public const string ButtonDelete = "ButtonDelete"; public const string ButtonDelete = "ButtonDelete";
public const string ButtonEdit = "ButtonEdit"; public const string ButtonEdit = "ButtonEdit";
public const string FullName = "FullName"; 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 EmailAddress = "EmailAddress";
public const string PhoneNumber = "PhoneNumber"; public const string PhoneNumber = "PhoneNumber";
public const string Password = "Password"; public const string Password = "Password";
@ -45,11 +48,17 @@
public const string Destination = "Destination"; public const string Destination = "Destination";
public const string PickupTime = "PickupTime"; public const string PickupTime = "PickupTime";
public const string NumberOfPassengers = "NumberOfPassengers"; 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 ProductType = "ProductType";
public const string ProductName = "ProductName"; public const string ProductName = "ProductName";
public const string ProductDescription = "ProductDescription"; public const string ProductDescription = "ProductDescription";
public const string Subject = "Subject";
public const string HtmlContent = "HtmlContent";
} }