mirror of
https://github.com/rafi1212122/PemukulPaku
synced 2025-12-12 21:04:43 +01:00
goofy Goodfeel implementation & SetWarshipAvatar
This commit is contained in:
48
Common/Database/Login.cs
Normal file
48
Common/Database/Login.cs
Normal file
@@ -0,0 +1,48 @@
|
||||
using MongoDB.Bson;
|
||||
using MongoDB.Driver;
|
||||
|
||||
namespace Common.Database
|
||||
{
|
||||
public class Login
|
||||
{
|
||||
public static readonly IMongoCollection<LoginScheme> collection = Global.db.GetCollection<LoginScheme>("Logins");
|
||||
|
||||
public static bool UserLogin(uint Uid)
|
||||
{
|
||||
LoginScheme? LastLogin = GetUserLastLogin(Uid);
|
||||
if (LastLogin is not null && LastLogin.Id.CreationTime.Date < DateTime.Now.Date)
|
||||
{
|
||||
collection.InsertOne(new() { OwnerUid = Uid });
|
||||
return true;
|
||||
}
|
||||
collection.InsertOne(new() { OwnerUid = Uid });
|
||||
return false;
|
||||
}
|
||||
|
||||
public static List<LoginScheme> GetUserLogins(uint Uid)
|
||||
{
|
||||
return collection.AsQueryable().Where(login => login.OwnerUid == Uid).ToList();
|
||||
}
|
||||
|
||||
public static LoginScheme? GetUserLastLogin(uint Uid)
|
||||
{
|
||||
return GetUserLogins(Uid).LastOrDefault();
|
||||
}
|
||||
|
||||
public static uint GetUserLoginDays(uint Uid)
|
||||
{
|
||||
return (uint)GetUserLogins(Uid).DistinctBy(login => login.Id.CreationTime.Date).Count();
|
||||
}
|
||||
}
|
||||
|
||||
public class LoginScheme
|
||||
{
|
||||
public ObjectId Id { get; set; }
|
||||
public uint OwnerUid { get; set; }
|
||||
|
||||
public uint GetCreationTime()
|
||||
{
|
||||
return (uint)((DateTimeOffset)Id.CreationTime).ToUnixTimeSeconds();
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user