-
-
My application
-
-
-
-
- The application is loading...
-
-
+
+
+
+
+
+
Please wait while WardrobeManager loads...
+
- An unhandled error has occurred.
-
Reload
-
🗙
+ An unhandled error has occurred.
+
Reload
+
🗙
-
-
-
-
-
-
-
+
+
diff --git a/WardrobeManager.Shared/Exceptions/UserNotFoundException.cs b/WardrobeManager.Shared/Exceptions/UserNotFoundException.cs
new file mode 100644
index 0000000..69e1a9f
--- /dev/null
+++ b/WardrobeManager.Shared/Exceptions/UserNotFoundException.cs
@@ -0,0 +1,12 @@
+namespace WardrobeManager.Shared.Exceptions;
+
+[Serializable]
+public class UserNotFoundException : Exception {
+ public UserNotFoundException() { }
+
+ public UserNotFoundException(string message)
+ : base(message) { }
+
+ public UserNotFoundException(string message, Exception inner)
+ : base(message, inner) { }
+}
diff --git a/WardrobeManager.Shared/Models/ServerClothingItem.cs b/WardrobeManager.Shared/Models/ServerClothingItem.cs
index df13a28..ae67841 100644
--- a/WardrobeManager.Shared/Models/ServerClothingItem.cs
+++ b/WardrobeManager.Shared/Models/ServerClothingItem.cs
@@ -1,22 +1,33 @@
using System.Diagnostics.CodeAnalysis;
using WardrobeManager.Shared.Enums;
+using System.Text.Json.Serialization;
namespace WardrobeManager.Shared.Models;
public class ServerClothingItem
{
public ServerClothingItem() { } // ONLY FOR DESERIALIZER, DO NOT USE THIS. THIS SHIT BETTER HAVE NO REFERENCES
- // deserializer needs a way to create the object without any fields so it can assign them if they exist
+ // deserializer needs a way to create the object without any fields so it can assign them if they exist
- public ServerClothingItem(string userId, string name, ClothingCategory category, Guid? imageGuid)
+ public ServerClothingItem(string name, ClothingCategory category, Guid? imageGuid)
{
- this.UserId = userId;
+ // this.UserId = userId;
this.Name = name;
this.Category = category;
this.ImageGuid = imageGuid;
}
- // User modifies
+ // EF Core modifies
+ public int Id { get; set; }
+
+ // represents a mandatory one-to-many relationship with a User as
+ // the following 2 fields are not nullable
+ // https://learn.microsoft.com/en-us/ef/core/modeling/relationships/one-to-many
+ [JsonIgnore] // causes the serializer to run into loop
+ public User User { get; set; } // navigation property
+ public int UserId { get; set; }
+
+ // User modifies
public string Name { get; set; }
public ClothingCategory Category { get; set; }
public Season? Season { get; set; } // doesn't have to be set
@@ -30,8 +41,6 @@ public ServerClothingItem(string userId, string name, ClothingCategory category,
// Only program modifies
- public int Id { get; set; }
- public string UserId { get; set; } // Auth0 OIDC id, this is unique: https://auth0.com/docs/manage-users/user-accounts/identify-users
public int TimesWornSinceWash { get; set; } = 0;
public int TimesWornTotal { get; set; } = 0; // initialized at zero since the user can change this later
public DateTime LastWorn { get; set; }
diff --git a/WardrobeManager.Shared/Models/User.cs b/WardrobeManager.Shared/Models/User.cs
index 65e8590..266b51b 100644
--- a/WardrobeManager.Shared/Models/User.cs
+++ b/WardrobeManager.Shared/Models/User.cs
@@ -5,10 +5,13 @@
using System.Threading.Tasks;
namespace WardrobeManager.Shared.Models;
-public class User(string userid)
+public class User(string Auth0Id)
{
+ // Personal info
public int Id { get; set; }
- public string UserId { get; set; } = userid; // auth0 id
+ public string Auth0Id { get; set; } = Auth0Id; // used to identify user from auth0
- public List
? ServerClothingItems { get; set;}
+ // Data relationships
+ // 1-many relationship with serverclothingitems
+ public List ServerClothingItems { get; set;} = new List();
}