Made foreign keys required causing cascade deletion.
Removed completed TODO comments.
This commit is contained in:
@@ -1,9 +1,12 @@
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
|
||||
namespace Props.Shared.Models
|
||||
{
|
||||
public class ApplicationPreferences
|
||||
{
|
||||
public int Id { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
public bool DarkMode { get; set; }
|
||||
|
@@ -1,22 +1,36 @@
|
||||
using Microsoft.AspNetCore.Identity;
|
||||
using Props.Shared.Models;
|
||||
using System;
|
||||
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; } = new SearchOutline();
|
||||
public virtual SearchOutline SearchOutline { get; private set; }
|
||||
|
||||
[Required]
|
||||
public virtual ResultsPreferences ResultsPreferences { get; private set; } = new ResultsPreferences();
|
||||
public virtual ResultsPreferences ResultsPreferences { get; private set; }
|
||||
|
||||
[Required]
|
||||
public virtual ApplicationPreferences ApplicationPreferences {get; private set; } = new ApplicationPreferences();
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -9,8 +9,9 @@ namespace Props.Models
|
||||
public class ResultsPreferences
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
|
||||
[Required]
|
||||
public IList<Category> Order { get; set; }
|
||||
|
||||
|
@@ -9,46 +9,11 @@ namespace Props.Models
|
||||
public class SearchOutline
|
||||
{
|
||||
public int Id { get; set; }
|
||||
[Required]
|
||||
public string ApplicationUserId { get; set; }
|
||||
|
||||
public Currency Currency { get; set; } = Currency.CAD;
|
||||
public Filters Filters { get; set; }
|
||||
public int MaxResults { get; set; } = 100;
|
||||
public float MinRating { get; set; } = 0.8f;
|
||||
public bool KeepUnrated { get; set; } = true;
|
||||
public bool EnableUpperPrice { get; set; } = false;
|
||||
private int _upperPrice;
|
||||
|
||||
public int UpperPrice
|
||||
{
|
||||
get
|
||||
{
|
||||
return _upperPrice;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EnableUpperPrice) _upperPrice = value;
|
||||
}
|
||||
}
|
||||
public int LowerPrice { get; set; }
|
||||
public int MinPurchases { get; set; }
|
||||
public bool KeepUnknownPurchaseCount { get; set; } = true;
|
||||
public int MinReviews { get; set; }
|
||||
public bool KeepUnknownRatingCount { get; set; } = true;
|
||||
public bool EnableMaxShippingFee { get; set; }
|
||||
private int _maxShippingFee;
|
||||
|
||||
public int MaxShippingFee
|
||||
{
|
||||
get
|
||||
{
|
||||
return _maxShippingFee;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (EnableMaxShippingFee) _maxShippingFee = value;
|
||||
}
|
||||
}
|
||||
public bool KeepUnknownShipping { get; set; } = true;
|
||||
|
||||
[Required]
|
||||
public ShopToggler ShopStates { get; set; } = new ShopToggler();
|
||||
@@ -56,11 +21,14 @@ namespace Props.Models
|
||||
public sealed class ShopToggler : HashSet<string>
|
||||
{
|
||||
public int TotalShops { get; set; }
|
||||
public bool this[string name] {
|
||||
get {
|
||||
public bool this[string name]
|
||||
{
|
||||
get
|
||||
{
|
||||
return !this.Contains(name);
|
||||
}
|
||||
set {
|
||||
set
|
||||
{
|
||||
if (value == false && TotalShops - Count <= 1) return;
|
||||
if (value)
|
||||
{
|
||||
@@ -73,10 +41,11 @@ namespace Props.Models
|
||||
}
|
||||
}
|
||||
|
||||
public ShopToggler Clone() {
|
||||
ShopToggler clone = new ShopToggler();
|
||||
clone.Union(this);
|
||||
return clone;
|
||||
public ShopToggler Copy()
|
||||
{
|
||||
ShopToggler copy = new ShopToggler();
|
||||
copy.Union(this);
|
||||
return copy;
|
||||
}
|
||||
|
||||
public bool IsShopToggleable(string shop)
|
||||
@@ -91,35 +60,17 @@ namespace Props.Models
|
||||
{
|
||||
return false;
|
||||
}
|
||||
SearchOutline other = (SearchOutline) obj;
|
||||
return
|
||||
Id == other.Id &&
|
||||
Currency == other.Currency &&
|
||||
MaxResults == other.MaxResults &&
|
||||
MinRating == other.MinRating &&
|
||||
KeepUnrated == other.KeepUnrated &&
|
||||
EnableUpperPrice == other.EnableUpperPrice &&
|
||||
UpperPrice == other.UpperPrice &&
|
||||
LowerPrice == other.LowerPrice &&
|
||||
MinPurchases == other.MinPurchases &&
|
||||
KeepUnknownPurchaseCount == other.KeepUnknownPurchaseCount &&
|
||||
MinReviews == other.MinReviews &&
|
||||
KeepUnknownRatingCount == other.KeepUnknownRatingCount &&
|
||||
EnableMaxShippingFee == other.EnableMaxShippingFee &&
|
||||
MaxShippingFee == other.MaxShippingFee &&
|
||||
KeepUnknownShipping == other.KeepUnknownShipping &&
|
||||
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;
|
||||
}
|
||||
|
||||
public SearchOutline DeepCopy() {
|
||||
SearchOutline profile = (SearchOutline)MemberwiseClone();
|
||||
profile.ShopStates = ShopStates.Clone();
|
||||
return profile;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user