mirror of
https://github.com/LBPUnion/ProjectLighthouse.git
synced 2025-05-07 03:02:28 +00:00
34 lines
No EOL
1 KiB
C#
34 lines
No EOL
1 KiB
C#
#nullable enable
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using LBPUnion.ProjectLighthouse.Types;
|
|
using LBPUnion.ProjectLighthouse.Types.Profiles;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
namespace LBPUnion.ProjectLighthouse.Helpers;
|
|
|
|
public static class LastContactHelper
|
|
{
|
|
private static readonly Database database = new();
|
|
|
|
public static async Task SetLastContact(User user, GameVersion gameVersion)
|
|
{
|
|
LastContact? lastContact = await database.LastContacts.Where(l => l.UserId == user.UserId).FirstOrDefaultAsync();
|
|
|
|
// below makes it not look like trash
|
|
// ReSharper disable once ConvertIfStatementToNullCoalescingExpression
|
|
if (lastContact == null)
|
|
{
|
|
lastContact = new LastContact
|
|
{
|
|
UserId = user.UserId,
|
|
};
|
|
database.LastContacts.Add(lastContact);
|
|
}
|
|
|
|
lastContact.Timestamp = TimestampHelper.Timestamp;
|
|
lastContact.GameVersion = gameVersion;
|
|
|
|
await database.SaveChangesAsync();
|
|
}
|
|
} |