Added identifier and fetch time product listings; Added persistence to AdafruitShop.

Implemented in AdafruitShop.

AdafruitShop Product listing data now persisted.

AdafruitShop configuration now persisted.
This commit is contained in:
2021-08-09 13:32:16 -05:00
parent 38ffb3c7e1
commit 0b507b90a1
28 changed files with 251 additions and 349 deletions

View File

@@ -15,9 +15,10 @@ namespace Props.Shop.Framework
public IAsyncEnumerable<ProductListing> Search(string query, Filters filters);
public Task<ProductListing> GetProductListingFromUrl(string url);
public Task<ProductListing> GetProductFromIdentifier(string identifier);
void Initialize(string workspaceDir, ILoggerFactory loggerFactory);
ValueTask SaveData();
public SupportedFeatures SupportedFeatures { get; }
}
}

View File

@@ -1,3 +1,5 @@
using System;
namespace Props.Shop.Framework
{
public class ProductListing
@@ -13,5 +15,41 @@ namespace Props.Shop.Framework
public int? ReviewCount { get; set; }
public bool ConvertedPrices { get; set; }
public bool? InStock { get; set; }
public string Identifier { get; set; }
public DateTime TimeFetchedUtc { get; set; }
public override bool Equals(object obj)
{
if (obj == null || GetType() != obj.GetType())
{
return false;
}
ProductListing other = obj as ProductListing;
return
this.LowerPrice == other.LowerPrice &&
this.UpperPrice == other.UpperPrice &&
this.Shipping == other.Shipping &&
this.Name == other.Name &&
this.URL == other.URL &&
this.ImageURL == other.ImageURL &&
this.Rating == other.Rating &&
this.PurchaseCount == other.PurchaseCount &&
this.ReviewCount == other.ReviewCount &&
this.ConvertedPrices == other.ConvertedPrices &&
this.InStock == other.InStock &&
this.Identifier == other.Identifier &&
this.TimeFetchedUtc == other.TimeFetchedUtc;
}
public override int GetHashCode()
{
return (Name, URL, UpperPrice, LowerPrice, ImageURL).GetHashCode();
}
public ProductListing Copy()
{
return MemberwiseClone() as ProductListing;
}
}
}