This commit is contained in:
jozsef.b@aycode.com 2024-06-03 07:48:09 +02:00
commit 536b9304d0
11 changed files with 198 additions and 25 deletions

View File

@ -35,6 +35,10 @@ namespace TIAM.Database.DataLayers.Admins
#region Car
public Car? GetCarById(Guid carId) => Session(ctx => ctx.Cars.FirstOrDefault(x => x.Id == carId));
public List<Car> GetCarByUserProductMappingId(Guid userProductMappingId) => Session(ctx => ctx.Cars.Where(x => x.UserProductMappingId == userProductMappingId).ToList());
public Task<bool> AddCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Add(car).State == EntityState.Added);
public Task<bool> UpdateCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Update(car).State == EntityState.Modified);
public Task<bool> RemoveCarAsync(Car car) => TransactionAsync(ctx => ctx.Cars.Remove(car).State == EntityState.Deleted);
#endregion Car
#region Transfer

View File

@ -58,7 +58,7 @@ namespace TIAM.Services.Server
if (message.SenderId == Guid.Empty)
{
message.EmailAddress = "noreply@anataworld.com";
from = new EmailAddress("noreply@anataworld.com", "TourIAm mailservice");
}
else
@ -90,8 +90,8 @@ namespace TIAM.Services.Server
{
Console.WriteLine($"{response.StatusCode}, {response.Body.ReadAsStringAsync()}");
}
adminDal.AddEmailMessageAsync(message).Forget();
//message.Id = Guid.NewGuid();
//adminDal.AddEmailMessageAsync(message).Forget();
}
catch(Exception ex)
{

View File

@ -40,4 +40,14 @@ public class SignalRTags : AcSignalRTags
public const int UpdateProfile = 38;
//public const int AddAddress = 39;
//public const int RemoveAddress = 40;
public const int CreateUserProductMapping = 27;
public const int UpdateUserProductMapping = 28;
public const int DeleteUserProductMapping = 29; //set permissions to 0
public const int GetCarsForUserProductMapping = 30;
public const int CreateCar = 31;
public const int UpdateCar = 32;
public const int DeleteCar = 33;
}
}

View File

@ -116,7 +116,7 @@ namespace TIAMSharedUI.Pages.Components
_logger.Info("Hellooooo " + type.AssemblyQualifiedName);
var propertyList = type.GetProperties();
var length = propertyList.Length - IgnoreReflection.Count;
//var length = propertyList.Length - IgnoreReflection.Count;
//var propertyList = typeof(TestUserData).GetProperties();
formLayoutBuilder.OpenComponent<DxFormLayout>(0);
@ -484,7 +484,7 @@ namespace TIAMSharedUI.Pages.Components
layoutItemBuilder.AddAttribute(i++, "Click", EventCallback.Factory.Create<MouseEventArgs>(this, OnNext));
layoutItemBuilder.AddAttribute(i++, "SubmitFormOnClick", false);
layoutItemBuilder.AddAttribute(i++, "CssClass", "btn btn-primary mt-3");
if (!(k < length - 1))
if (!(k < FormSteps.Count - 1))
{
layoutItemBuilder.AddAttribute(i++, "disabled", "true");
@ -520,7 +520,7 @@ namespace TIAMSharedUI.Pages.Components
editor.AddAttribute(i++, "type", "submit");
editor.AddAttribute(i++, "class", "btn btn-primary mt-3 w-100");
editor.AddAttribute(i++, "style", "margin: 0 auto");
if (CurrentStep < length - 1)
if (CurrentStep < FormSteps.Count - 1)
{
editor.AddAttribute(i++, "disabled", "true");

View File

@ -436,7 +436,7 @@ new HeroSliderItem
var orderModel = result as TransferWizardModel;
//check if user exists
if (sessionService.IsAuthenticated && sessionService.User != null )
if (sessionService.IsAuthenticated && sessionService.User != null)
{
//Basic settings
orderModel.UserId = sessionService.User.UserModelDto.Id;
@ -507,6 +507,35 @@ new HeroSliderItem
public async Task<List<Transfer>> ProcessTransfers(TransferWizardModel orderModel)
{
List<TransferWizardModel> transferList = new List<TransferWizardModel>();
double _transferPrice = 0.0f;
if(orderModel.NumberOfPassengers < 5) {
switch (transferList.Count)
{
case (1):
_transferPrice = 119/2;
break;
case (2):
_transferPrice = 199 / 4;
break;
case (3):
_transferPrice = 269 / 6;
break;
}
}else if (orderModel.NumberOfPassengers > 5 && orderModel.NumberOfPassengers < 8) {
switch (transferList.Count)
{
case (1):
_transferPrice = 219f /2;
break;
case (2):
_transferPrice = 359 / 4;
break;
case (3):
_transferPrice = 489 / 6;
break;
}
}
foreach (var date in OrderDates)
{
@ -517,6 +546,9 @@ new HeroSliderItem
// Outbound trip
transfer.PickupAddress = OrderLocation;
transfer.Destination = "Hungaroring";
transfer.PhoneNumber = orderModel.PhoneNumber;
transfer.EmailAddress = orderModel.EmailAddress;
transfer.Price = _transferPrice;
transferList.Add(transfer);
// Return trip
@ -526,6 +558,7 @@ new HeroSliderItem
transfer.Destination = OrderLocation;
transfer.PhoneNumber = orderModel.PhoneNumber;
transfer.EmailAddress = orderModel.EmailAddress;
transfer.Price = _transferPrice;
transferList.Add(transfer);
}

1
TIAMSharedUI/Todo.txt Normal file
View File

@ -0,0 +1 @@


View File

@ -52,6 +52,8 @@ namespace TIAMWebApp.Server.Controllers
Console.WriteLine(message.Message);
var result = await _messageSenderService.SendMessageAsync(messageElement, (int)message.MessageType);
//_adminDal.AddEmailMessageAsync((TIAM.Entities.Emails.EmailMessage)SerializedMessageSenderModel.Message);
messageElement.EmailAddress = "noreply@anataworld.com";
_adminDal.AddEmailMessageAsync(messageElement).Forget();
Console.WriteLine("SendEmail result: " + result);
return Ok(result);

View File

@ -169,17 +169,16 @@ namespace TIAMWebApp.Server.Controllers
[Route(APIUrls.CreateUserProductMappingRouteName)]
[Tags("Finished", "ServiceProvider")]
[EndpointSummary("Create assigned user to product")]
public async Task<IActionResult> CreateUserProductMapping(CreateUserProductMappingModel createUserProductMappingModel)
[SignalR(SignalRTags.CreateUserProductMapping)]
public async Task<IActionResult> CreateUserProductMapping(UserProductMapping userProductMapping)
{
if(createUserProductMappingModel.ContextId == Guid.Empty || createUserProductMappingModel.UserId == Guid.Empty)
if(userProductMapping.ProductId == Guid.Empty || userProductMapping.UserId == Guid.Empty)
{
return BadRequest("Invalid request");
}
else
{
_logger.Info($@"CreateUserProductMappings called with ownerId: {createUserProductMappingModel.ContextId}, {createUserProductMappingModel.ContextId}");
var userProductMapping = new UserProductMapping(createUserProductMappingModel.ContextId, createUserProductMappingModel.ContextId);
_logger.Info($@"CreateUserProductMappings called with ownerId: {userProductMapping.ProductId}, {userProductMapping.UserId}");
var result = await adminDal.AddUserProductMappingAsync(userProductMapping);
@ -187,6 +186,32 @@ namespace TIAMWebApp.Server.Controllers
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateUserProductMappingRouteName)]
[SignalR(SignalRTags.UpdateUserProductMapping)]
public async Task<string> UpdateUserProductMapping(UserProductMapping userProductMapping)
{
_logger.Info($"UpdateUserProductMapping called! + {userProductMapping.Id}");
var result = await adminDal.UpdateUserProductMappingAsync(userProductMapping);
return result ? userProductMapping.ToJson() : string.Empty;
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.DeleteUserProductMappingRouteName)]
[SignalR(SignalRTags.DeleteUserProductMapping)]
public async Task<string> DeleteUserProductMapping(UserProductMapping userProductMapping)
{
_logger.Info($"UpdateUserProductMapping called! + {userProductMapping.Id}");
var result = await adminDal.RemoveUserProductMappingAsync(userProductMapping.Id);
return result ? userProductMapping.ToJson() : string.Empty;
}
//23.
[AllowAnonymous]
[HttpPost]
@ -205,6 +230,85 @@ namespace TIAMWebApp.Server.Controllers
return myServiceproviders;
}
[AllowAnonymous]
[HttpGet]
[Route(APIUrls.GetCarsForUserProductMappingRouteName + "/{userProductMappingId}")]
[SignalR(SignalRTags.GetCarsForUserProductMapping)]
public async Task<List<Car>> GetCarsForUserProductMapping(string userProductMappingId)
{
_logger.Info($@"GetCarsForUserProductMapping called with userProductMappingId: {userProductMappingId}");
var cars = adminDal.GetCarByUserProductMappingId(Guid.Parse(userProductMappingId));
return cars;
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreateCarRouteName)]
[Tags("Finished", "Cars")]
[EndpointSummary("Create car")]
[SignalR(SignalRTags.CreateCar)]
public async Task<IActionResult> CreateCar(Car car)
{
if (car.UserProductMappingId == Guid.Empty || car.LicencePlate == null)
{
return BadRequest("Invalid request");
}
else
{
_logger.Info($@"CreateCar called with ownerId: {car.UserProductMappingId}, {car.LicencePlate}");
var result = await adminDal.AddCarAsync(car);
return Ok(car);
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.UpdateCarRouteName)]
[Tags("Finished", "Cars")]
[EndpointSummary("Update car")]
[SignalR(SignalRTags.UpdateCar)]
public async Task<IActionResult> UpdateCar(Car car)
{
if (car.UserProductMappingId == Guid.Empty || car.LicencePlate == null)
{
return BadRequest("Invalid request");
}
else
{
_logger.Info($@"CreateCar called with ownerId: {car.UserProductMappingId}, {car.LicencePlate}");
var result = await adminDal.UpdateCarAsync(car);
return Ok(car);
}
}
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.DeleteCarRouteName)]
[Tags("Finished", "Cars")]
[EndpointSummary("Delete car")]
[SignalR(SignalRTags.DeleteCar)]
public async Task<IActionResult> DeleteCar(Car car)
{
if (car.UserProductMappingId == Guid.Empty || car.LicencePlate == null)
{
return BadRequest("Invalid request");
}
else
{
_logger.Info($@"CreateCar called with ownerId: {car.UserProductMappingId}, {car.LicencePlate}");
var result = await adminDal.RemoveCarAsync(car);
return Ok(car);
}
}
[HttpPost]
[Route(APIUrls.AddProductRouteName)]
[Tags("In-Progress", "Product")]

