Basic search outline config UI implemented.

This commit is contained in:
2021-08-17 02:59:01 -05:00
parent 8a1e5aca15
commit c6b8ca523b
25 changed files with 1047 additions and 520 deletions

View File

@@ -123,8 +123,13 @@ namespace Props.Shop.Adafruit
if (workspaceDir != null)
{
logger.LogDebug("Saving data in \"{0}\"...", workspaceDir);
string configurationPath = Path.Combine(workspaceDir, Configuration.FILE_NAME);
File.Delete(configurationPath);
await File.WriteAllTextAsync(Path.Combine(workspaceDir, Configuration.FILE_NAME), JsonSerializer.Serialize(configuration));
using (Stream fileStream = File.OpenWrite(Path.Combine(workspaceDir, ProductListingCacheData.FILE_NAME)))
string productListingCachePath = Path.Combine(workspaceDir, ProductListingCacheData.FILE_NAME);
File.Delete(productListingCachePath);
using (Stream fileStream = File.OpenWrite(productListingCachePath))
{
await JsonSerializer.SerializeAsync(fileStream, new ProductListingCacheData(await searchManager.ProductListingManager.ProductListings));
}

View File

@@ -5,12 +5,12 @@ namespace Props.Shop.Framework
public class Filters
{
public Currency Currency { get; set; } = Currency.CAD;
private float minRatingNormalized;
private float minRatingNormalized = 0.8f;
public int MinRating
{
get
{
return (int)(minRatingNormalized * 100);
return (int)(minRatingNormalized * 100f);
}
set
{
@@ -38,7 +38,7 @@ namespace Props.Shop.Framework
public bool KeepUnknownPurchaseCount { get; set; } = true;
public int MinReviews { get; set; }
public bool KeepUnknownReviewCount { get; set; } = true;
public bool EnableMaxShippingFee { get; set; }
public bool EnableMaxShipping { get; set; }
private int maxShippingFee;
public int MaxShippingFee
@@ -49,7 +49,7 @@ namespace Props.Shop.Framework
}
set
{
if (EnableMaxShippingFee) maxShippingFee = value;
if (EnableMaxShipping) maxShippingFee = value;
}
}
public bool KeepUnknownShipping { get; set; } = true;
@@ -72,7 +72,7 @@ namespace Props.Shop.Framework
KeepUnknownPurchaseCount == other.KeepUnknownPurchaseCount &&
MinReviews == other.MinReviews &&
KeepUnknownReviewCount == other.KeepUnknownReviewCount &&
EnableMaxShippingFee == other.EnableMaxShippingFee &&
EnableMaxShipping == other.EnableMaxShipping &&
MaxShippingFee == other.MaxShippingFee &&
KeepUnknownShipping == other.KeepUnknownShipping;
@@ -96,7 +96,7 @@ namespace Props.Shop.Framework
public bool Validate(ProductListing listing)
{
if (listing.Shipping == null && !KeepUnknownShipping || (EnableMaxShippingFee && listing.Shipping > MaxShippingFee)) return false;
if (listing.Shipping == null && !KeepUnknownShipping || (EnableMaxShipping && listing.Shipping > MaxShippingFee)) return false;
float shippingDifference = listing.Shipping != null ? listing.Shipping.Value : 0;
if (!(listing.LowerPrice + shippingDifference >= LowerPrice && (!EnableUpperPrice || listing.UpperPrice + shippingDifference <= UpperPrice))) return false;
if ((listing.Rating == null && !KeepUnrated) && MinRating > (listing.Rating == null ? 0 : listing.Rating)) return false;