Transfer, TransferPrices, TransferToDriver, Car, etc... fixes, improvements...
This commit is contained in:
parent
7a5dc75e2b
commit
7e1903bbea
|
|
@ -0,0 +1,8 @@
|
|||
namespace TIAM.Core.Enums;
|
||||
|
||||
public enum SeatNumberPriceType : byte
|
||||
{
|
||||
Price1SeatNum = 0,
|
||||
Price2SeatNum = 4,
|
||||
Price3SeatNum = 8,
|
||||
}
|
||||
|
|
@ -83,32 +83,33 @@ namespace TIAM.Database.DbContexts.Admins
|
|||
//modelBuilder.Entity<Car>().HasNoKey();
|
||||
//modelBuilder.Entity<UserProductToCar>().HasNoKey();
|
||||
|
||||
modelBuilder.Entity<UserProductMapping>().OwnsOne(
|
||||
userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
|
||||
{
|
||||
builderUserProductJsonDetail.ToJson();
|
||||
//builderUserProductJsonDetail.Property(nameof(UserProductMapping.JsonDetailModel)).HasColumnName("JsonDetailModel");
|
||||
//JSONMODEL - J.
|
||||
//modelBuilder.Entity<UserProductMapping>().OwnsOne(
|
||||
// userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
|
||||
// {
|
||||
// builderUserProductJsonDetail.ToJson();
|
||||
// //builderUserProductJsonDetail.Property(nameof(UserProductMapping.JsonDetailModel)).HasColumnName("JsonDetailModel");
|
||||
|
||||
builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
|
||||
{
|
||||
//builderUserProductToCar.ToJson();
|
||||
// builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
|
||||
// {
|
||||
// //builderUserProductToCar.ToJson();
|
||||
|
||||
//builderUserProductToCar.Ignore(x => x.UserProductToCarId);
|
||||
//builderUserProductToCar.Ignore(x => x.Created);
|
||||
//builderUserProductToCar.Ignore(x => x.Modified);
|
||||
// //builderUserProductToCar.Ignore(x => x.UserProductToCarId);
|
||||
// //builderUserProductToCar.Ignore(x => x.Created);
|
||||
// //builderUserProductToCar.Ignore(x => x.Modified);
|
||||
|
||||
builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
|
||||
{
|
||||
//builderCar.ToJson();
|
||||
// builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
|
||||
// {
|
||||
// //builderCar.ToJson();
|
||||
|
||||
//builderCar.Ignore(x => x.Id);
|
||||
//builderCar.Ignore(x => x.Created);
|
||||
//builderCar.Ignore(x => x.Modified);
|
||||
});
|
||||
});
|
||||
// //builderCar.Ignore(x => x.Id);
|
||||
// //builderCar.Ignore(x => x.Created);
|
||||
// //builderCar.Ignore(x => x.Modified);
|
||||
// });
|
||||
// });
|
||||
|
||||
//builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
|
||||
});
|
||||
// //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
|
||||
// });
|
||||
|
||||
//modelBuilder.Entity<UserProductToCar>().OwnsOne(
|
||||
// userToProduct => userToProduct.Car, ownedNavigationBuilder =>
|
||||
|
|
|
|||
|
|
@ -83,20 +83,20 @@ namespace TIAM.Database.DbContexts.Users
|
|||
//modelBuilder.Entity<Product>().BuildProductToServiceProviderRelation();
|
||||
//new UserProductMappingEntityTypeDefaultConfiguration().Configure(modelBuilder.Entity<UserProductMapping>());
|
||||
|
||||
modelBuilder.Entity<UserProductMapping>().OwnsOne(
|
||||
userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
|
||||
{
|
||||
builderUserProductJsonDetail.ToJson();
|
||||
//modelBuilder.Entity<UserProductMapping>().OwnsOne(
|
||||
// userToProduct => userToProduct.JsonDetailModel, builderUserProductJsonDetail =>
|
||||
// {
|
||||
// builderUserProductJsonDetail.ToJson();
|
||||
|
||||
builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
|
||||
{
|
||||
builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
|
||||
{
|
||||
});
|
||||
});
|
||||
// builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars, builderUserProductToCar =>
|
||||
// {
|
||||
// builderUserProductToCar.OwnsOne(userProductToCar => userProductToCar.Car, builderCar =>
|
||||
// {
|
||||
// });
|
||||
// });
|
||||
|
||||
//builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
|
||||
});
|
||||
// //builderUserProductJsonDetail.OwnsMany(userProductJsonDetail => userProductJsonDetail.Cars2);
|
||||
// });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using TIAM.Core.Enums;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Entities.Drivers
|
||||
{
|
||||
public class Car : IEntityGuid//, ITimeStampInfo, ITimeStampDisableAutoSet
|
||||
[Table(nameof(Car))]
|
||||
public class Car : IEntityGuid, ITimeStampInfo, IUserProductMappingForeignKey//, ITimeStampDisableAutoSet
|
||||
{
|
||||
//[NotMapped]
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
public Guid UserProductMappingId { get; set; }
|
||||
|
||||
public int CountryCode { get; set; } = 36;
|
||||
|
||||
public string LicencePlate { get; set; } = "JGH452";
|
||||
|
|
@ -18,10 +23,13 @@ namespace TIAM.Entities.Drivers
|
|||
public string CarModel { get; set; } = "Mondeo";
|
||||
|
||||
public int YearOfMake { get; set; } = 2021;
|
||||
public int SeatNumber { get; set; } = 5;
|
||||
public byte SeatNumber { get; set; } = 5;
|
||||
|
||||
public CarMotorType CarMotorType { get; set; } = CarMotorType.Diesel;
|
||||
|
||||
//public string Tulajdonos { get; set; }
|
||||
//public string Üzembentartó { get; set; }
|
||||
|
||||
public DateTime Created { get; set; } = DateTime.UtcNow;
|
||||
public DateTime Modified { get; set; } = DateTime.UtcNow;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,10 +1,12 @@
|
|||
namespace TIAM.Entities.Drivers;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
namespace TIAM.Entities.Drivers;
|
||||
|
||||
public class UserProductJsonDetailModel
|
||||
{
|
||||
//public string Value { get; set; } = "ANYÁD!!!";
|
||||
|
||||
//[NotMapped]
|
||||
[NotMapped]
|
||||
public List<UserProductToCar>? Cars { get; set; }
|
||||
//public List<UserProductToCarTest>? Cars2 { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ public class UserProductToCar //: IEntityGuid//, ITimeStampInfo, ITimeStampDisab
|
|||
/// </summary>
|
||||
public Guid UserProductCarId { get; set; }
|
||||
|
||||
//[NotMapped, JsonIgnore]
|
||||
[NotMapped]
|
||||
//public Guid UserProductMappingId { get; set; }
|
||||
public Car Car { get; set; }
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ using TIAM.Entities.Users;
|
|||
namespace TIAM.Entities.Transfers;
|
||||
|
||||
[Table(nameof(Transfer))]
|
||||
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserProductMappingRelation<Guid?>
|
||||
public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserProductMappingRelation<Guid?>, IUserForeignKey
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
|
@ -17,6 +17,7 @@ public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserPro
|
|||
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
||||
public int OrderId { get; }
|
||||
|
||||
public Guid UserId { get; set; }
|
||||
public Guid ProductId { get; set; }
|
||||
public Guid? UserProductMappingId { get; set; }
|
||||
public Guid? UserProductToCarId { get; set; }
|
||||
|
|
@ -36,8 +37,8 @@ public class Transfer: IEntityGuid, ITimeStampInfo, IProductForeignKey, IUserPro
|
|||
[MaxLength(200)] public string? ToAddress { get; set; }
|
||||
[MaxLength(250)] public string? Comment { get; set; }
|
||||
|
||||
[Column("ReferralProductId")]
|
||||
public Guid? ReferralProductId { get; set; }
|
||||
//[Column("ReferralProductId")]
|
||||
public Guid? ReferralId { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using AyCode.Interfaces.Entities;
|
||||
using AyCode.Interfaces.TimeStampInfo;
|
||||
using TIAM.Entities.Users;
|
||||
|
||||
namespace TIAM.Entities.Transfers;
|
||||
|
||||
[Table(nameof(TransferToDriver))]
|
||||
public class TransferToDriver : IEntityGuid, ITimeStampInfo, IUserProductMappingForeignKey
|
||||
{
|
||||
[Key, DatabaseGenerated(DatabaseGeneratedOption.None)]
|
||||
public Guid Id { get; set; }
|
||||
|
||||
public Guid TransferId { get; set; }
|
||||
public Guid UserProductMappingId { get; set; }
|
||||
public Guid CarId { get; set; }
|
||||
|
||||
public string LicencePlate { get; set; }
|
||||
public double Price { get; set; }
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
public DateTime Modified { get; set; }
|
||||
}
|
||||
|
|
@ -30,6 +30,7 @@ public class UserProductMapping : IEntityGuid, IUserRelation, IProductRelation,
|
|||
//private string? JsonDetails { get; set; }
|
||||
|
||||
//[Column("JsonDetailModel")]
|
||||
[NotMapped]
|
||||
public UserProductJsonDetailModel? JsonDetailModel { get; set; } = null;
|
||||
|
||||
public DateTime Created { get; set; }
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ using TIAM.Database.DataLayers.Admins;
|
|||
using TIAM.Database.DataLayers.TransferDestinations;
|
||||
using TIAM.Database.DataLayers.Users;
|
||||
using TIAM.Database.DbContexts;
|
||||
using TIAM.Entities.Products;
|
||||
using TIAM.Entities.Transfers;
|
||||
using TIAM.Entities.Users;
|
||||
using TIAMWebApp.Shared.Application.Models;
|
||||
|
|
@ -47,6 +48,51 @@ namespace TIAMWebApp.Server.Controllers
|
|||
_adminDal = adminDal;
|
||||
}
|
||||
|
||||
public double GetTransferPrice(Guid productId, Guid fromTransferDestinationId, Guid toTranferDestinationId)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
public double GetTransferPrice(Guid productId, TransferDestination fromTransferDestination, TransferDestination toTransferDestination, in byte seatNumber)
|
||||
{
|
||||
var product = _adminDal.GetProductById(productId);
|
||||
|
||||
if (product == null) return -1;
|
||||
|
||||
return GetTransferPrice(product, fromTransferDestination, toTransferDestination, in seatNumber);
|
||||
}
|
||||
|
||||
public double GetTransferPrice(Product product, TransferDestination fromTransferDestination, TransferDestination toTransferDestination, in byte seatNumber)
|
||||
{
|
||||
var baseDestination = product.Profile.AddressId == fromTransferDestination.AddressId ? toTransferDestination : fromTransferDestination;
|
||||
|
||||
var transferDestinationToProduct = _adminDal.GetTransferDestinationToProduct(product.Id, baseDestination.Id);
|
||||
|
||||
var tranferDestinationPrice = transferDestinationToProduct ?? baseDestination as ITransfeDestinationPrices;
|
||||
|
||||
var price = GetSeatNumberPrice(in tranferDestinationPrice, seatNumber);
|
||||
|
||||
//TODO: ExtraPrice - J.
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
public double GetSeatNumberPrice(in ITransfeDestinationPrices transfeDestinationPrices, in byte seatNumber)
|
||||
=> GetSeatNumberPrice(transfeDestinationPrices.Price, transfeDestinationPrices.Price2, transfeDestinationPrices.Price3, seatNumber);
|
||||
|
||||
public double GetSeatNumberPrice(in double price, in double? price2, in double? price3, in byte seatNumber)
|
||||
{
|
||||
if (seatNumber >= (byte)SeatNumberPriceType.Price3SeatNum)
|
||||
return price3 ?? price; //TODO: *seatnum percent - J.
|
||||
|
||||
if (seatNumber >= (byte)SeatNumberPriceType.Price2SeatNum)
|
||||
return price2 ?? price; //TODO: *seatnum percent - J.
|
||||
|
||||
return price;
|
||||
}
|
||||
|
||||
//public double GetExtraPrice(bool? extraPriceType){}
|
||||
|
||||
[AllowAnonymous]
|
||||
[HttpGet]
|
||||
[Route(APIUrls.GetTransferDestinationsRouteName)]
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ namespace TIAMWebApp.Shared.Application.Services
|
|||
this.logToBrowserConsole = logToBrowserConsole;
|
||||
}
|
||||
|
||||
|
||||
public async Task<List<TransferDestination>> GetDestinationsAsync()
|
||||
{
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue