Implemented groundwork for search configuration.
This commit is contained in:
18
Props/Models/Search/ProductListingInfo.cs
Normal file
18
Props/Models/Search/ProductListingInfo.cs
Normal 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; }
|
||||
}
|
||||
}
|
79
Props/Models/Search/SearchOutline.cs
Normal file
79
Props/Models/Search/SearchOutline.cs
Normal file
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Props.Models.User;
|
||||
using Props.Shop.Framework;
|
||||
|
||||
namespace Props.Models.Search
|
||||
{
|
||||
public class SearchOutline
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public virtual ApplicationUser ApplicationUser { get; set; }
|
||||
|
||||
public Filters Filters { get; set; } = new Filters();
|
||||
|
||||
[Required]
|
||||
public ShopsDisabled Disabled { get; set; } = new ShopsDisabled();
|
||||
|
||||
public sealed class ShopsDisabled : HashSet<string>
|
||||
{
|
||||
public int TotalShops { get; set; }
|
||||
public bool this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return !this.Contains(name);
|
||||
}
|
||||
set
|
||||
{
|
||||
if (value == false && TotalShops - Count <= 1) return;
|
||||
if (value)
|
||||
{
|
||||
this.Remove(name);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Add(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public ShopsDisabled Copy()
|
||||
{
|
||||
ShopsDisabled copy = new ShopsDisabled();
|
||||
copy.Union(this);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public bool IsShopToggleable(string shop)
|
||||
{
|
||||
return (!Contains(shop) && TotalShops - Count > 1) || Contains(shop);
|
||||
}
|
||||
}
|
||||
|
||||
public override bool Equals(object obj)
|
||||
{
|
||||
if (obj == null || GetType() != obj.GetType())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SearchOutline other = (SearchOutline)obj;
|
||||
return
|
||||
Id == other.Id &&
|
||||
Filters.Equals(other.Filters) &&
|
||||
Disabled.Equals(other.Disabled);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user