Bläddra i källkod

add detail controller

USRINGENICO\fmorel 3 år sedan
förälder
incheckning
c3baf627f7

+ 24 - 19
Dotnet/Warhammer/Controllers/HomeController.cs

@@ -1,39 +1,44 @@
 using System.Collections.Generic;
 using System.Diagnostics;
+using System.Threading.Tasks;
 using Microsoft.AspNetCore.Mvc;
 using Microsoft.Extensions.Logging;
 using Warhammer.Models;
+using Warhammer.Service.Interfaces;
 
 namespace Warhammer.Controllers
 {
     public class HomeController : Controller
     {
         private readonly ILogger<HomeController> _logger;
+        private readonly IPlayerService _playerService;
 
-        public HomeController(ILogger<HomeController> logger)
+        public HomeController(ILogger<HomeController> logger, IPlayerService playerService)
         {
             _logger = logger;
+            _playerService = playerService;
         }
 
-        public IActionResult Players()
+        public async Task<IActionResult> PlayersAsync()
         {
-            var players = new List<Player>
-            {
-                new Player
-                {
-                    Experience = 17400,
-                    CC = 52,
-                    CT = 40,
-                    F = 46,
-                    E = 45,
-                    AG = 50,
-                    INT = 34,
-                    PER = 43,
-                    FM = 43,
-                    SOC = 40
-                }
-            };
-            return View("PlayerListView",players);
+            //new List<Player>
+            //{
+            //    new Player
+            //    {
+            //        Experience = 17400,
+            //        CC = 52,
+            //        CT = 40,
+            //        F = 46,
+            //        E = 45,
+            //        AG = 50,
+            //        INT = 34,
+            //        PER = 43,
+            //        FM = 43,
+            //        SOC = 40
+            //    }
+            //};
+            var players = await _playerService.GetAll();
+            return View("PlayerListView", players);
         }
 
         public IActionResult Index()

+ 40 - 0
Dotnet/Warhammer/Controllers/PlayerController.cs

@@ -0,0 +1,40 @@
+using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Warhammer.Models;
+using Warhammer.Service.Interfaces;
+
+
+namespace Warhammer.Controllers
+{
+    [Controller]
+    public class PlayerController : Controller
+    {
+        private Player CurrentPlayer { get; set; }
+        private readonly IPlayerService _playerService;
+
+        public PlayerController(Player currentPlayer, IPlayerService playerService)
+        {
+            CurrentPlayer = new Player();
+            _playerService = playerService;
+        }
+
+        public async Task<IActionResult> GetById(int id)
+        {
+            var player = await _playerService.GetById(id);
+            return View("PlayerDetail", player);
+        }
+
+        [HttpGet("{id}")]
+        public async Task<IActionResult> GetPlayerById(int id)
+        {
+            var player = await _playerService.GetById(id);
+            return View("PlayerDetail", player);
+        }
+
+        public async Task<IActionResult> IndexAsync()
+        {
+            var player = await _playerService.GetById(0);
+            return View("PlayerDetail", player);
+        }
+    }
+}

+ 1 - 1
Dotnet/Warhammer/DataLayer/AbstractRepository.cs

@@ -25,7 +25,7 @@ namespace Warhammer.DataLayer
 
         #region Public Methods
 
-        public async Task<T> GetById(Guid id)
+        public async Task<T> GetById(int id)
         {
             return await DeathwatchDbContext.Set<T>().FindAsync(id);
         }

+ 1 - 1
Dotnet/Warhammer/DataLayer/Interfaces/IAbstractRepository.cs

@@ -8,7 +8,7 @@ namespace Warhammer.DataLayer.Interfaces
 {
     public interface IAbstractRepository<T> where T : BaseEntity
     {
-        Task<T> GetById(Guid id);
+        Task<T> GetById(int id);
         Task<T> FirstOrDefault(Expression<Func<T, bool>> predicate);
 
         Task Add(T entity);

+ 14 - 0
Dotnet/Warhammer/DataLayer/PlayerRepository.cs

@@ -0,0 +1,14 @@
+using Warhammer.DataLayer.Interfaces;
+using Warhammer.Models;
+
+namespace Warhammer.DataLayer
+{
+    public class PlayerRepository : AbstractRepository<Player>, IPlayerRepository
+    {
+        private readonly DeathwatchDbContext _deathwatchDbContext;
+
+        public PlayerRepository(DeathwatchDbContext deathwatchDbContext) : base(deathwatchDbContext)
+        {
+        }
+    }
+}

+ 0 - 84
Dotnet/Warhammer/Migrations/20220920105933_DeathwatchDbFirstMigration.Designer.cs

@@ -1,84 +0,0 @@
-// <auto-generated />
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using Warhammer.DataLayer;
-
-namespace Warhammer.Migrations
-{
-    [DbContext(typeof(DeathwatchDbContext))]
-    [Migration("20220920105933_DeathwatchDbFirstMigration")]
-    partial class DeathwatchDbFirstMigration
-    {
-        protected override void BuildTargetModel(ModelBuilder modelBuilder)
-        {
-#pragma warning disable 612, 618
-            modelBuilder
-                .HasAnnotation("ProductVersion", "3.1.0")
-                .HasAnnotation("Relational:MaxIdentifierLength", 128)
-                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
-
-            modelBuilder.Entity("Warhammer.Models.Player", b =>
-                {
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(450)");
-
-                    b.Property<int>("AG")
-                        .HasColumnType("int");
-
-                    b.Property<string>("Background")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("CC")
-                        .HasColumnType("int");
-
-                    b.Property<int>("CT")
-                        .HasColumnType("int");
-
-                    b.Property<string>("CharacterName")
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<DateTime>("CreatedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<int>("E")
-                        .HasColumnType("int");
-
-                    b.Property<int>("Experience")
-                        .HasColumnType("int");
-
-                    b.Property<int>("F")
-                        .HasColumnType("int");
-
-                    b.Property<int>("FM")
-                        .HasColumnType("int");
-
-                    b.Property<int>("INT")
-                        .HasColumnType("int");
-
-                    b.Property<Guid>("Id")
-                        .HasColumnType("uniqueidentifier");
-
-                    b.Property<int>("MF")
-                        .HasColumnType("int");
-
-                    b.Property<DateTime>("ModifiedDate")
-                        .HasColumnType("datetime2");
-
-                    b.Property<int>("PER")
-                        .HasColumnType("int");
-
-                    b.Property<int>("SOC")
-                        .HasColumnType("int");
-
-                    b.HasKey("Name");
-
-                    b.ToTable("Players");
-                });
-#pragma warning restore 612, 618
-        }
-    }
-}

+ 0 - 44
Dotnet/Warhammer/Migrations/20220920105933_DeathwatchDbFirstMigration.cs

@@ -1,44 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-namespace Warhammer.Migrations
-{
-    public partial class DeathwatchDbFirstMigration : Migration
-    {
-        protected override void Up(MigrationBuilder migrationBuilder)
-        {
-            migrationBuilder.CreateTable(
-                name: "Players",
-                columns: table => new
-                {
-                    Name = table.Column<string>(nullable: false),
-                    Id = table.Column<Guid>(nullable: false),
-                    CreatedDate = table.Column<DateTime>(nullable: false),
-                    ModifiedDate = table.Column<DateTime>(nullable: false),
-                    CharacterName = table.Column<string>(nullable: true),
-                    Background = table.Column<string>(nullable: true),
-                    Experience = table.Column<int>(nullable: false),
-                    CC = table.Column<int>(nullable: false),
-                    CT = table.Column<int>(nullable: false),
-                    F = table.Column<int>(nullable: false),
-                    E = table.Column<int>(nullable: false),
-                    AG = table.Column<int>(nullable: false),
-                    INT = table.Column<int>(nullable: false),
-                    PER = table.Column<int>(nullable: false),
-                    FM = table.Column<int>(nullable: false),
-                    SOC = table.Column<int>(nullable: false),
-                    MF = table.Column<int>(nullable: false)
-                },
-                constraints: table =>
-                {
-                    table.PrimaryKey("PK_Players", x => x.Name);
-                });
-        }
-
-        protected override void Down(MigrationBuilder migrationBuilder)
-        {
-            migrationBuilder.DropTable(
-                name: "Players");
-        }
-    }
-}

+ 155 - 0
Dotnet/Warhammer/Migrations/20220922082312_newMigration.Designer.cs

@@ -0,0 +1,155 @@
+// <auto-generated />
+using System;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.Infrastructure;
+using Microsoft.EntityFrameworkCore.Metadata;
+using Microsoft.EntityFrameworkCore.Migrations;
+using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
+using Warhammer.DataLayer;
+
+namespace Warhammer.Migrations
+{
+    [DbContext(typeof(DeathwatchDbContext))]
+    [Migration("20220922082312_newMigration")]
+    partial class newMigration
+    {
+        protected override void BuildTargetModel(ModelBuilder modelBuilder)
+        {
+#pragma warning disable 612, 618
+            modelBuilder
+                .HasAnnotation("ProductVersion", "3.1.0")
+                .HasAnnotation("Relational:MaxIdentifierLength", 128)
+                .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+            modelBuilder.Entity("Warhammer.Models.Player", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("int")
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+                    b.Property<int>("AG")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Background")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("CC")
+                        .HasColumnType("int");
+
+                    b.Property<int>("CT")
+                        .HasColumnType("int");
+
+                    b.Property<string>("CharacterName")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreatedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<int>("E")
+                        .HasColumnType("int");
+
+                    b.Property<int>("Experience")
+                        .HasColumnType("int");
+
+                    b.Property<int>("F")
+                        .HasColumnType("int");
+
+                    b.Property<int>("FM")
+                        .HasColumnType("int");
+
+                    b.Property<int>("INT")
+                        .HasColumnType("int");
+
+                    b.Property<int>("MF")
+                        .HasColumnType("int");
+
+                    b.Property<DateTime>("ModifiedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("PER")
+                        .HasColumnType("int");
+
+                    b.Property<int>("SOC")
+                        .HasColumnType("int");
+
+                    b.Property<int?>("WeaponId")
+                        .HasColumnType("int");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("WeaponId");
+
+                    b.ToTable("Players");
+                });
+
+            modelBuilder.Entity("Warhammer.Models.Weapons.Weapon", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("int")
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+                    b.Property<string>("At")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Attribute")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreatedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("GPE")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Mode")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("ModifiedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Pene")
+                        .HasColumnType("int");
+
+                    b.Property<int?>("PlayerId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("Range")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Rch")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Type")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("PlayerId");
+
+                    b.ToTable("Weapon");
+                });
+
+            modelBuilder.Entity("Warhammer.Models.Player", b =>
+                {
+                    b.HasOne("Warhammer.Models.Weapons.Weapon", null)
+                        .WithMany("Players")
+                        .HasForeignKey("WeaponId");
+                });
+
+            modelBuilder.Entity("Warhammer.Models.Weapons.Weapon", b =>
+                {
+                    b.HasOne("Warhammer.Models.Player", null)
+                        .WithMany("Weapons")
+                        .HasForeignKey("PlayerId");
+                });
+#pragma warning restore 612, 618
+        }
+    }
+}

+ 102 - 0
Dotnet/Warhammer/Migrations/20220922082312_newMigration.cs

@@ -0,0 +1,102 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+namespace Warhammer.Migrations
+{
+    public partial class newMigration : Migration
+    {
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+
+            migrationBuilder.CreateTable(
+                name: "Weapon",
+                columns: table => new
+                {
+                    Id = table.Column<int>(nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreatedDate = table.Column<DateTime>(nullable: false),
+                    ModifiedDate = table.Column<DateTime>(nullable: false),
+                    Range = table.Column<int>(nullable: false),
+                    Name = table.Column<string>(nullable: true),
+                    GPE = table.Column<string>(nullable: true),
+                    Type = table.Column<string>(nullable: true),
+                    Pene = table.Column<int>(nullable: false),
+                    Mode = table.Column<string>(nullable: true),
+                    At = table.Column<string>(nullable: true),
+                    Rch = table.Column<string>(nullable: true),
+                    Attribute = table.Column<string>(nullable: true),
+                    PlayerId = table.Column<int>(nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Weapon", x => x.Id);
+                });
+
+            migrationBuilder.CreateTable(
+                name: "Players",
+                columns: table => new
+                {
+                    Id = table.Column<int>(nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreatedDate = table.Column<DateTime>(nullable: false),
+                    ModifiedDate = table.Column<DateTime>(nullable: false),
+                    Name = table.Column<string>(nullable: true),
+                    CharacterName = table.Column<string>(nullable: true),
+                    Background = table.Column<string>(nullable: true),
+                    Experience = table.Column<int>(nullable: false),
+                    CC = table.Column<int>(nullable: false),
+                    CT = table.Column<int>(nullable: false),
+                    F = table.Column<int>(nullable: false),
+                    E = table.Column<int>(nullable: false),
+                    AG = table.Column<int>(nullable: false),
+                    INT = table.Column<int>(nullable: false),
+                    PER = table.Column<int>(nullable: false),
+                    FM = table.Column<int>(nullable: false),
+                    SOC = table.Column<int>(nullable: false),
+                    MF = table.Column<int>(nullable: false),
+                    WeaponId = table.Column<int>(nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Players", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_Players_Weapon_WeaponId",
+                        column: x => x.WeaponId,
+                        principalTable: "Weapon",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Restrict);
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Players_WeaponId",
+                table: "Players",
+                column: "WeaponId");
+
+            migrationBuilder.CreateIndex(
+                name: "IX_Weapon_PlayerId",
+                table: "Weapon",
+                column: "PlayerId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_Weapon_Players_PlayerId",
+                table: "Weapon",
+                column: "PlayerId",
+                principalTable: "Players",
+                principalColumn: "Id",
+                onDelete: ReferentialAction.Restrict);
+        }
+
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_Players_Weapon_WeaponId",
+                table: "Players");
+
+            migrationBuilder.DropTable(
+                name: "Weapon");
+
+            migrationBuilder.DropTable(
+                name: "Players");
+        }
+    }
+}

+ 77 - 6
Dotnet/Warhammer/Migrations/DeathwatchDbContextModelSnapshot.cs

@@ -21,8 +21,10 @@ namespace Warhammer.Migrations
 
             modelBuilder.Entity("Warhammer.Models.Player", b =>
                 {
-                    b.Property<string>("Name")
-                        .HasColumnType("nvarchar(450)");
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("int")
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
 
                     b.Property<int>("AG")
                         .HasColumnType("int");
@@ -57,25 +59,94 @@ namespace Warhammer.Migrations
                     b.Property<int>("INT")
                         .HasColumnType("int");
 
-                    b.Property<Guid>("Id")
-                        .HasColumnType("uniqueidentifier");
-
                     b.Property<int>("MF")
                         .HasColumnType("int");
 
                     b.Property<DateTime>("ModifiedDate")
                         .HasColumnType("datetime2");
 
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
                     b.Property<int>("PER")
                         .HasColumnType("int");
 
                     b.Property<int>("SOC")
                         .HasColumnType("int");
 
-                    b.HasKey("Name");
+                    b.Property<int?>("WeaponId")
+                        .HasColumnType("int");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("WeaponId");
 
                     b.ToTable("Players");
                 });
+
+            modelBuilder.Entity("Warhammer.Models.Weapons.Weapon", b =>
+                {
+                    b.Property<int>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("int")
+                        .HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
+
+                    b.Property<string>("At")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Attribute")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("CreatedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("GPE")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Mode")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<DateTime>("ModifiedDate")
+                        .HasColumnType("datetime2");
+
+                    b.Property<string>("Name")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<int>("Pene")
+                        .HasColumnType("int");
+
+                    b.Property<int?>("PlayerId")
+                        .HasColumnType("int");
+
+                    b.Property<int>("Range")
+                        .HasColumnType("int");
+
+                    b.Property<string>("Rch")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.Property<string>("Type")
+                        .HasColumnType("nvarchar(max)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("PlayerId");
+
+                    b.ToTable("Weapon");
+                });
+
+            modelBuilder.Entity("Warhammer.Models.Player", b =>
+                {
+                    b.HasOne("Warhammer.Models.Weapons.Weapon", null)
+                        .WithMany("Players")
+                        .HasForeignKey("WeaponId");
+                });
+
+            modelBuilder.Entity("Warhammer.Models.Weapons.Weapon", b =>
+                {
+                    b.HasOne("Warhammer.Models.Player", null)
+                        .WithMany("Weapons")
+                        .HasForeignKey("PlayerId");
+                });
 #pragma warning restore 612, 618
         }
     }

+ 1 - 1
Dotnet/Warhammer/Models/BaseEntity.cs

@@ -6,7 +6,7 @@ namespace Warhammer.Models
     public class BaseEntity
     {
         [Key]
-        public Guid Id { get; set; }
+        public int Id { get; set; }
         public DateTime CreatedDate { get; set; }
         public DateTime ModifiedDate { get; set; }
 

+ 11 - 3
Dotnet/Warhammer/Models/Weapons/Weapon.cs

@@ -1,9 +1,10 @@
 using System.Collections.Generic;
 using Microsoft.EntityFrameworkCore.Storage.ValueConversion.Internal;
+using Warhammer.Service;
 
 namespace Warhammer.Models.Weapons
 {
-    public abstract class Weapon : BaseEntity
+    public class Weapon : BaseEntity
     {
         public int Damage;
         public int Range { get; set; }
@@ -18,9 +19,16 @@ namespace Warhammer.Models.Weapons
 
         public ICollection<Player> Players { get; set; }
 
-        public abstract int Attack(int bonusStat, int stat, string amo = null, bool? isHorde = null);
+        public virtual int Attack(int bonusStat, int stat, string amo = null, bool? isHorde = null)
+        {
+            var ctDice = DiceService.RollDices(1, 100);
+            return ctDice;
+        }
 
-        public abstract int DamageAmount(int successDegree);
+        public virtual int DamageAmount(int successDegree)
+        {
+            return 0;
+        }
 
     }
 }

+ 1 - 1
Dotnet/Warhammer/Properties/PublishProfiles/DeathwatchWebApp - Web Deploy.pubxml.user

@@ -7,6 +7,6 @@ by editing this MSBuild file. In order to learn more about this please visit htt
   <PropertyGroup>
     <TimeStampOfAssociatedLegacyPublishXmlFile />
     <EncryptedPassword>AQAAANCMnd8BFdERjHoAwE/Cl+sBAAAA3aukXzos7UmpDo1WnIZ1xAAAAAACAAAAAAADZgAAwAAAABAAAACnCoiGSbWN4HGb1PUIKKGPAAAAAASAAACgAAAAEAAAAIG73dxboIaK3CVSNKerN42AAAAA3LbNVHirj20WPofbvToIRGwRPHoijX74t4vOUZxDXEInDt0xUdMB4oZkV07T7GlntblCn4XNlSTnq0lRwIY13PwmpkiX9utIpM6ji386dxAgk8h5KztgX9hTEBdFjHFaBmTbm8zzSNMN16F83b57ZacyTfgqYQ+dLyMbZ4spf9EUAAAAgvEaFmvL4fAV0i0g/9K19hrwZ8A=</EncryptedPassword>
-    <History>True|2022-09-21T19:17:52.2079741Z;</History>
+    <History>True|2022-09-21T20:06:23.4478529Z;True|2022-09-21T21:17:52.2079741+02:00;</History>
   </PropertyGroup>
 </Project>

+ 1 - 1
Dotnet/Warhammer/Service/Interfaces/IPlayerService.cs

@@ -8,7 +8,7 @@ namespace Warhammer.Service.Interfaces
 {
     public interface IPlayerService
     {
-        Task<Player> GetById(Guid id);
+        Task<Player> GetById(int id);
         Task<Player> FirstOrDefault(Expression<Func<Player, bool>> predicate);
 
         Task Add(Player entity);

+ 5 - 4
Dotnet/Warhammer/Service/PlayerService.cs

@@ -37,14 +37,15 @@ namespace Warhammer.Service
             throw new NotImplementedException();
         }
 
-        public Task<IEnumerable<Player>> GetAll()
+        public async Task<IEnumerable<Player>> GetAll()
         {
-            throw new NotImplementedException();
+            return await _playerRepository.GetAll();
+
         }
 
-        public Task<Player> GetById(Guid id)
+        public async Task<Player> GetById(int id)
         {
-            throw new NotImplementedException();
+            return await _playerRepository.GetById(id);
         }
 
         public Task<IEnumerable<Player>> GetWhere(Expression<Func<Player, bool>> predicate)

+ 25 - 3
Dotnet/Warhammer/Startup.cs

@@ -5,6 +5,9 @@ using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Warhammer.DataLayer;
+using Warhammer.DataLayer.Interfaces;
+using Warhammer.Service;
+using Warhammer.Service.Interfaces;
 
 namespace Warhammer
 {
@@ -20,10 +23,26 @@ namespace Warhammer
         // This method gets called by the runtime. Use this method to add services to the container.
         public void ConfigureServices(IServiceCollection services)
         {
+            services.AddCors(o => o.AddPolicy("MyPolicy", builder =>
+            {
+                builder.AllowAnyOrigin()
+                    .AllowAnyMethod()
+                    .AllowAnyHeader();
+            }));
+
             services.AddControllersWithViews();
+            services.AddMvc();
+            services.AddHttpClient();
+            services.AddRazorPages();
 
             services.AddDbContext<DeathwatchDbContext>(options =>
                 options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
+
+            services.AddTransient(typeof(IAbstractRepository<>), typeof(AbstractRepository<>));
+            services.AddTransient<IPlayerRepository, PlayerRepository>();
+
+            services.AddTransient<IPlayerService, PlayerService>();
+
         }
 
         // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
@@ -35,9 +54,8 @@ namespace Warhammer
             //}
             //else
             //{
-                app.UseExceptionHandler("/Home/Error");
-                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
-                app.UseHsts();
+            //app.UseExceptionHandler("/Home/Error");
+            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
             //}
 
             app.UseHttpsRedirection();
@@ -52,7 +70,11 @@ namespace Warhammer
                 endpoints.MapControllerRoute(
                     "default",
                     "{controller=Home}/{action=Index}/{id?}");
+                endpoints.MapRazorPages();
             });
+
+            app.UseHsts();
+
         }
     }
 }

+ 0 - 96
Dotnet/Warhammer/Views/Home/PlayerListView.cshtml

@@ -1,96 +0,0 @@
-@model IEnumerable<Player>
-
-@{
-    ViewData["Title"] = "View";
-}
-
-<h1>View</h1>
-
-@*<p>
-    <a asp-action="Create">Create New</a>
-</p>*@
-<table class="table">
-    <thead>
-    <tr>
-        <th>
-            @Html.DisplayNameFor(model => model.Experience)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.CC)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.CT)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.F)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.E)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.AG)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.INT)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.PER)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.FM)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.SOC)
-        </th>
-        <th>
-            @Html.DisplayNameFor(model => model.MF)
-        </th>
-        <th></th>
-    </tr>
-    </thead>
-    <tbody>
-    @foreach (var item in Model)
-    {
-        <tr>
-            <td>
-                @Html.DisplayFor(modelItem => item.Experience)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.CC)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.CT)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.F)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.E)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.AG)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.INT)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.PER)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.FM)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.SOC)
-            </td>
-            <td>
-                @Html.DisplayFor(modelItem => item.MF)
-            </td>
-            @*<td>
-                @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
-                @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
-                @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
-            </td>*@
-        </tr>
-    }
-    </tbody>
-</table>

