Pārlūkot izejas kodu

cleanup and resolve conflicts

USRINGENICO\fmorel 3 gadi atpakaļ
vecāks
revīzija
da42dc11c4

+ 13 - 16
Dotnet/Warhammer/Controllers/HomeController.cs

@@ -1,10 +1,7 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
+using System.Collections.Generic;
 using System.Diagnostics;
-using System.Linq;
-using System.Threading.Tasks;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
 using Warhammer.Models;
 
 namespace Warhammer.Controllers
@@ -25,15 +22,15 @@ namespace Warhammer.Controllers
                 new Player
                 {
                     Experience = 17400,
-                    CC = 52           ,
-                    CT = 40           ,
-                    F = 46            ,
-                    E = 45            ,
-                    AG = 50           ,
-                    INT = 34          ,
-                    PER = 43          ,
-                    FM = 43           ,
-                    SOC = 40          ,
+                    CC = 52,
+                    CT = 40,
+                    F = 46,
+                    E = 45,
+                    AG = 50,
+                    INT = 34,
+                    PER = 43,
+                    FM = 43,
+                    SOC = 40
                 }
             };
             return View(players);
@@ -55,4 +52,4 @@ namespace Warhammer.Controllers
             return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
         }
     }
-}
+}

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

@@ -1,87 +0,0 @@
-using Microsoft.AspNetCore.Http;
-using Microsoft.AspNetCore.Mvc;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-
-namespace Warhammer.Controllers
-{
-    public class PlayerController : Controller
-    {
-        // GET: Player
-        public ActionResult Index()
-        {
-            return View();
-        }
-
-        // GET: Player/Details/5
-        public ActionResult Details(int id)
-        {
-            return View();
-        }
-
-        // GET: Player/Create
-        public ActionResult Create()
-        {
-            return View();
-        }
-
-        // POST: Player/Create
-        [HttpPost]
-        [ValidateAntiForgeryToken]
-        public ActionResult Create(IFormCollection collection)
-        {
-            try
-            {
-                return RedirectToAction(nameof(Index));
-            }
-            catch
-            {
-                return View();
-            }
-        }
-
-        // GET: Player/Edit/5
-        public ActionResult Edit(int id)
-        {
-            return View();
-        }
-
-        // POST: Player/Edit/5
-        [HttpPost]
-        [ValidateAntiForgeryToken]
-        public ActionResult Edit(int id, IFormCollection collection)
-        {
-            try
-            {
-                return RedirectToAction(nameof(Index));
-            }
-            catch
-            {
-                return View();
-            }
-        }
-
-        // GET: Player/Delete/5
-        public ActionResult Delete(int id)
-        {
-            return View();
-        }
-
-        // POST: Player/Delete/5
-        [HttpPost]
-        [ValidateAntiForgeryToken]
-        public ActionResult Delete(int id, IFormCollection collection)
-        {
-            try
-            {
-                return RedirectToAction(nameof(Index));
-            }
-            catch
-            {
-                return View();
-            }
-        }
-    }
-}

+ 0 - 9
Dotnet/Warhammer/DAL/Database/DeathwatchDbContext.cs

@@ -1,9 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-
-namespace Warhammer.DAL.Database
-{
-    public class DeathwatchDbContext : DbContext
-    {
-
-    }
-}

+ 15 - 26
Dotnet/Warhammer/DataLayer/DbContextInitializer.cs

@@ -1,7 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
+using System.Linq;
 using Warhammer.Models;
 
 namespace Warhammer.DataLayer
@@ -13,34 +10,26 @@ namespace Warhammer.DataLayer
             context.Database.EnsureCreated();
 
             // Look for any students.
-            if (context.Players.Any())
-            {
-                return;   // DB has been seeded
-            }
+            if (context.Players.Any()) return; // DB has been seeded
 
