Switched to MPA powered by Razor Pages

After reconsidering where I want to take this project, I realized that a MPA is more fitting.
This commit is contained in:
2021-07-20 19:08:57 -05:00
parent e0756e0967
commit 57f67391f1
141 changed files with 5292 additions and 22079 deletions

View File

@@ -0,0 +1,14 @@
using System.ComponentModel.DataAnnotations;
namespace Props.Shared.Models
{
public class ApplicationPreferences
{
public int Id { get; set; }
[Required]
public string ApplicationUserId { get; set; }
public bool EnableSearchHistory { get; set; } = true;
}
}

View 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;
namespace Props.Models
{
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;
}
}
}

View 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,
}
}
}

View 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;
}
}
}