+ 110 - 0
Dotnet/Warhammer/Views/Shared/PlayerDetail.cshtml

@@ -0,0 +1,110 @@
+@model Warhammer.Models.Player
+@{
+    ViewData["Title"] = "View";
+}
+<div>
+    <h4>Player</h4>
+    <hr />
+    <dl class="row">
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.Name)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.Name)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.CharacterName)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.CharacterName)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.Background)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.Background)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.Experience)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.Experience)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.CC)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.CC)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.CT)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.CT)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.F)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.F)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.E)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.E)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.AG)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.AG)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.INT)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.INT)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.PER)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.PER)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.FM)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.FM)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.SOC)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.SOC)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.MF)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.MF)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.CreatedDate)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.CreatedDate)
+        </dd>
+        <dt class = "col-sm-2">
+            @Html.DisplayNameFor(model => model.ModifiedDate)
+        </dt>
+        <dd class = "col-sm-10">
+            @Html.DisplayFor(model => model.ModifiedDate)
+        </dd>
+    </dl>
+</div>
+<div>
+    @*<a asp-action="Edit" asp-route-id="@Model.Id">Edit</a> |*@
+    <a asp-action="Index">Back to List</a>
+</div>

+ 105 - 0
Dotnet/Warhammer/Views/Shared/PlayerListView.cshtml

