diff --git a/Model/DatabaseContext.cs b/Model/DatabaseContext.cs index 828b051e..b9758761 100644 --- a/Model/DatabaseContext.cs +++ b/Model/DatabaseContext.cs @@ -68,6 +68,10 @@ namespace reallife_gamemode.Model public DbSet Vehicles { get; set; } public DbSet ShopVehicles { get; set; } + // Business + public DbSet Businesses { get; set; } + public DbSet BusinessBankAccounts { get; set; } + // Control Panel public DbSet News { get; set; } } diff --git a/Server/Entities/Business.cs b/Server/Entities/Business.cs new file mode 100644 index 00000000..3f4ab18f --- /dev/null +++ b/Server/Entities/Business.cs @@ -0,0 +1,35 @@ +using reallife_gamemode.Model; +using reallife_gamemode.Server.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; + +namespace reallife_gamemode.Server.Entities +{ + public class Business : IBankAccountOwner + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + + public string Name { get; set; } + + public IBankAccount GetBankAccount (DatabaseContext databaseContext = null) + { + if (databaseContext == null) + { + using (databaseContext = new DatabaseContext()) + { + return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == this.Id); + } + } + else + { + return databaseContext.BusinessBankAccounts.FirstOrDefault(u => u.BusinessId == this.Id); + } + } + } +} diff --git a/Server/Entities/BusinessBankAccount.cs b/Server/Entities/BusinessBankAccount.cs new file mode 100644 index 00000000..0139e19f --- /dev/null +++ b/Server/Entities/BusinessBankAccount.cs @@ -0,0 +1,21 @@ +using reallife_gamemode.Server.Util; +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Text; + +namespace reallife_gamemode.Server.Entities +{ + public class BusinessBankAccount : IBankAccount + { + [Key] + [DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int Id { get; set; } + public int Balance { get; set; } + + [ForeignKey("Business")] + public int BusinessId { get; set; } + public Business Business { get; set; } + } +}