fixes, email
This commit is contained in:
parent
6ed517f0b0
commit
c99f64054c
|
|
@ -60,26 +60,66 @@ namespace TIAM.Services.Server
|
||||||
|
|
||||||
if (message.SenderId == Guid.Empty)
|
if (message.SenderId == Guid.Empty)
|
||||||
{
|
{
|
||||||
from = new EmailAddress("noreply@tiam.com", "TourIAm mailservice");
|
from = new EmailAddress("noreply@touriam.com", "TourIAm mailservice");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
from = new EmailAddress(message.EmailAddress, senderUser.Profile.Name);
|
from = new EmailAddress(message.EmailAddress, senderUser.Profile.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
List<Task<Response>> sendTasks = new List<Task<Response>>();
|
||||||
foreach (var messageRecipient in message.Recipients)
|
foreach (var messageRecipient in message.Recipients)
|
||||||
{
|
{
|
||||||
var to = new EmailAddress(messageRecipient.EmailAddress, messageRecipient.EmailAddress);
|
var to = new EmailAddress(messageRecipient.EmailAddress, messageRecipient.EmailAddress);
|
||||||
var plainTextContent = message.Text;
|
var plainTextContent = message.Text;
|
||||||
//var _htmlContent = message.;
|
|
||||||
|
|
||||||
//MailHelper.CreateSingleEmailToMultipleRecipients()
|
|
||||||
var msg = MailHelper.CreateSingleEmail(from, to, message.Subject, plainTextContent, plainTextContent);
|
var msg = MailHelper.CreateSingleEmail(from, to, message.Subject, plainTextContent, plainTextContent);
|
||||||
var response = await client.SendEmailAsync(msg).ConfigureAwait(false);
|
sendTasks.Add(client.SendEmailAsync(msg));
|
||||||
}
|
}
|
||||||
|
|
||||||
//return response.StatusCode;
|
var responses = await Task.WhenAll(sendTasks).ConfigureAwait(false);
|
||||||
return HttpStatusCode.Accepted;
|
|
||||||
|
if (responses.Any(response => !response.IsSuccessStatusCode))
|
||||||
|
{
|
||||||
|
Console.WriteLine("Some emails failed to send");
|
||||||
|
return HttpStatusCode.InternalServerError;
|
||||||
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("All emails sent successfully");
|
||||||
|
return HttpStatusCode.OK;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//List<bool> results = new List<bool>();
|
||||||
|
//foreach (var messageRecipient in message.Recipients)
|
||||||
|
//{
|
||||||
|
// var to = new EmailAddress(messageRecipient.EmailAddress, messageRecipient.EmailAddress);
|
||||||
|
// var plainTextContent = message.Text;
|
||||||
|
// //var _htmlContent = message.;
|
||||||
|
|
||||||
|
// //MailHelper.CreateSingleEmailToMultipleRecipients()
|
||||||
|
// var msg = MailHelper.CreateSingleEmail(from, to, message.Subject, plainTextContent, plainTextContent);
|
||||||
|
// var response = await client.SendEmailAsync(msg).ConfigureAwait(false);
|
||||||
|
// if(response.IsSuccessStatusCode)
|
||||||
|
// {
|
||||||
|
// results.Add(true);
|
||||||
|
// }
|
||||||
|
// else { results.Add(false); }
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if(results.Any(x => x=false))
|
||||||
|
//{
|
||||||
|
// return HttpStatusCode.BadRequest;
|
||||||
|
//}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// return HttpStatusCode.OK;
|
||||||
|
//}
|
||||||
|
////return response.StatusCode;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,9 @@
|
||||||
<Reference Include="AyCode.Models">
|
<Reference Include="AyCode.Models">
|
||||||
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
|
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Models.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="AyCode.Utils">
|
||||||
|
<HintPath>..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
@using System.ComponentModel.DataAnnotations
|
@using System.ComponentModel.DataAnnotations
|
||||||
@using BlazorAnimation
|
@using BlazorAnimation
|
||||||
|
|
||||||
<Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)">
|
@* <Animation Effect="@Effect.FadeInUp" Speed="@Speed.Fast" Delay="@TimeSpan.FromMilliseconds(250)"> *@
|
||||||
|
|
||||||
<EditForm Model="@Data"
|
<EditForm Model="@Data"
|
||||||
OnValidSubmit="@HandleValidSubmit"
|
OnValidSubmit="@HandleValidSubmit"
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
<p class="mt-2 cw-480">
|
<p class="mt-2 cw-480">
|
||||||
@_formSubmitResult
|
@_formSubmitResult
|
||||||
</p>
|
</p>
|
||||||
</Animation>
|
@* </Animation> *@
|
||||||
@code {
|
@code {
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -369,7 +369,7 @@ namespace TIAMSharedUI.Pages.Components
|
||||||
_logger.Detail($"Slider changed to {result}");
|
_logger.Detail($"Slider changed to {result}");
|
||||||
property.SetValue(Data, result);
|
property.SetValue(Data, result);
|
||||||
_logger.Detail($"bleh: {property.Name} = {property.GetValue(Data)}");
|
_logger.Detail($"bleh: {property.Name} = {property.GetValue(Data)}");
|
||||||
StateHasChanged(); // Add this line to refresh the UI
|
//StateHasChanged(); // Add this line to refresh the UI
|
||||||
}));
|
}));
|
||||||
|
|
||||||
editor.CloseComponent();
|
editor.CloseComponent();
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@
|
||||||
@inject IStringLocalizer<TIAMResources> localizer
|
@inject IStringLocalizer<TIAMResources> localizer
|
||||||
@inject IWizardProcessor wizardProcessor
|
@inject IWizardProcessor wizardProcessor
|
||||||
@inject ITransferDataService transferDataService
|
@inject ITransferDataService transferDataService
|
||||||
|
@inject ISessionService sessionService
|
||||||
<PageTitle>Transfers</PageTitle>
|
<PageTitle>Transfers</PageTitle>
|
||||||
|
|
||||||
<div class="text-center m-5">
|
<div class="text-center m-5">
|
||||||
|
|
@ -44,7 +45,7 @@
|
||||||
IgnoreReflection=@ignoreList
|
IgnoreReflection=@ignoreList
|
||||||
TitleResourceString="NewMessage"
|
TitleResourceString="NewMessage"
|
||||||
SubtitleResourceString="NewMessageSubtitle"
|
SubtitleResourceString="NewMessageSubtitle"
|
||||||
SubmitButtonText="ButtonSend"></InputWizard>
|
SubmitButtonText="@localizer.GetString("ButtonSend")"></InputWizard>
|
||||||
</BodyContentTemplate>
|
</BodyContentTemplate>
|
||||||
<FooterContentTemplate Context="Context">
|
<FooterContentTemplate Context="Context">
|
||||||
<div class="popup-demo-events-footer">
|
<div class="popup-demo-events-footer">
|
||||||
|
|
@ -209,6 +210,7 @@
|
||||||
"ReceiverEmailAddress",
|
"ReceiverEmailAddress",
|
||||||
"ReceiverId",
|
"ReceiverId",
|
||||||
"SenderEmailAddress",
|
"SenderEmailAddress",
|
||||||
|
"SenderFullName",
|
||||||
"SenderId",
|
"SenderId",
|
||||||
"ContextId"
|
"ContextId"
|
||||||
};
|
};
|
||||||
|
|
@ -225,7 +227,15 @@
|
||||||
|
|
||||||
void SendMail(Transfer Item)
|
void SendMail(Transfer Item)
|
||||||
{
|
{
|
||||||
_logger.Info($"Sending mail to {Item.ContactEmail}");
|
_logger.Info($"Sending mail to {Item.ContactEmail}, {Item.Id}");
|
||||||
|
|
||||||
|
Guid? nullableGuid = Item.Id;
|
||||||
|
if (nullableGuid.HasValue)
|
||||||
|
{
|
||||||
|
Guid nonNullableGuid = nullableGuid.Value;
|
||||||
|
messageWizardModel.ContextId = nonNullableGuid;
|
||||||
|
}
|
||||||
|
messageWizardModel.SenderFullName = Item.FullName;
|
||||||
PopupVisible = true;
|
PopupVisible = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -250,7 +260,25 @@
|
||||||
|
|
||||||
public async Task SubmitForm(object Result)
|
public async Task SubmitForm(object Result)
|
||||||
{
|
{
|
||||||
var email = await wizardProcessor.ProcessWizardAsync<MessageWizardModel>(Result.GetType(), Result);
|
var messageModel = Result as MessageWizardModel;
|
||||||
|
messageModel.ContextId = messageWizardModel.ContextId;
|
||||||
|
//messageModel.SenderId = sessionService.User.UserId;
|
||||||
|
|
||||||
|
string FormatEmailContent()
|
||||||
|
{
|
||||||
|
return $@"
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>Dear {messageModel.SenderFullName},</p>
|
||||||
|
<p>{messageModel.Content}:</p>
|
||||||
|
<p>Best regards,<br/>Tour I Am team</p>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
}
|
||||||
|
messageModel.Content = FormatEmailContent();
|
||||||
|
|
||||||
|
_logger.Info(messageModel.Content);
|
||||||
|
var email = await wizardProcessor.ProcessWizardAsync<MessageWizardModel>(Result.GetType(), messageModel);
|
||||||
|
|
||||||
_logger.Info($"Submitted nested form: {Result.GetType().FullName}");
|
_logger.Info($"Submitted nested form: {Result.GetType().FullName}");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -33,11 +33,11 @@ namespace TIAMSharedUI.Shared.Components
|
||||||
public IAcLogWriterBase BrowserConsoleLogWriter { get; set; }
|
public IAcLogWriterBase BrowserConsoleLogWriter { get; set; }
|
||||||
|
|
||||||
|
|
||||||
private bool enableLogin = false;
|
private bool enableLogin = true;
|
||||||
private bool enableEvents = false;
|
private bool enableEvents = false;
|
||||||
private bool enableTransfer = true;
|
private bool enableTransfer = true;
|
||||||
private bool enableLanguage = false;
|
private bool enableLanguage = false;
|
||||||
private bool enableApi = false;
|
private bool enableApi = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,9 @@
|
||||||
<Reference Include="AyCode.Services">
|
<Reference Include="AyCode.Services">
|
||||||
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
|
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Services.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="AyCode.Utils">
|
||||||
|
<HintPath>..\..\..\AyCode.Core\AyCode.Services.Server\bin\Debug\net8.0\AyCode.Utils.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
||||||
|
using AyCode.Core.Loggers;
|
||||||
using AyCode.Utils.Extensions;
|
using AyCode.Utils.Extensions;
|
||||||
using Microsoft.AspNetCore.Authorization;
|
using Microsoft.AspNetCore.Authorization;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
@ -7,6 +8,7 @@ using Newtonsoft.Json.Linq;
|
||||||
using Newtonsoft.Json.Serialization;
|
using Newtonsoft.Json.Serialization;
|
||||||
using System.Linq.Expressions;
|
using System.Linq.Expressions;
|
||||||
using System.Reflection.Metadata;
|
using System.Reflection.Metadata;
|
||||||
|
using System.ServiceModel.Channels;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using TIAM.Core.Enums;
|
using TIAM.Core.Enums;
|
||||||
using TIAM.Database.DataLayers;
|
using TIAM.Database.DataLayers;
|
||||||
|
|
@ -15,13 +17,19 @@ using TIAM.Database.DataLayers.TransferDestinations;
|
||||||
using TIAM.Database.DataLayers.Users;
|
using TIAM.Database.DataLayers.Users;
|
||||||
using TIAM.Database.DbContexts;
|
using TIAM.Database.DbContexts;
|
||||||
using TIAM.Database.DbSets.Transfers;
|
using TIAM.Database.DbSets.Transfers;
|
||||||
|
using TIAM.Entities.Emails;
|
||||||
using TIAM.Entities.Products;
|
using TIAM.Entities.Products;
|
||||||
using TIAM.Entities.Transfers;
|
using TIAM.Entities.Transfers;
|
||||||
using TIAM.Entities.Users;
|
using TIAM.Entities.Users;
|
||||||
using TIAM.Services.Server;
|
using TIAM.Services.Server;
|
||||||
using TIAMWebApp.Shared.Application.Models;
|
using TIAMWebApp.Shared.Application.Models;
|
||||||
|
using TIAMWebApp.Shared.Application.Models.ClientSide.Messages;
|
||||||
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
using TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels;
|
||||||
using TIAMWebApp.Shared.Application.Models.PageModels;
|
using TIAMWebApp.Shared.Application.Models.PageModels;
|
||||||
|
using ILogger = TIAM.Core.Loggers.ILogger;
|
||||||
|
using LogLevel = AyCode.Core.Loggers.LogLevel;
|
||||||
|
using TIAM.Core.Loggers;
|
||||||
|
using System.Security.Cryptography.Xml;
|
||||||
|
|
||||||
namespace TIAMWebApp.Server.Controllers
|
namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
|
|
@ -44,18 +52,20 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
|
|
||||||
private readonly TransferDestinationDal _transferDestinationDal;
|
private readonly TransferDestinationDal _transferDestinationDal;
|
||||||
private readonly AdminDal _adminDal;
|
private readonly AdminDal _adminDal;
|
||||||
private readonly ILogger<TransferDataAPIController> _logger;
|
private readonly ILogger _logger;
|
||||||
private readonly TransferBackendService _transferBackendService;
|
private readonly TransferBackendService _transferBackendService;
|
||||||
|
private readonly IMessageSenderService _messageSenderService;
|
||||||
|
|
||||||
public TransferDataAPIController(ILogger<TransferDataAPIController> logger, TransferDestinationDal transferDestinationDal, AdminDal adminDal, TransferBackendService transferBackendService)
|
public TransferDataAPIController(TransferDestinationDal transferDestinationDal, AdminDal adminDal, TransferBackendService transferBackendService, IMessageSenderService messageSenderService, IEnumerable<IAcLogWriterBase> logWriters)
|
||||||
{
|
{
|
||||||
_logger = logger;
|
_logger = new TIAM.Core.Loggers.Logger<UserAPIController>(logWriters.ToArray());
|
||||||
_transferDestinationDal = transferDestinationDal;
|
_transferDestinationDal = transferDestinationDal;
|
||||||
_adminDal = adminDal;
|
_adminDal = adminDal;
|
||||||
_transferBackendService = transferBackendService;
|
_transferBackendService = transferBackendService;
|
||||||
|
_messageSenderService = messageSenderService;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
@ -86,7 +96,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route(APIUrls.CreateTransferDestinationRouteName)]
|
[Route(APIUrls.CreateTransferDestinationRouteName)]
|
||||||
public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement serializedTransferDestinationModel)
|
public async Task<IActionResult> CreateTransferDestination([FromBody] JsonElement serializedTransferDestinationModel)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"CreateTransferDestination called!");
|
_logger.Info(@"CreateTransferDestination called!");
|
||||||
if (string.IsNullOrEmpty(serializedTransferDestinationModel.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferDestinationModel.GetRawText()))
|
||||||
{
|
{
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
|
|
@ -97,10 +107,10 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
|
|
||||||
if (transferDestination != null)
|
if (transferDestination != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
var id = Guid.NewGuid();
|
var id = Guid.NewGuid();
|
||||||
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||||
|
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
if (string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||||
{
|
{
|
||||||
|
|
@ -108,16 +118,16 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($@"TransferDestination to be created: {id}");
|
_logger.Info($@"TransferDestination to be created: {id}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.AddressId}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.AddressId}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.Name}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.Name}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.Price}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.Price}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.Price2}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.Price2}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.Price3}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.Price3}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.ExtraPrice}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.ExtraPrice}");
|
||||||
//Console.WriteLine($"TransferDestination to be created: {transferDestination.ExtraPriceType}");
|
//Console.WriteLine($"TransferDestination to be created: {transferDestination.ExtraPriceType}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.AddressString}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.AddressString}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transferDestination.Description}");
|
_logger.Info($@"TransferDestination to be created: {transferDestination.Description}");
|
||||||
|
|
||||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||||
await _adminDal.AddTransferDestinationAsync(transferDestination);
|
await _adminDal.AddTransferDestinationAsync(transferDestination);
|
||||||
|
|
@ -128,7 +138,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
return BadRequest("Invalid request");
|
return BadRequest("Invalid request");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -138,44 +148,44 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
[Route(APIUrls.UpdateTransferDestinationRouteName)]
|
||||||
public async Task<IActionResult> UpdateTransferDestination([FromBody]JsonElement serializedTransferDestination)
|
public async Task<IActionResult> UpdateTransferDestination([FromBody] JsonElement serializedTransferDestination)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"UpdateTransferDestination called!");
|
_logger.Info(@"UpdateTransferDestination called!");
|
||||||
if (string.IsNullOrEmpty(serializedTransferDestination.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferDestination.GetRawText()))
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"Bad request!");
|
_logger.Info(@"Bad request!");
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"Serialized model not empty!");
|
_logger.Info(@"Serialized model not empty!");
|
||||||
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestination.GetRawText()).ToObject<TransferDestination>();
|
TransferDestination? transferDestination = JObject.Parse(serializedTransferDestination.GetRawText()).ToObject<TransferDestination>();
|
||||||
Console.WriteLine($@"TransferDestination to be updated: {serializedTransferDestination.GetRawText()}");
|
_logger.Info($@"TransferDestination to be updated: {serializedTransferDestination.GetRawText()}");
|
||||||
Console.WriteLine($@"TransferDestination to be updated: {transferDestination.AddressString}");
|
_logger.Info($@"TransferDestination to be updated: {transferDestination.AddressString}");
|
||||||
|
|
||||||
|
|
||||||
if (transferDestination != null)
|
if (transferDestination != null)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
//TransferDestination transferDestination = new TransferDestination(id, transferDestinationModel.Name, transferDestinationModel.Description, transferDestinationModel.AddressString);
|
||||||
|
|
||||||
if (transferDestination.Id == Guid.Empty || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
if (transferDestination.Id == Guid.Empty || string.IsNullOrEmpty(transferDestination.Name) || string.IsNullOrEmpty(transferDestination.AddressString))
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"Serialized model not empty, but bad request!");
|
_logger.Info(@"Serialized model not empty, but bad request!");
|
||||||
return BadRequest("Invalid request");
|
return BadRequest("Invalid request");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
Console.WriteLine($@"TransferDestination to be updated: {transferDestination.Id}");
|
_logger.Info($@"TransferDestination to be updated: {transferDestination.Id}");
|
||||||
Console.WriteLine($@"TransferDestination to be updated new name: {transferDestination.Name}");
|
_logger.Info($@"TransferDestination to be updated new name: {transferDestination.Name}");
|
||||||
Console.WriteLine($@"TransferDestination to be updated new price: {transferDestination.Price}");
|
_logger.Info($@"TransferDestination to be updated new price: {transferDestination.Price}");
|
||||||
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price2}");
|
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price2}");
|
||||||
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price3}");
|
//Console.WriteLine($"TransferDestination to be updated new price: {transferDestination.Price3}");
|
||||||
//Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
//Console.WriteLine($"TransferDestination to be updated new priceType: {transferDestination.PriceType}");
|
||||||
Console.WriteLine($@"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
_logger.Info($@"TransferDestination to be updated new address: {transferDestination.AddressString}");
|
||||||
Console.WriteLine($@"TransferDestination to be updated new description: {transferDestination.Description}");
|
_logger.Info($@"TransferDestination to be updated new description: {transferDestination.Description}");
|
||||||
|
|
||||||
//var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
//var dbTransferDestinationJson = _adminDal.GetTransferDestinationJsonById(transferDestination.Id);
|
||||||
//Console.WriteLine($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
//Console.WriteLine($"TransferDestination JSON to be updated: {dbTransferDestinationJson}");
|
||||||
|
|
@ -192,7 +202,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
// dbTransferDestination.Description = transferDestination.Description;
|
// dbTransferDestination.Description = transferDestination.Description;
|
||||||
// dbTransferDestination.AddressString = transferDestination.AddressString;
|
// dbTransferDestination.AddressString = transferDestination.AddressString;
|
||||||
// dbTransferDestination.Address = transferDestination.Address;
|
// dbTransferDestination.Address = transferDestination.Address;
|
||||||
|
|
||||||
//}
|
//}
|
||||||
|
|
||||||
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
//await _transferDestinationDal.Context.TransferDestinations.AddAsync(transferDestination);
|
||||||
|
|
@ -216,14 +226,14 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route(APIUrls.CreateTransferRouteName)]
|
[Route(APIUrls.CreateTransferRouteName)]
|
||||||
public async Task<IActionResult> CreateTransfer([FromBody] JsonElement serializedTransferModel)
|
public async Task<IActionResult> CreateTransfer([FromBody] JsonElement serializedTransferModel)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"CreateTransfer called!");
|
_logger.Info(@"CreateTransfer called!");
|
||||||
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
|
||||||
{
|
{
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Transfer? transfer= JObject.Parse(serializedTransferModel.GetRawText()).ToObject<Transfer>();
|
Transfer? transfer = JObject.Parse(serializedTransferModel.GetRawText()).ToObject<Transfer>();
|
||||||
|
|
||||||
if (transfer != null)
|
if (transfer != null)
|
||||||
{
|
{
|
||||||
|
|
@ -238,22 +248,58 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($@"TransferDestination to be created: {id}");
|
_logger.Info($@"TransferDestination to be created: {id}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transfer.FromAddress}");
|
_logger.Info($@"TransferDestination to be created: {transfer.FromAddress}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transfer.ToAddress}");
|
_logger.Info($@"TransferDestination to be created: {transfer.ToAddress}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transfer.ProductId}");
|
_logger.Info($@"TransferDestination to be created: {transfer.ProductId}");
|
||||||
Console.WriteLine($@"TransferDestination to be created: {transfer.Price}");
|
_logger.Info($@"TransferDestination to be created: {transfer.Price}");
|
||||||
|
|
||||||
var from = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.FromAddress);
|
var from = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.FromAddress);
|
||||||
var to = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.ToAddress);
|
var to = await _adminDal.Context.TransferDestinations.FirstOrDefaultAsync(x => x.AddressString == transfer.ToAddress);
|
||||||
|
|
||||||
//TODO
|
//TODO
|
||||||
if(!transfer.ProductId.IsNullOrEmpty())
|
if (!transfer.ProductId.IsNullOrEmpty())
|
||||||
transfer.Price = _transferBackendService.GetTransferPrice(transfer.ProductId.Value, from, to, transfer.PassengerCount);
|
transfer.Price = _transferBackendService.GetTransferPrice(transfer.ProductId.Value, from, to, transfer.PassengerCount);
|
||||||
|
|
||||||
transfer.TransferStatusType = TransferStatusType.OrderSubmitted;
|
transfer.TransferStatusType = TransferStatusType.OrderSubmitted;
|
||||||
|
|
||||||
await _adminDal.AddTransferAsync(transfer);
|
await _adminDal.AddTransferAsync(transfer);
|
||||||
|
|
||||||
|
|
||||||
|
_logger.Info($"Created transfer, send emailMessage!!!");
|
||||||
|
var message = new MessageSenderModel<EmailMessage>();
|
||||||
|
message.Message.Subject = "[Tour I Am] New transfer in Budapest";
|
||||||
|
message.Message.ContextId = transfer.Id;
|
||||||
|
message.Message.SenderId = Guid.Empty;
|
||||||
|
message.Message.Recipients.Add(new EmailRecipient(Guid.NewGuid(), transfer.UserId, Guid.NewGuid(), transfer.ContactEmail));
|
||||||
|
|
||||||
|
string FormatEmailContent()
|
||||||
|
{
|
||||||
|
return $@"
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>Dear {transfer.FullName},</p>
|
||||||
|
<p>We are pleased to inform you that a transfer order has been placed. Below are the details of the transfer:</p>
|
||||||
|
<p>{transfer.FromAddress} - {transfer.ToAddress}</p>
|
||||||
|
<p>{transfer.Appointment}</p>
|
||||||
|
<p>{transfer.FullName}</p>
|
||||||
|
<p>{transfer.PassengerCount}</p>
|
||||||
|
<p>Please confirm the transfer by clicking on the following link:</p>
|
||||||
|
<p><a href=""https://www.touriam.com/mytransfer?{transfer.Id}"">Confirm Transfer</a></p>
|
||||||
|
<p>If you did not request this transfer, please disregard this email.</p>
|
||||||
|
<p>Thank you,<br/>Tour I Am team</p>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
}
|
||||||
|
message.Message.Text = FormatEmailContent();
|
||||||
|
_logger.Info(message.Message.Text);
|
||||||
|
//message.Message.Text = $"Dear {transfer.FullName}! /n We have received an order from you, please confirm the details here: https://www.touriam.com/mytransfer?{transfer.Id}";
|
||||||
|
var messageElement = message.Message;
|
||||||
|
var result = await _messageSenderService.SendMessageAsync(messageElement, (int)message.MessageType);
|
||||||
|
//_adminDal.AddEmailMessageAsync((TIAM.Entities.Emails.EmailMessage)SerializedMessageSenderModel.Message);
|
||||||
|
_logger.Info("SendEmail result: " + result);
|
||||||
|
|
||||||
|
|
||||||
return Ok(transfer);
|
return Ok(transfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -273,14 +319,14 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route(APIUrls.CreateTransfersRouteName)]
|
[Route(APIUrls.CreateTransfersRouteName)]
|
||||||
public async Task<IActionResult> CreateTransfers([FromBody] JsonElement serializedTransferModel)
|
public async Task<IActionResult> CreateTransfers([FromBody] JsonElement serializedTransferModel)
|
||||||
{
|
{
|
||||||
Console.WriteLine(@"CreateTransfers called!");
|
_logger.Info(@"CreateTransfers called!");
|
||||||
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
|
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
|
||||||
{
|
{
|
||||||
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
return BadRequest("SerializedTramsferDestinationWizardModel is required");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Console.WriteLine($@"Serialized model: {serializedTransferModel.GetRawText()}");
|
_logger.Info($@"Serialized model: {serializedTransferModel.GetRawText()}");
|
||||||
|
|
||||||
var settings = new JsonSerializerSettings
|
var settings = new JsonSerializerSettings
|
||||||
{
|
{
|
||||||
|
|
@ -297,11 +343,48 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
var id = Guid.NewGuid();
|
var id = Guid.NewGuid();
|
||||||
var result = await _adminDal.AddTransferAsync(transfer);
|
var result = await _adminDal.AddTransferAsync(transfer);
|
||||||
if(result)
|
if (result)
|
||||||
{
|
{
|
||||||
createdTransfers.Add(transfer);
|
createdTransfers.Add(transfer);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var createdTransfer in createdTransfers)
|
||||||
|
{
|
||||||
|
_logger.Info($"Created transfer, send emailMessage!!!");
|
||||||
|
var message = new MessageSenderModel<EmailMessage>();
|
||||||
|
message.Message.Subject = "[Tour I Am] New transfer in Budapest";
|
||||||
|
message.Message.ContextId = createdTransfer.Id;
|
||||||
|
message.Message.SenderId = Guid.Empty;
|
||||||
|
message.Message.Recipients.Add(new EmailRecipient(Guid.NewGuid(), createdTransfer.UserId, Guid.NewGuid(), createdTransfer.ContactEmail));
|
||||||
|
string FormatEmailContent()
|
||||||
|
{
|
||||||
|
return $@"
|
||||||
|
<html>
|
||||||
|
<body>
|
||||||
|
<p>Dear {createdTransfer.FullName},</p>
|
||||||
|
<p>We are pleased to inform you that a transfer order has been placed. Below are the details of the transfer:</p>
|
||||||
|
<p>
|
||||||
|
{createdTransfer.FromAddress} - {createdTransfer.ToAddress}</p>
|
||||||
|
<p>{createdTransfer.Appointment}</p>
|
||||||
|
<p>{createdTransfer.FullName}</p>
|
||||||
|
<p>{createdTransfer.PassengerCount}</p>
|
||||||
|
<p>Please confirm the transfer by clicking on the following link:</p>
|
||||||
|
<p><a href=""https://www.touriam.com/mytransfer?{createdTransfer.Id}"">Confirm Transfer</a></p>
|
||||||
|
<p>If you did not request this transfer, please disregard this email.</p>
|
||||||
|
<p>Thank you,<br/>Tour I Am team</p>
|
||||||
|
</body>
|
||||||
|
</html>";
|
||||||
|
}
|
||||||
|
message.Message.Text = FormatEmailContent();
|
||||||
|
_logger.Info(message.Message.Text);
|
||||||
|
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);
|
||||||
|
_logger.Info("SendEmail result: " + result);
|
||||||
|
}
|
||||||
|
|
||||||
return Ok(createdTransfers);
|
return Ok(createdTransfers);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -318,7 +401,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
{
|
{
|
||||||
var result = await _adminDal.GetTransfersJsonAsync();
|
var result = await _adminDal.GetTransfersJsonAsync();
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -327,7 +410,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
[Route(APIUrls.UpdateTransferRouteName)]
|
[Route(APIUrls.UpdateTransferRouteName)]
|
||||||
public async Task<bool> UpdateTransfer(Transfer transferToModify)
|
public async Task<bool> UpdateTransfer(Transfer transferToModify)
|
||||||
{
|
{
|
||||||
Console.WriteLine("UpdateTransfer called!");
|
_logger.Info("UpdateTransfer called!");
|
||||||
return await _adminDal.UpdateTransferAsync(transferToModify);
|
return await _adminDal.UpdateTransferAsync(transferToModify);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ builder.Services.AddScoped<AdminDal>();
|
||||||
builder.Services.AddScoped<AuctionDal>();
|
builder.Services.AddScoped<AuctionDal>();
|
||||||
builder.Services.AddScoped<TransferDestinationDal>();
|
builder.Services.AddScoped<TransferDestinationDal>();
|
||||||
|
|
||||||
|
|
||||||
builder.Services.AddCors(options => {
|
builder.Services.AddCors(options => {
|
||||||
options.AddPolicy(MyAllowSpecificOrigins,
|
options.AddPolicy(MyAllowSpecificOrigins,
|
||||||
builder => {
|
builder => {
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,7 @@ namespace TIAMWebApp.Shared.Application.Models.ClientSide.UI.WizardModels
|
||||||
public string ReceiverEmailAddress { get; set; }
|
public string ReceiverEmailAddress { get; set; }
|
||||||
public Guid ReceiverId { get; set; }
|
public Guid ReceiverId { get; set; }
|
||||||
public string SenderEmailAddress { get; set; }
|
public string SenderEmailAddress { get; set; }
|
||||||
|
public string SenderFullName { get; set; }
|
||||||
public Guid SenderId { get; set; }
|
public Guid SenderId { get; set; }
|
||||||
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.")]
|
||||||
|
|
|
||||||
|
|
@ -47,8 +47,8 @@ namespace TIAMWebApp.Shared.Application.Services
|
||||||
if (!response.IsSuccessStatusCode)
|
if (!response.IsSuccessStatusCode)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
var result = (string)(await response.Content.ReadFromJsonAsync(typeof(string)));
|
var result = (HttpResponseMessage)(await response.Content.ReadFromJsonAsync(typeof(HttpResponseMessage)));
|
||||||
return result;
|
return result.Content.ToString();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue