Simplified bank money transfer

This commit is contained in:
hydrant
2018-11-01 12:41:58 +01:00
parent 13d976258a
commit fec77e5279
12 changed files with 116 additions and 223 deletions

View File

@@ -16,7 +16,7 @@ using System.Text;
namespace reallife_gamemode.Server.Entities
{
public class User
public class User : IBankAccountOwner
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
@@ -28,8 +28,8 @@ namespace reallife_gamemode.Server.Entities
[StringLength(64)]
public string Password { get; set; }
public int LogUserId { get; set; }
[Timestamp]
public byte[] RegistrationDate { get; set; }
[DatabaseGenerated(DatabaseGeneratedOption.Computed)]
public DateTime RegistrationDate { get; set; }
[EmailAddress]
[StringLength(64)]
@@ -131,5 +131,20 @@ namespace reallife_gamemode.Server.Entities
}
public bool IsAdmin(AdminLevel level) => AdminLevel >= level;
public IBankAccount GetBankAccount(DatabaseContext databaseContext = null)
{
if (databaseContext == null)
{
using (databaseContext = new DatabaseContext())
{
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
}
}
else
{
return databaseContext.UserBankAccounts.FirstOrDefault(u => u.UserId == this.Id);
}
}
}
}