Added business database entity (+ bank account)
This commit is contained in:
@@ -68,6 +68,10 @@ namespace reallife_gamemode.Model
|
|||||||
public DbSet<Server.Saves.SavedVehicle> Vehicles { get; set; }
|
public DbSet<Server.Saves.SavedVehicle> Vehicles { get; set; }
|
||||||
public DbSet<Server.Entities.ShopVehicle> ShopVehicles { get; set; }
|
public DbSet<Server.Entities.ShopVehicle> ShopVehicles { get; set; }
|
||||||
|
|
||||||
|
// Business
|
||||||
|
public DbSet<Server.Entities.Business> Businesses { get; set; }
|
||||||
|
public DbSet<Server.Entities.BusinessBankAccount> BusinessBankAccounts { get; set; }
|
||||||
|
|
||||||
// Control Panel
|
// Control Panel
|
||||||
public DbSet<Server.Entities.News> News { get; set; }
|
public DbSet<Server.Entities.News> News { get; set; }
|
||||||
}
|
}
|
||||||
|
|||||||
35
Server/Entities/Business.cs
Normal file
35
Server/Entities/Business.cs
Normal file
@@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
21
Server/Entities/BusinessBankAccount.cs
Normal file
21
Server/Entities/BusinessBankAccount.cs
Normal file
@@ -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; }
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user