I have two classes, one for User
, and one for Warn
that a said user can receive, and I'd like to map them, but I'm having an issue with doing so.
using System;
using System.Collections.Generic;
using System.Linq;
namespace web
{
public class User
{
public User()
{
}
public ICollection<MuteWarn> Mutes { get; set; }
public ICollection<Warn> Warns { get; set; }
public ICollection<Ban> Bans { get; set; }
public ICollection<Kick> Kicks { get; set; }
public int Id { get; set; }
public ulong DiscordId { get; set; }
public bool AntiBan { get; set; }
public ICollection<string> Permissions { get; set; }
public Level Level { get; set; }
public Mute CurrentMute { get; set; }
public string Name { get; set; }
public int Discrim { get; set; }
public string AvatarUrl { get; set; }
public Guild Guild { get; set; }
public bool HasPermission(string perm)
{
var res = Permissions.Where(x => x == perm);
if(res != null) return true;
return false;
}
}
}
This is the User
class, and here is the Warn
class:
using System;
namespace web
{
public class Warn
{
public Warn()
{
Moderator = DataHelper.GetDefaultModerator();
}
public int Id { get; set; }
public string Reason { get; set; }
public DateTime Timestamp { get; set; }
public User Moderator { get; set; }
public User User { get; set; }
public Guild Guild { get; set; }
}
}
As you can see there are two objects of type User
in this class, and I'd like to access them from the User class like so:
foreach(var w in User.Warns)
{
Console.WriteLine(w.Reason);
Console.WriteLine(w.Moderator.Name);
}
and etc.
The moderator and user are two separate users (even though they can be the same person).
The Moderator is the person who issues this warn, and the User is the user who receives the warn.
Each user can have an unlimited number of warns.
For some reason this will not build because it cannot find the relationship between Moderator and User.
Please do help, thank you.