@@ -0,0 +1,105 @@
+@model IEnumerable<Player>
+
+@{
+    ViewData["Title"] = "View";
+}
+
+<h1>View</h1>
+
+@*<p>
+    <a asp-action="Create">Create New</a>
+    </p>*@
+<table class="table">
+    <thead>
+        <tr>
+            <th>
+                @Html.DisplayNameFor(model => model.Id)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.Experience)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.CC)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.CT)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.F)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.E)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.AG)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.INT)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.PER)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.FM)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.SOC)
+            </th>
+            <th>
+                @Html.DisplayNameFor(model => model.MF)
+            </th>
+            <th></th>
+        </tr>
+    </thead>
+    <tbody>
+        @foreach (var item in Model)
+        {
+            <tr>
+
+                <td>
+                    <a asp-action="GetPlayerById" asp-controller="Player" asp-route-id="Players/@item.Id">
+                        @Html.DisplayFor(modelItem => item.Id)
+                    </a>
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.Experience)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.CC)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.CT)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.F)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.E)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.AG)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.INT)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.PER)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.FM)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.SOC)
+                </td>
+                <td>
+                    @Html.DisplayFor(modelItem => item.MF)
+                </td>
+                @*<td>
+                    @Html.ActionLink("Edit", "Edit", new { /* id=item.PrimaryKey */ }) |
+                    @Html.ActionLink("Details", "Details", new { /* id=item.PrimaryKey */ }) |
+                    @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
+                    </td>*@
+            </tr>
+        }
+    </tbody>
+</table>