View File

@ -299,23 +299,23 @@ namespace TIAMWebApp.Server.Controllers
[AllowAnonymous]
[HttpPost]
[Route(APIUrls.CreateTransfersRouteName)]
public async Task<IActionResult> CreateTransfers([FromBody] JsonElement serializedTransferModel)
public async Task<IActionResult> CreateTransfers([FromBody] JsonElement serializedTransferList)
{
_logger.Info(@"CreateTransfers called!");
if (string.IsNullOrEmpty(serializedTransferModel.GetRawText()))
if (string.IsNullOrEmpty(serializedTransferList.GetRawText()))
{
return BadRequest("SerializedTramsferDestinationWizardModel is required");
}
else
{
_logger.Info($@"Serialized model: {serializedTransferModel.GetRawText()}");
_logger.Info($@"Serialized model: {serializedTransferList.GetRawText()}");
var settings = new JsonSerializerSettings
{
ContractResolver = new CamelCasePropertyNamesContractResolver()
};
List<Transfer>? transfers = JsonConvert.DeserializeObject<List<Transfer>>(serializedTransferModel.GetRawText(), settings);
List<Transfer>? transfers = JsonConvert.DeserializeObject<List<Transfer>>(serializedTransferList.GetRawText(), settings);
//List<Transfer>? transfers = JObject.Parse(serializedTransferModel.GetRawText()).ToObject<List<Transfer>>();
List<Transfer> createdTransfers = new List<Transfer>();

View File

@ -131,18 +131,35 @@ namespace TIAMWebApp.Shared.Application.Models
public const string CreateUserProductMappingRouteName = "CreateUserProductMapping";
public const string CreateUserProductMapping = ServiceProviderAPI + CreateUserProductMappingRouteName;
public const string UpdateUserProductMappingRouteName = "UpdateUserProductMapping";
public const string UpdateUserProductMapping = ServiceProviderAPI + UpdateUserProductMappingRouteName;
public const string DeleteUserProductMappingRouteName = "DeleteUserProductMapping";
public const string DeleteUserProductMapping = ServiceProviderAPI + DeleteUserProductMappingRouteName;
public const string GetServiceProvidersRouteName = "GetServiceProviders";
public const string GetServiceProviders = ServiceProviderAPI + GetServiceProvidersRouteName;
public const string GetUserProductMappingsForProductRouteName = "GetUserProductMappingsForProduct";
public const string GetUserProductMappingsForProduct = ServiceProviderAPI + GetUserProductMappingsForProductRouteName;
public const string GetCarsForUserProductMappingRouteName = "GetCarsForUserProductMapping";
public const string GetCarsForUserProductMapping = ServiceProviderAPI + GetCarsForUserProductMappingRouteName;
public const string CreateCarRouteName = "CreateCar";
public const string CreateCar = ServiceProviderAPI + CreateCarRouteName;
public const string UpdateCarRouteName = "UpdateCar";
public const string UpdateCar = ServiceProviderAPI + UpdateCarRouteName;
public const string DeleteCarRouteName = "DeleteCar";
public const string DeleteCar = ServiceProviderAPI + DeleteCarRouteName;
//AssingedUsers
public const string CreateAssignedUserRouteName = "CreateAssignedUser";
public const string CreateAssignedUser = ServiceProviderAPI + CreateAssignedUserRouteName;
public const string GetAssignedUsersForServiceProviderRouteName = "GetAssignedUsersForServiceProvider";
public const string GetAssignedUsersForServiceProvider = ServiceProviderAPI + GetAssignedUsersForServiceProviderRouteName;
//public const string CreateAssignedUserRouteName = "CreateAssignedUser";
//public const string CreateAssignedUser = ServiceProviderAPI + CreateAssignedUserRouteName;
//public const string GetAssignedUsersForServiceProviderRouteName = "GetAssignedUsersForServiceProvider";
//public const string GetAssignedUsersForServiceProvider = ServiceProviderAPI + GetAssignedUsersForServiceProviderRouteName;
//permissions
//1

View File

@ -7,5 +7,7 @@
public Guid UserId { get; set; }
public int? Permission { get; set; }
}
}