added assault troops and removed DB dependence
parent
f27e8d6c80
commit
ff3fdab4e7
|
|
@ -18,6 +18,12 @@
|
||||||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
|
||||||
|
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
|
||||||
|
</ItemGroup>
|
||||||
|
|
||||||
|
<ItemGroup>
|
||||||
|
<Folder Include="Data\" />
|
||||||
|
<Folder Include="Migrations\" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -1,56 +0,0 @@
|
||||||
using BHServer.Data;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
|
||||||
|
|
||||||
namespace BHServer.Controllers
|
|
||||||
{
|
|
||||||
[Route("[controller]")]
|
|
||||||
[ApiController]
|
|
||||||
public class APIController : ControllerBase
|
|
||||||
{
|
|
||||||
private readonly ApplicationDbContext _db;
|
|
||||||
public APIController(ApplicationDbContext db)
|
|
||||||
{
|
|
||||||
_db = db;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: /<APIController>
|
|
||||||
[HttpGet]
|
|
||||||
public IEnumerable<String> Get()
|
|
||||||
{
|
|
||||||
List<String> arr = [];
|
|
||||||
foreach (var entry in _db.Provinces.ToList())
|
|
||||||
{
|
|
||||||
String str = @"{""id"": " + entry.ProvinceId + @", ""name"": """ + entry.Name + @""", ""faction"": " + entry.Faction + @", ""mul"": " + entry.Multiplier + @", ""ats"": " + entry.ATs + @", ""state"": " + entry.State + "}";
|
|
||||||
arr.Add(str);
|
|
||||||
}
|
|
||||||
return arr;
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET /<APIController>/5
|
|
||||||
[HttpGet("{id}")]
|
|
||||||
public string Get(int id)
|
|
||||||
{
|
|
||||||
return "value";
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST /<APIController>
|
|
||||||
[HttpPost]
|
|
||||||
public void Post([FromBody] string value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// PUT /<APIController>/5
|
|
||||||
[HttpPut("{id}")]
|
|
||||||
public void Put(int id, [FromBody] string value)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// DELETE /<APIController>/5
|
|
||||||
[HttpDelete("{id}")]
|
|
||||||
public void Delete(int id)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,60 @@
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
|
||||||
|
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
|
||||||
|
|
||||||
|
namespace BHServer.Controllers
|
||||||
|
{
|
||||||
|
public class AssaultTroopController : ControllerBase
|
||||||
|
{
|
||||||
|
List<string> MockData = [
|
||||||
|
"{\"id\": 1, \"name\": \"First Infantry Division\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 1}",
|
||||||
|
"{\"id\": 2, \"name\": \"First Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||||
|
"{\"id\": 3, \"name\": \"Second Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||||
|
"{\"id\": 4, \"name\": \"Third Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||||
|
"{\"id\": 5, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
|
||||||
|
"{\"id\": 6, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||||
|
"{\"id\": 7, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||||
|
"{\"id\": 8, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||||
|
"{\"id\": 9, \"name\": \"Cheeki Breeki Boys\", \"faction\": 2, \"type\": 1, \"province\": 1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}",
|
||||||
|
"{\"id\": 10, \"name\": \"Hitler\\'s Men\", \"faction\": 2, \"type\": 1, \"province\": 0, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 4}",
|
||||||
|
"{\"id\": 11, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
|
||||||
|
"{\"id\": 12, \"name\": \"Fifth Infantry Division\", \"faction\": 1, \"type\": 1, \"province\": -1, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 5}",
|
||||||
|
"{\"id\": 13, \"name\": \"First Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||||
|
"{\"id\": 14, \"name\": \"Second Armor Division\", \"faction\": 1, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 2}",
|
||||||
|
"{\"id\": 15, \"name\": \"Cheeki Breeki Tonks\", \"faction\": 2, \"type\": 4, \"province\": 2, \"orders\": {\"Dep\": [], \"Mov\": []}, \"owner\": 3}"
|
||||||
|
];
|
||||||
|
|
||||||
|
// GET: /<APIController>
|
||||||
|
[HttpGet]
|
||||||
|
public IEnumerable<string> Get()
|
||||||
|
{
|
||||||
|
return MockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /<APIController>/5
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public string Get(int id)
|
||||||
|
{
|
||||||
|
var entry = MockData.ElementAt(id);
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /<APIController>
|
||||||
|
[HttpPost]
|
||||||
|
public void Post([FromBody] string value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT /<APIController>/5
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public void Put(int id, [FromBody] string value)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /<APIController>/5
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,22 +1,65 @@
|
||||||
using BHServer.Data;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
using BHServer.Models;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace BHServer.Controllers
|
namespace BHServer.Controllers
|
||||||
{
|
{
|
||||||
public class ProvinceController : Controller
|
public class ProvinceController : Controller
|
||||||
{
|
{
|
||||||
private readonly ApplicationDbContext _db;
|
List<string> MockData = [
|
||||||
public ProvinceController(ApplicationDbContext db)
|
"{\"id\": 0, \"name\": \"Hessen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [2, 3, 4], \"Axis\": [1, 5, 9, 10]}, \"state\": 1}",
|
||||||
{
|
"{\"id\": 1, \"name\": \"Thuringen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [6, 7, 8]}, \"state\": 0}",
|
||||||
_db = db;
|
"{\"id\": 2, \"name\": \"Rheinland-Pfalz\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [13, 14], \"Axis\": [15]}, \"state\": 1}",
|
||||||
}
|
"{\"id\": 3, \"name\": \"Saarland\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [16, 17, 18], \"Axis\": []}, \"state\": 0}",
|
||||||
|
"{\"id\": 4, \"name\": \"Baden-Wurttemberg\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [17, 19], \"Axis\": []}, \"state\": 0}",
|
||||||
|
"{\"id\": 5, \"name\": \"Bayern\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [20, 21], \"Axis\": []}, \"state\": 0}",
|
||||||
|
"{\"id\": 6, \"name\": \"Sachsen\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [23], \"Axis\": []}, \"state\": 0}",
|
||||||
|
"{\"id\": 7, \"name\": \"Brandenburg\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [25, 26, 27, 28]}, \"state\": 0}",
|
||||||
|
"{\"id\": 8, \"name\": \"Berlin\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [29, 30, 31]}, \"state\": 0}",
|
||||||
|
"{\"id\": 9, \"name\": \"Schleswig-Holstein\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [33]}, \"state\": 0}",
|
||||||
|
"{\"id\": 10, \"name\": \"Hamburg\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [34]}, \"state\": 0}",
|
||||||
|
"{\"id\": 11, \"name\": \"Niedersachsen\", \"faction\": 2, \"mul\": 1, \"ats\": {\"Allies\": [], \"Axis\": [35]}, \"state\": 0}",
|
||||||
|
"{\"id\": 12, \"name\": \"Nordreihn-Westfalen\", \"faction\": 1, \"mul\": 1, \"ats\": {\"Allies\": [36, 37], \"Axis\": []}, \"state\": 0}"
|
||||||
|
];
|
||||||
|
|
||||||
public IActionResult Index()
|
public IActionResult Index()
|
||||||
{
|
{
|
||||||
List<Province> ObjectProvinceList = _db.Provinces.ToList();
|
return View();
|
||||||
// If the above line faulters then ensure SQL Server is running
|
}
|
||||||
return View(ObjectProvinceList);
|
|
||||||
|
[HttpGet]
|
||||||
|
public IEnumerable<string> Get()
|
||||||
|
{
|
||||||
|
return MockData;
|
||||||
|
}
|
||||||
|
|
||||||
|
// GET /<APIController>/5
|
||||||
|
[HttpGet("{id}")]
|
||||||
|
public string Get(int id)
|
||||||
|
{
|
||||||
|
var entry = MockData.ElementAt(id);
|
||||||
|
return entry;
|
||||||
|
}
|
||||||
|
|
||||||
|
// POST /<APIController>
|
||||||
|
[HttpPost]
|
||||||
|
public void Post([FromBody] string value)
|
||||||
|
{
|
||||||
|
// TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
// PUT /<APIController>/5
|
||||||
|
[HttpPut("{id}")]
|
||||||
|
public void Put(int id, [FromBody] string value)
|
||||||
|
{
|
||||||
|
// TODO: Implement
|
||||||
|
}
|
||||||
|
|
||||||
|
// DELETE /<APIController>/5
|
||||||
|
[HttpDelete("{id}")]
|
||||||
|
public void Delete(int id)
|
||||||
|
{
|
||||||
|
// TODO: Implement
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,18 +0,0 @@
|
||||||
using BHServer.Models;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
|
|
||||||
namespace BHServer.Data
|
|
||||||
{
|
|
||||||
public class ApplicationDbContext : DbContext
|
|
||||||
{
|
|
||||||
public ApplicationDbContext(DbContextOptions<ApplicationDbContext> options) : base(options)
|
|
||||||
// this will pass along the options from the implementation to the definition
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public DbSet<Province> Provinces { get; set; } // specify the table and it's class
|
|
||||||
// to run migrations, run `add-migration <name of the migration>` in the NuGet console
|
|
||||||
// then make the migrations from the console by using `update-database`
|
|
||||||
// to rollback migrations run the command `remove-migration <name>`
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using BHServer.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace BHServer.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20241111135918_AddProvincesToDb")]
|
|
||||||
partial class AddProvincesToDb
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ATs")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Faction")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Multiplier")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Provinces");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,38 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace BHServer.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class AddProvincesToDb : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.CreateTable(
|
|
||||||
name: "Provinces",
|
|
||||||
columns: table => new
|
|
||||||
{
|
|
||||||
Id = table.Column<int>(type: "int", nullable: false)
|
|
||||||
.Annotation("SqlServer:Identity", "1, 1"),
|
|
||||||
Name = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
Faction = table.Column<int>(type: "int", nullable: false),
|
|
||||||
Multiplier = table.Column<int>(type: "int", nullable: false),
|
|
||||||
ATs = table.Column<string>(type: "nvarchar(max)", nullable: false),
|
|
||||||
State = table.Column<int>(type: "int", nullable: false)
|
|
||||||
},
|
|
||||||
constraints: table =>
|
|
||||||
{
|
|
||||||
table.PrimaryKey("PK_Provinces", x => x.Id);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropTable(
|
|
||||||
name: "Provinces");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,62 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using BHServer.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace BHServer.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
[Migration("20241116161946_UpdateProvinceTable")]
|
|
||||||
partial class UpdateProvinceTable
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void BuildTargetModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ATs")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Faction")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Multiplier")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("ProvinceId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Provinces");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,29 +0,0 @@
|
||||||
using Microsoft.EntityFrameworkCore.Migrations;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace BHServer.Migrations
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
public partial class UpdateProvinceTable : Migration
|
|
||||||
{
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.AddColumn<int>(
|
|
||||||
name: "ProvinceId",
|
|
||||||
table: "Provinces",
|
|
||||||
type: "int",
|
|
||||||
nullable: false,
|
|
||||||
defaultValue: 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <inheritdoc />
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
|
||||||
migrationBuilder.DropColumn(
|
|
||||||
name: "ProvinceId",
|
|
||||||
table: "Provinces");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
||||||
// <auto-generated />
|
|
||||||
using BHServer.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
|
||||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
|
||||||
using Microsoft.EntityFrameworkCore.Metadata;
|
|
||||||
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
|
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
namespace BHServer.Migrations
|
|
||||||
{
|
|
||||||
[DbContext(typeof(ApplicationDbContext))]
|
|
||||||
partial class ApplicationDbContextModelSnapshot : ModelSnapshot
|
|
||||||
{
|
|
||||||
protected override void BuildModel(ModelBuilder modelBuilder)
|
|
||||||
{
|
|
||||||
#pragma warning disable 612, 618
|
|
||||||
modelBuilder
|
|
||||||
.HasAnnotation("ProductVersion", "8.0.10")
|
|
||||||
.HasAnnotation("Relational:MaxIdentifierLength", 128);
|
|
||||||
|
|
||||||
SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
|
|
||||||
|
|
||||||
modelBuilder.Entity("BHServer.Models.Province", b =>
|
|
||||||
{
|
|
||||||
b.Property<int>("Id")
|
|
||||||
.ValueGeneratedOnAdd()
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<int>("Id"));
|
|
||||||
|
|
||||||
b.Property<string>("ATs")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("Faction")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("Multiplier")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<string>("Name")
|
|
||||||
.IsRequired()
|
|
||||||
.HasColumnType("nvarchar(max)");
|
|
||||||
|
|
||||||
b.Property<int>("ProvinceId")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.Property<int>("State")
|
|
||||||
.HasColumnType("int");
|
|
||||||
|
|
||||||
b.HasKey("Id");
|
|
||||||
|
|
||||||
b.ToTable("Provinces");
|
|
||||||
});
|
|
||||||
#pragma warning restore 612, 618
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -0,0 +1,23 @@
|
||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
|
||||||
|
namespace BHServer.Models
|
||||||
|
{
|
||||||
|
public class AssaultTroop
|
||||||
|
{
|
||||||
|
[Key]
|
||||||
|
public int Id { get; set; }
|
||||||
|
public int ATId { get; set; }
|
||||||
|
[Required]
|
||||||
|
public string Name { get; set; }
|
||||||
|
[Required]
|
||||||
|
public int Faction { get; set; } // 0 - Neutral, 1 - Allies, 2 - Axis
|
||||||
|
[Required]
|
||||||
|
public int Type { get; set; } // 1 - infantry, 4 - Armor
|
||||||
|
[Required]
|
||||||
|
public int Province { get; set; } // -1 - not deployed, provinces id
|
||||||
|
[Required]
|
||||||
|
public string Orders { get; set; } // Json String
|
||||||
|
[Required]
|
||||||
|
public int Owner { get; set; } // owner id
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,3 @@
|
||||||
using BHServer.Data;
|
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
|
|
@ -6,11 +5,6 @@ var builder = WebApplication.CreateBuilder(args);
|
||||||
// Add services to the container.
|
// Add services to the container.
|
||||||
builder.Services.AddControllersWithViews();
|
builder.Services.AddControllersWithViews();
|
||||||
|
|
||||||
builder.Services.AddDbContext<ApplicationDbContext>(
|
|
||||||
options => options.UseSqlServer(builder.Configuration.GetConnectionString("DefaultConnection"))
|
|
||||||
// `ConnectionString` is defined in the appsettings.json file
|
|
||||||
);
|
|
||||||
|
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
// Configure the HTTP request pipeline.
|
// Configure the HTTP request pipeline.
|
||||||
|
|
|
||||||
|
|
@ -4,79 +4,4 @@
|
||||||
@{
|
@{
|
||||||
}
|
}
|
||||||
|
|
||||||
@model List<Province>
|
|
||||||
|
|
||||||
<h1>Provinces</h1>
|
<h1>Provinces</h1>
|
||||||
<table class="table table-bordered table-striped">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
Id
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Name
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Faction
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
Multiplier
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
ATs
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
State
|
|
||||||
</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
@foreach (var obj in Model) {
|
|
||||||
<tr>
|
|
||||||
<th>
|
|
||||||
@obj.ProvinceId
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
@obj.Name
|
|
||||||
</th>
|
|
||||||
@switch (obj.Faction)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
<th>
|
|
||||||
Neutral
|
|
||||||
</th>
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
<th>
|
|
||||||
Allies
|
|
||||||
</th>
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
<th>
|
|
||||||
Axis
|
|
||||||
</th>
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
<th>
|
|
||||||
@obj.Multiplier
|
|
||||||
</th>
|
|
||||||
<th>
|
|
||||||
@obj.ATs
|
|
||||||
</th>
|
|
||||||
@switch (obj.State)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
<th>
|
|
||||||
At Peace
|
|
||||||
</th>
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
<th>
|
|
||||||
At War
|
|
||||||
</th>
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
</tr>
|
|
||||||
}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
|
|
@ -5,10 +5,6 @@
|
||||||
"Microsoft.AspNetCore": "Warning"
|
"Microsoft.AspNetCore": "Warning"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"AllowedHosts": "*",
|
"AllowedHosts": "*"
|
||||||
"ConnectionStrings": {
|
// This also needs to be changed
|
||||||
"DefaultConnection": "Server=CREATORPC;Database=BHDB;Trusted_Connection=True;TrustServerCertificate=True"
|
|
||||||
// the server name in `Server=` needs to point to an actual live server
|
|
||||||
// We use the command `update-database` in the NuGet Console to create the database
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Reference in New Issue