+ 5 - 0
Dotnet/Warhammer/Warhammer.csproj

@@ -6,6 +6,11 @@
     <StartupObject>Warhammer.Program</StartupObject>
   </PropertyGroup>
 
+  <ItemGroup>
+    <Compile Remove="Migrations\20220922081842_newMigration.cs" />
+    <Compile Remove="Migrations\20220922081842_newMigration.Designer.cs" />
+  </ItemGroup>
+
   <ItemGroup>
     <PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.1.0" />
     <PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.0" />

+ 4 - 3
Dotnet/Warhammer/Warhammer.csproj.user

@@ -3,16 +3,17 @@
   <PropertyGroup>
     <View_SelectedScaffolderID>RazorViewScaffolder</View_SelectedScaffolderID>
     <View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
-    <WebStackScaffolding_ViewDialogWidth>650.4</WebStackScaffolding_ViewDialogWidth>
+    <WebStackScaffolding_ViewDialogWidth>650</WebStackScaffolding_ViewDialogWidth>
     <WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
-    <WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
+    <WebStackScaffolding_IsPartialViewSelected>True</WebStackScaffolding_IsPartialViewSelected>
     <WebStackScaffolding_IsReferencingScriptLibrariesSelected>True</WebStackScaffolding_IsReferencingScriptLibrariesSelected>
     <WebStackScaffolding_LayoutPageFile />
-    <Controller_SelectedScaffolderID>MvcControllerWithContextScaffolder</Controller_SelectedScaffolderID>
+    <Controller_SelectedScaffolderID>MvcControllerEmptyScaffolder</Controller_SelectedScaffolderID>
     <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
     <WebStackScaffolding_ControllerDialogWidth>650</WebStackScaffolding_ControllerDialogWidth>
     <ActiveDebugProfile>IIS Express</ActiveDebugProfile>
     <NameOfLastUsedPublishProfile>C:\Repositories\Warhammer\Deathwatch\Dotnet\Warhammer\Properties\PublishProfiles\DeathwatchWebApp - Web Deploy.pubxml</NameOfLastUsedPublishProfile>
+    <WebStackScaffolding_DbContextTypeFullName>Warhammer.DataLayer.DeathwatchDbContext</WebStackScaffolding_DbContextTypeFullName>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>