-            var players = new Player[]
+            var players = new[]
             {
                 new Player
                 {
-                      Experience = 17400,
-                      CC = 52,
-                      CT = 40,
-                      F = 46,
-                      E = 45,
-                      AG = 50,
-                      INT = 34,
-                      PER = 43,
-                      FM = 43,
-                      SOC = 40          
+                    Experience = 17400,
+                    CC = 52,
+                    CT = 40,
+                    F = 46,
+                    E = 45,
+                    AG = 50,
+                    INT = 34,
+                    PER = 43,
+                    FM = 43,
+                    SOC = 40
                 }
             };
-            foreach (Player player in players)
-            {
-                context.Players.Add(player);
-            }
+            foreach (var player in players) context.Players.Add(player);
             context.SaveChanges();
-
         }
     }
-}
-
+}

+ 3 - 7
Dotnet/Warhammer/DataLayer/DeathwatchDbContext.cs

@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore;
 using Warhammer.Models;
 
 namespace Warhammer.DataLayer
@@ -17,7 +13,7 @@ namespace Warhammer.DataLayer
 
         protected override void OnModelCreating(ModelBuilder modelBuilder)
         {
-            modelBuilder.Entity<Player>().ToTable("Players").HasKey(p => p.Id);
+            modelBuilder.Entity<Player>().ToTable("Players").HasKey(p => p.Name);
         }
     }
-}
+}

+ 22 - 42
Dotnet/Warhammer/Models/Enum/Enum.cs

@@ -4,56 +4,36 @@ namespace Warhammer.Models.Enum
 {
     public enum WeaponClass
     {
-        [Description("Pistol")]
-        PISTOL,
-        [Description("Basic")]
-        BASIC,
-        [Description("Heavy")]
-        HEAVY,
-        [Description("Thrown")]
-        THROWN,
-        [Description("Melee")]
-        MELEE
+        [Description("Pistol")] PISTOL,
+        [Description("Basic")] BASIC,
+        [Description("Heavy")] HEAVY,
+        [Description("Thrown")] THROWN,
+        [Description("Melee")] MELEE
     }
 
     public enum ItemAvailibility
     {
-        [Description("Automatic")]
-        UBIQUITOUS = 100,
-        [Description("Easy")]
-        ABUNDANT = 30,
-        [Description("Routine")]
-        PLENTIFUL = 20,
-        [Description("Ordinary")]
-        COMMON = 10,
-        [Description("Challenging")]
-        AVERAGE = 0,
-        [Description("Difficult")]
-        SCARCE = -10,
-        [Description("Hard")]
-        RARE = -20,
-        [Description("Very Hard")]
-        VERY_RARE = -30,
-        [Description("Arduous ")]
-        EXTREMELY_RARE = -40,
-        [Description("Punishing ")]
-        NEAR_UNIQUE = -50,
-        [Description("Hellish")]
-        UNIQUE = -60
+        [Description("Automatic")] UBIQUITOUS = 100,
+        [Description("Easy")] ABUNDANT = 30,
+        [Description("Routine")] PLENTIFUL = 20,
+        [Description("Ordinary")] COMMON = 10,
+        [Description("Challenging")] AVERAGE = 0,
+        [Description("Difficult")] SCARCE = -10,
+        [Description("Hard")] RARE = -20,
+        [Description("Very Hard")] VERY_RARE = -30,
+        [Description("Arduous ")] EXTREMELY_RARE = -40,
+        [Description("Punishing ")] NEAR_UNIQUE = -50,
+        [Description("Hellish")] UNIQUE = -60
     }
 
     public enum OrganisationLevel
     {
-        [Description("Local Influence")]
-        LOCAL,
-        [Description("Regional Influence")]
-        REGIONAL,
-        [Description("National Influence")]
-        NATIONAL,
-        [Description("All the Planet")]
-        PLANETARY,
+        [Description("Local Influence")] LOCAL,
+        [Description("Regional Influence")] REGIONAL,
+        [Description("National Influence")] NATIONAL,
+        [Description("All the Planet")] PLANETARY,
+
         [Description("All the galaxy & beyond")]
         INTERGALACTICAL
     }
-
-}
+}

+ 1 - 3
Dotnet/Warhammer/Models/ErrorViewModel.cs

@@ -1,5 +1,3 @@
-using System;
-
 namespace Warhammer.Models
 {
     public class ErrorViewModel
@@ -8,4 +6,4 @@ namespace Warhammer.Models
 
         public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
     }
-}
+}

+ 4 - 4
Dotnet/Warhammer/Models/Player.cs

@@ -2,10 +2,10 @@
 
 namespace Warhammer.Models
 {
-    public partial class Player
+    public class Player
     {
-        [Key]
-        public string Name { get; set; }
+        [Key] public string Name { get; set; }
+
         public int Experience { get; set; }
         public int CC { get; set; }
         public int CT { get; set; }
@@ -18,4 +18,4 @@ namespace Warhammer.Models
         public int SOC { get; set; }
         public int MF { get; set; }
     }
-}
+}

+ 3 - 4
Dotnet/Warhammer/Models/Weapon.cs

@@ -4,10 +4,9 @@ namespace Warhammer.Models
 {
     public class Weapon
     {
-        [Key]
-        public int id { get; set; }
+        [Key] public int id { get; set; }
+
         public int Range { get; set; }
         public string Name { get; set; }
-        
     }
-}
+}

+ 8 - 13
Dotnet/Warhammer/Program.cs

@@ -1,12 +1,8 @@
+using System;
 using Microsoft.AspNetCore.Hosting;
-using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
 using Microsoft.Extensions.Logging;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
-using Microsoft.Extensions.DependencyInjection;
 using Warhammer.DataLayer;
 
 namespace Warhammer
@@ -23,12 +19,11 @@ namespace Warhammer
             host.Run();
         }
 
-        public static IHostBuilder CreateHostBuilder(string[] args) =>
-            Host.CreateDefaultBuilder(args)
-                .ConfigureWebHostDefaults(webBuilder =>
-                {
-                    webBuilder.UseStartup<Startup>();
-                });
+        public static IHostBuilder CreateHostBuilder(string[] args)
+        {
+            return Host.CreateDefaultBuilder(args)
+                .ConfigureWebHostDefaults(webBuilder => { webBuilder.UseStartup<Startup>(); });
+        }
 
         private static void CreateDbIfNotExists(IHost host)
         {
@@ -48,4 +43,4 @@ namespace Warhammer
             }
         }
     }
-}
+}

+ 1 - 1
Dotnet/Warhammer/Properties/launchSettings.json

@@ -26,4 +26,4 @@
       }
     }
   }
-}
+}

+ 4 - 8
Dotnet/Warhammer/Startup.cs

@@ -1,14 +1,9 @@
 using Microsoft.AspNetCore.Builder;
 using Microsoft.AspNetCore.Hosting;
-using Microsoft.AspNetCore.HttpsPolicy;
 using Microsoft.EntityFrameworkCore;
 using Microsoft.Extensions.Configuration;
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.Hosting;
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Threading.Tasks;
 using Warhammer.DataLayer;
 
 namespace Warhammer
@@ -44,6 +39,7 @@ namespace Warhammer
                 // 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.UseHttpsRedirection();
             app.UseStaticFiles();
 
@@ -54,9 +50,9 @@ namespace Warhammer
             app.UseEndpoints(endpoints =>
             {
                 endpoints.MapControllerRoute(
-                    name: "default",
-                    pattern: "{controller=Home}/{action=Index}/{id?}");
+                    "default",
+                    "{controller=Home}/{action=Index}/{id?}");
             });
         }
     }
-}
+}

+ 1 - 1
Dotnet/Warhammer/Views/Home/Index.cshtml

