mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-29 20:22:32 +00:00
Fix error when slot on case does not exist
This commit is contained in:
parent
f0a9fc324f
commit
643b00512a
2 changed files with 14 additions and 8 deletions
|
@ -40,13 +40,19 @@
|
||||||
|
|
||||||
@if (Model.Type.AffectsLevel())
|
@if (Model.Type.AffectsLevel())
|
||||||
{
|
{
|
||||||
Slot slot = await Model.GetSlotAsync(database);
|
Slot? slot = await Model.GetSlotAsync(database);
|
||||||
<p><strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name</a></p>
|
if (slot != null)
|
||||||
|
{
|
||||||
|
<p><strong>Affected level:</strong> <a href="/slot/@slot.SlotId">@slot.Name</a></p>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (Model.Type.AffectsUser())
|
else if (Model.Type.AffectsUser())
|
||||||
{
|
{
|
||||||
User user = await Model.GetUserAsync(database);
|
User? user = await Model.GetUserAsync(database);
|
||||||
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
|
if (user != null)
|
||||||
|
{
|
||||||
|
<p><strong>Affected user:</strong> <a href="/user/@user.UserId">@user.Username</a></p>
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
<h3>Reason</h3>
|
<h3>Reason</h3>
|
||||||
|
|
|
@ -42,16 +42,16 @@ public class ModerationCase
|
||||||
public int AffectedId { get; set; }
|
public int AffectedId { get; set; }
|
||||||
|
|
||||||
#region Get affected id result
|
#region Get affected id result
|
||||||
public Task<User> GetUserAsync(Database database)
|
public Task<User?> GetUserAsync(Database database)
|
||||||
{
|
{
|
||||||
Debug.Assert(this.Type.AffectsUser());
|
Debug.Assert(this.Type.AffectsUser());
|
||||||
return database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId)!;
|
return database.Users.FirstOrDefaultAsync(u => u.UserId == this.AffectedId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Task<Slot> GetSlotAsync(Database database)
|
public Task<Slot?> GetSlotAsync(Database database)
|
||||||
{
|
{
|
||||||
Debug.Assert(this.Type.AffectsLevel());
|
Debug.Assert(this.Type.AffectsLevel());
|
||||||
return database.Slots.FirstOrDefaultAsync(u => u.SlotId == this.AffectedId)!;
|
return database.Slots.FirstOrDefaultAsync(u => u.SlotId == this.AffectedId);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue