ProjectLighthouse/ProjectLighthouse/Helpers/LastContactHelper.cs
Josh a69d94054b
Simplify filters and make cross control slots not show by default (#782)
* Simplify filters and make cross control slots not show by default
Also sort author levels by oldest levels first rather than newest levels first.

* Fix unit test expecting slots to sorted by timestamp descending

* Remove errant whitespace
2023-06-05 22:53:41 +00:00

32 lines
No EOL
1,017 B
C#

#nullable enable
using System.Linq;
using System.Threading.Tasks;
using LBPUnion.ProjectLighthouse.Database;
using LBPUnion.ProjectLighthouse.Types.Entities.Profile;
using LBPUnion.ProjectLighthouse.Types.Users;
using Microsoft.EntityFrameworkCore;
namespace LBPUnion.ProjectLighthouse.Helpers;
public static class LastContactHelper
{
public static async Task SetLastContact(DatabaseContext database, UserEntity user, GameVersion gameVersion, Platform platform)
{
LastContactEntity? lastContact = await database.LastContacts.Where(l => l.UserId == user.UserId).FirstOrDefaultAsync();
if (lastContact == null)
{
lastContact = new LastContactEntity
{
UserId = user.UserId,
};
database.LastContacts.Add(lastContact);
}
lastContact.Timestamp = TimeHelper.Timestamp;
lastContact.GameVersion = gameVersion;
lastContact.Platform = platform;
await database.SaveChangesAsync();
}
}