@@ -5,4 +5,4 @@
 <div class="text-center">
     <h1 class="display-4">Welcome</h1>
     <p>Learn about <a href="https://docs.microsoft.com/aspnet/core">building Web apps with ASP.NET Core</a>.</p>
-</div>
+</div>

+ 41 - 40
Dotnet/Warhammer/Views/Home/Player.cshtml

@@ -1,4 +1,4 @@
-@model IEnumerable<Warhammer.Models.Player>
+@model IEnumerable<Player>
 
 @{
     ViewData["Title"] = "View";
@@ -11,45 +11,46 @@
 </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>
+    <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) {
+    @foreach (var item in Model)
+    {
         <tr>
             <td>
                 @Html.DisplayFor(modelItem => item.Experience)
@@ -90,6 +91,6 @@
                 @Html.ActionLink("Delete", "Delete", new { /* id=item.PrimaryKey */ })
             </td>*@
         </tr>
-}
+    }
     </tbody>
-</table>
+</table>

+ 1 - 1
Dotnet/Warhammer/Views/Home/Privacy.cshtml

@@ -3,4 +3,4 @@
 }
 <h1>@ViewData["Title"]</h1>
 
-<p>Use this page to detail your site's privacy policy.</p>
+<p>Use this page to detail your site's privacy policy.</p>

+ 1 - 1
Dotnet/Warhammer/Views/Shared/Error.cshtml

@@ -22,4 +22,4 @@
     It can result in displaying sensitive information from exceptions to end users.
     For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
     and restarting the app.
-</p>
+</p>

+ 41 - 41
Dotnet/Warhammer/Views/Shared/_Layout.cshtml

@@ -1,51 +1,51 @@
 <!DOCTYPE html>
 <html lang="en">
 <head>
-    <meta charset="utf-8" />
-    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
+    <meta charset="utf-8"/>
+    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
     <title>@ViewData["Title"] - Warhammer</title>
-    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
-    <link rel="stylesheet" href="~/css/site.css" />
+    <link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css"/>
+    <link rel="stylesheet" href="~/css/site.css"/>
 </head>
 <body>
-    <header>
-        <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
-            <div class="container">
-                <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Warhammer</a>
-                <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
-                        aria-expanded="false" aria-label="Toggle navigation">
-                    <span class="navbar-toggler-icon"></span>
-                </button>
-                <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
-                    <ul class="navbar-nav flex-grow-1">
-                        <li class="nav-item">
-                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
-                        </li>
-                        <li class="nav-item">
-                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
-                        </li>
-                        <li class="nav-item">
-                            <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Players">Players</a>
-                        </li>
-                    </ul>
-                </div>
+<header>
+    <nav class="navbar navbar-expand-sm navbar-toggleable-sm navbar-light bg-white border-bottom box-shadow mb-3">
+        <div class="container">
+            <a class="navbar-brand" asp-area="" asp-controller="Home" asp-action="Index">Warhammer</a>
+            <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".navbar-collapse" aria-controls="navbarSupportedContent"
+                    aria-expanded="false" aria-label="Toggle navigation">
+                <span class="navbar-toggler-icon"></span>
+            </button>
+            <div class="navbar-collapse collapse d-sm-inline-flex flex-sm-row-reverse">
+                <ul class="navbar-nav flex-grow-1">
+                    <li class="nav-item">
+                        <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Index">Home</a>
+                    </li>
+                    <li class="nav-item">
+                        <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
+                    </li>
+                    <li class="nav-item">
+                        <a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Players">Players</a>
+                    </li>
+                </ul>
             </div>
-        </nav>
-    </header>
+        </div>
+    </nav>
+</header>
+<div class="container">
+    <main role="main" class="pb-3">
+        @RenderBody()
+    </main>
+</div>
+
+<footer class="border-top footer text-muted">
     <div class="container">
-        <main role="main" class="pb-3">
-            @RenderBody()
-        </main>
+        &copy; 2022 - Warhammer - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
     </div>
