2021-07-12 08:07:16 +00:00
|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
|
using System.Linq;
|
2021-07-22 21:12:27 +00:00
|
|
|
using Props.Models.User;
|
2021-07-13 05:35:31 +00:00
|
|
|
using Props.Shop.Framework;
|
2021-07-12 08:07:16 +00:00
|
|
|
|
2021-07-22 21:12:27 +00:00
|
|
|
namespace Props.Models.Search
|
2021-07-12 08:07:16 +00:00
|
|
|
{
|
|
|
|
public class SearchOutline
|
|
|
|
{
|
|
|
|
public int Id { get; set; }
|
2021-07-22 21:12:27 +00:00
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public int SearchOutlinePreferencesId { get; set; }
|
2021-07-12 08:07:16 +00:00
|
|
|
|
2021-07-22 21:12:27 +00:00
|
|
|
[Required]
|
2021-08-17 07:59:01 +00:00
|
|
|
public virtual SearchOutlinePreferences SearchOutlinePreferences { get; set; }
|
2021-07-22 21:12:27 +00:00
|
|
|
|
2021-08-05 06:22:19 +00:00
|
|
|
[Required]
|
2021-08-17 07:59:01 +00:00
|
|
|
public string Name { get; set; }
|
2021-07-12 08:07:16 +00:00
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public Filters Filters { get; set; }
|
2021-07-12 08:07:16 +00:00
|
|
|
[Required]
|
2021-08-17 07:59:01 +00:00
|
|
|
public ShopSelector DisabledShops { get; set; }
|
2021-07-12 08:07:16 +00:00
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public sealed class ShopSelector : HashSet<string>
|
2021-07-12 08:07:16 +00:00
|
|
|
{
|
2021-07-14 06:13:19 +00:00
|
|
|
public bool this[string name]
|
|
|
|
{
|
|
|
|
get
|
|
|
|
{
|
2021-08-17 07:59:01 +00:00
|
|
|
return this.Contains(name);
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
2021-07-14 06:13:19 +00:00
|
|
|
set
|
|
|
|
{
|
2021-07-12 08:07:16 +00:00
|
|
|
if (value)
|
|
|
|
{
|
2021-08-17 07:59:01 +00:00
|
|
|
this.Add(name);
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-08-17 07:59:01 +00:00
|
|
|
this.Remove(name);
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public ShopSelector()
|
2021-07-14 06:13:19 +00:00
|
|
|
{
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public ShopSelector(IEnumerable<string> disabledShops) : base(disabledShops)
|
2021-07-12 08:07:16 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override bool Equals(object obj)
|
|
|
|
{
|
|
|
|
if (obj == null || GetType() != obj.GetType())
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2021-07-14 06:13:19 +00:00
|
|
|
SearchOutline other = (SearchOutline)obj;
|
|
|
|
return
|
|
|
|
Id == other.Id &&
|
2021-08-17 07:59:01 +00:00
|
|
|
Name.Equals(other.Name) &&
|
2021-07-14 06:13:19 +00:00
|
|
|
Filters.Equals(other.Filters) &&
|
2021-08-17 07:59:01 +00:00
|
|
|
DisabledShops.Equals(other.DisabledShops);
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
2021-07-14 06:13:19 +00:00
|
|
|
|
2021-07-12 08:07:16 +00:00
|
|
|
public override int GetHashCode()
|
|
|
|
{
|
2021-08-17 07:59:01 +00:00
|
|
|
return HashCode.Combine(Id, Name, Filters, DisabledShops);
|
2021-08-05 06:22:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public SearchOutline()
|
|
|
|
{
|
|
|
|
this.Filters = new Filters();
|
2021-08-17 07:59:01 +00:00
|
|
|
this.DisabledShops = new ShopSelector();
|
2021-08-05 06:22:19 +00:00
|
|
|
}
|
|
|
|
|
2021-08-17 07:59:01 +00:00
|
|
|
public SearchOutline(string name, Filters filters, ShopSelector disabled)
|
2021-08-05 06:22:19 +00:00
|
|
|
{
|
|
|
|
this.Name = name;
|
|
|
|
this.Filters = filters;
|
2021-08-17 07:59:01 +00:00
|
|
|
this.DisabledShops = disabled;
|
2021-07-12 08:07:16 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|