Implemented groundwork for search configuration.

This commit is contained in:
2021-07-22 16:12:27 -05:00
parent 3129e5e564
commit 2719142538
41 changed files with 1037 additions and 205 deletions

View File

@@ -0,0 +1,18 @@
using System;
using Props.Shop.Framework;
namespace Props.Models.Search
{
public class ProductListingInfo
{
public int Id { get; set; }
public uint Hits { get; set; }
public DateTime LastUpdated { get; set; }
public string ProductUrl { get; set; }
public string ProductName { get; set; }
}
}

View File

@@ -2,23 +2,27 @@ using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using Props.Models.User;
using Props.Shop.Framework;
namespace Props.Models
namespace Props.Models.Search
{
public class SearchOutline
{
public int Id { get; set; }
[Required]
public string ApplicationUserId { get; set; }
public Filters Filters { get; set; }
public int MaxResults { get; set; } = 100;
[Required]
public virtual ApplicationUser ApplicationUser { get; set; }
public Filters Filters { get; set; } = new Filters();
[Required]
public ShopToggler ShopStates { get; set; } = new ShopToggler();
public ShopsDisabled Disabled { get; set; } = new ShopsDisabled();
public sealed class ShopToggler : HashSet<string>
public sealed class ShopsDisabled : HashSet<string>
{
public int TotalShops { get; set; }
public bool this[string name]
@@ -41,9 +45,9 @@ namespace Props.Models
}
}
public ShopToggler Copy()
public ShopsDisabled Copy()
{
ShopToggler copy = new ShopToggler();
ShopsDisabled copy = new ShopsDisabled();
copy.Union(this);
return copy;
}
@@ -63,9 +67,8 @@ namespace Props.Models
SearchOutline other = (SearchOutline)obj;
return
Id == other.Id &&
MaxResults == other.MaxResults &&
Filters.Equals(other.Filters) &&
ShopStates.Equals(other.ShopStates);
Disabled.Equals(other.Disabled);
}
public override int GetHashCode()

View File

@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Props.Models.User;
namespace Props.Shared.Models.User
{
@@ -9,6 +10,9 @@ namespace Props.Shared.Models.User
[Required]
public string ApplicationUserId { get; set; }
[Required]
public virtual ApplicationUser ApplicationUser { get; set; }
public bool EnableSearchHistory { get; set; } = true;
public bool DarkMode { get; set; } = false;
}

View File

@@ -4,30 +4,30 @@ using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
using Props.Models.Search;
using Props.Shared.Models.User;
namespace Props.Models.User
{
public class ApplicationUser : IdentityUser
{
[Required]
public virtual SearchOutline SearchOutline { get; private set; }
public virtual ISet<SearchOutline> SearchOutlines { get; set; }
[Required]
public virtual ResultsPreferences ResultsPreferences { get; private set; }
[Required]
public virtual ApplicationPreferences ApplicationPreferences { get; private set; }
// TODO: Write project system.
public ApplicationUser()
{
SearchOutline = new SearchOutline();
ResultsPreferences = new ResultsPreferences();
ApplicationPreferences = new ApplicationPreferences();
}
public ApplicationUser(SearchOutline searchOutline, ResultsPreferences resultsPreferences, ApplicationPreferences applicationPreferences)
public ApplicationUser(ResultsPreferences resultsPreferences, ApplicationPreferences applicationPreferences)
{
this.SearchOutline = searchOutline;
this.ResultsPreferences = resultsPreferences;
this.ApplicationPreferences = applicationPreferences;
}

View File

@@ -3,18 +3,27 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text.Json;
using Props.Models.User;
namespace Props.Models
{
public class ResultsPreferences
{
public int Id { get; set; }
[Required]
public string ApplicationUserId { get; set; }
[Required]
public virtual ApplicationUser ApplicationUser { get; set; }
[Required]
public IList<Category> Order { get; set; }
[Required]
public string ProfileName { get; set; }
public ResultsPreferences()
{
Order = new List<Category>(Enum.GetValues<Category>().Length);