-
-    <footer class="border-top footer text-muted">
-        <div class="container">
-            &copy; 2022 - Warhammer - <a asp-area="" asp-controller="Home" asp-action="Privacy">Privacy</a>
-        </div>
-    </footer>
-    <script src="~/lib/jquery/dist/jquery.min.js"></script>
-    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
-    <script src="~/js/site.js" asp-append-version="true"></script>
-    @RenderSection("Scripts", required: false)
+</footer>
+<script src="~/lib/jquery/dist/jquery.min.js"></script>
+<script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
+<script src="~/js/site.js" asp-append-version="true"></script>
+@RenderSection("Scripts", false)
 </body>
-</html>
+</html>

+ 1 - 1
Dotnet/Warhammer/Views/Shared/_ValidationScriptsPartial.cshtml

@@ -1,2 +1,2 @@
 <script src="~/lib/jquery-validation/dist/jquery.validate.min.js"></script>
-<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>
+<script src="~/lib/jquery-validation-unobtrusive/jquery.validate.unobtrusive.min.js"></script>

+ 1 - 1
Dotnet/Warhammer/Views/_ViewImports.cshtml

@@ -1,3 +1,3 @@
 @using Warhammer
 @using Warhammer.Models
-@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
+@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers

+ 1 - 1
Dotnet/Warhammer/Views/_ViewStart.cshtml

@@ -1,3 +1,3 @@
 @{
     Layout = "_Layout";
-}
+}

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

@@ -1,8 +1,8 @@
 <?xml version="1.0" encoding="utf-8"?>
 <Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
   <PropertyGroup>
-    <View_SelectedScaffolderID>RazorViewScaffolder</View_SelectedScaffolderID>
-    <View_SelectedScaffolderCategoryPath>root/Common/MVC/View</View_SelectedScaffolderCategoryPath>
+    <View_SelectedScaffolderID>ApiControllerWithContextScaffolder</View_SelectedScaffolderID>
+    <View_SelectedScaffolderCategoryPath>root/Common/Api</View_SelectedScaffolderCategoryPath>
     <WebStackScaffolding_ViewDialogWidth>650.4</WebStackScaffolding_ViewDialogWidth>
     <WebStackScaffolding_IsLayoutPageSelected>True</WebStackScaffolding_IsLayoutPageSelected>
     <WebStackScaffolding_IsPartialViewSelected>False</WebStackScaffolding_IsPartialViewSelected>
@@ -11,7 +11,5 @@
     <Controller_SelectedScaffolderID>MvcControllerWithActionsScaffolder</Controller_SelectedScaffolderID>
     <Controller_SelectedScaffolderCategoryPath>root/Common/MVC/Controller</Controller_SelectedScaffolderCategoryPath>
     <WebStackScaffolding_ControllerDialogWidth>650</WebStackScaffolding_ControllerDialogWidth>
-    <WebStackScaffolding_DbContextDialogWidth>650</WebStackScaffolding_DbContextDialogWidth>
-    <ShowAllFiles>true</ShowAllFiles>
   </PropertyGroup>
 </Project>

+ 1 - 1
Dotnet/Warhammer/appsettings.Development.json

@@ -6,4 +6,4 @@
       "Microsoft.Hosting.Lifetime": "Information"
     }
   }
-}
+}

+ 3 - 3
Dotnet/Warhammer/appsettings.json

@@ -1,7 +1,7 @@
 {
-
   "ConnectionStrings": {
-    "DefaultConnection": "Server=(localdb)\\mssqllocaldb;Database=Warhammer;Trusted_Connection=True;MultipleActiveResultSets=true"
+    "DefaultConnection":
+      "Server=(localdb)\\mssqllocaldb;Database=Warhammer;Trusted_Connection=True;MultipleActiveResultSets=true"
   },
   "Logging": {
     "LogLevel": {
@@ -11,4 +11,4 @@
     }
   },
   "AllowedHosts": "*"
-}
+}