Ported progress from SPA and began scaffolding Identity UI.
Laid some groundwork in backend. Began customizing Identity UI.
This commit is contained in:
15
Props/Models/User/ApplicationPreferences.cs
Normal file
15
Props/Models/User/ApplicationPreferences.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Props.Shared.Models.User
|
||||
{
|
||||
public class ApplicationPreferences
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
public bool EnableSearchHistory { get; set; } = true;
|
||||
public bool DarkMode { get; set; } = false;
|
||||
}
|
||||
}
|
35
Props/Models/User/ApplicationUser.cs
Normal file
35
Props/Models/User/ApplicationUser.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Props.Shared.Models.User;
|
||||
|
||||
namespace Props.Models.User
|
||||
{
|
||||
public class ApplicationUser : IdentityUser
|
||||
{
|
||||
[Required]
|
||||
public virtual SearchOutline SearchOutline { get; private set; }
|
||||
[Required]
|
||||
public virtual ResultsPreferences ResultsPreferences { get; private set; }
|
||||
|
||||
[Required]
|
||||
public virtual ApplicationPreferences ApplicationPreferences { get; private set; }
|
||||
|
||||
public ApplicationUser()
|
||||
{
|
||||
SearchOutline = new SearchOutline();
|
||||
ResultsPreferences = new ResultsPreferences();
|
||||
ApplicationPreferences = new ApplicationPreferences();
|
||||
}
|
||||
|
||||
public ApplicationUser(SearchOutline searchOutline, ResultsPreferences resultsPreferences, ApplicationPreferences applicationPreferences)
|
||||
{
|
||||
this.SearchOutline = searchOutline;
|
||||
this.ResultsPreferences = resultsPreferences;
|
||||
this.ApplicationPreferences = applicationPreferences;
|
||||
}
|
||||
}
|
||||
}
|
35
Props/Models/User/ResultsPreferences.cs
Normal file
35
Props/Models/User/ResultsPreferences.cs
Normal file
@@ -0,0 +1,35 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace Props.Models
|
||||
{
|
||||
public class ResultsPreferences
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
[Required]
|
||||
public IList<Category> Order { get; set; }
|
||||
|
||||
public ResultsPreferences()
|
||||
{
|
||||
Order = new List<Category>(Enum.GetValues<Category>().Length);
|
||||
foreach (Category category in Enum.GetValues<Category>())
|
||||
{
|
||||
Order.Add(category);
|
||||
}
|
||||
}
|
||||
|
||||
public enum Category
|
||||
{
|
||||
RatingPriceRatio,
|
||||
Reviews,
|
||||
Purchases,
|
||||
Price,
|
||||
}
|
||||
}
|
||||
}
|
76
Props/Models/User/SearchOutline.cs
Normal file
76
Props/Models/User/SearchOutline.cs
Normal file
@@ -0,0 +1,76 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.Linq;
|
||||
using Props.Shop.Framework;
|
||||
|
||||
namespace Props.Models
|
||||
{
|
||||
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 ShopToggler ShopStates { get; set; } = new ShopToggler();
|
||||
|
||||
public sealed class ShopToggler : 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 ShopToggler Copy()
|
||||
{
|
||||
ShopToggler copy = new ShopToggler();
|
||||
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 &&
|
||||
MaxResults == other.MaxResults &&
|
||||
Filters.Equals(other.Filters) &&
|
||||
ShopStates.Equals(other.ShopStates);
|
||||
}
|
||||
|
||||
public override int GetHashCode()
|
||||
{
|
||||
return Id;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user