refractor getprice methods
This commit is contained in:
parent
5d4abbc220
commit
a5266f3d79
|
|
@ -48,51 +48,7 @@ namespace TIAMWebApp.Server.Controllers
|
||||||
_adminDal = adminDal;
|
_adminDal = adminDal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetTransferPrice(Guid productId, Guid fromTransferDestinationId, Guid toTranferDestinationId, in byte seatNumber)
|
|
||||||
{
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
return seatNumber switch
|
|
||||||
{
|
|
||||||
>= (byte)SeatNumberPriceType.Price3SeatNum => price3 ?? price //TODO: price * seatnum percent - J.
|
|
||||||
,
|
|
||||||
>= (byte)SeatNumberPriceType.Price2SeatNum => price2 ?? price //TODO: price * seatnum percent - J.
|
|
||||||
,
|
|
||||||
_ => price
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
//public double GetExtraPrice(bool? extraPriceType){}
|
|
||||||
|
|
||||||
[AllowAnonymous]
|
[AllowAnonymous]
|
||||||
[HttpGet]
|
[HttpGet]
|
||||||
|
|
|
||||||
|
|
@ -13,12 +13,11 @@ namespace TIAMWebApp.Server.Services
|
||||||
|
|
||||||
public TransferBackendService(IConfiguration configuration, AdminDal adminDal)
|
public TransferBackendService(IConfiguration configuration, AdminDal adminDal)
|
||||||
{
|
{
|
||||||
|
|
||||||
_configuration = configuration;
|
_configuration = configuration;
|
||||||
_adminDal = adminDal;
|
_adminDal = adminDal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetTransferPrice(Guid productId, Guid fromTransferDestinationId, Guid toTranferDestinationId)
|
public double GetTransferPrice(Guid productId, Guid fromTransferDestinationId, Guid toTranferDestinationId, in byte seatNumber)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
|
|
@ -52,13 +51,15 @@ namespace TIAMWebApp.Server.Services
|
||||||
|
|
||||||
public double GetSeatNumberPrice(in double price, in double? price2, in double? price3, in byte seatNumber)
|
public double GetSeatNumberPrice(in double price, in double? price2, in double? price3, in byte seatNumber)
|
||||||
{
|
{
|
||||||
if (seatNumber >= (byte)SeatNumberPriceType.Price3SeatNum)
|
return seatNumber switch
|
||||||
return price3 ?? price; //TODO: *seatnum percent - J.
|
{
|
||||||
|
>= (byte)SeatNumberPriceType.Price3SeatNum => price3 ?? price //TODO: price * seatnum percent - J.
|
||||||
if (seatNumber >= (byte)SeatNumberPriceType.Price2SeatNum)
|
,
|
||||||
return price2 ?? price; //TODO: *seatnum percent - J.
|
>= (byte)SeatNumberPriceType.Price2SeatNum => price2 ?? price //TODO: price * seatnum percent - J.
|
||||||
|
,
|
||||||
return price;
|
_ => price
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue