Jelajahi Sumber

Clean model and split weapon and WeaponList into 2 components

Florian Morel 1 tahun lalu
induk
melakukan
ffc0896c93

+ 8 - 0
.gitignore

@@ -38,3 +38,11 @@ __pycache__
 /Dotnet/Warhammer/bin/Debug/net8.0
 /.vs/Warhammer/FileContentIndex
 /.vs/Warhammer/v17
+/Dotnet/Deathwatch/bin/Release/net8.0
+/Dotnet/Infrastructure/bin/Release/net8.0
+/Dotnet/Services/bin/Release/net8.0
+/Dotnet/Domain/bin/Release/net8.0
+/Dotnet/DataLayer/bin/Release/net8.0
+/Dotnet/Deathwatch/Properties/PublishProfiles
+/Dotnet/Deathwatch/Properties/ServiceDependencies/Deathwatch - Web Deploy
+/Dotnet/Deathwatch/.config

+ 1 - 0
Dotnet/Deathwatch/Deathwatch.csproj.user

@@ -4,6 +4,7 @@
     <ActiveDebugProfile>IIS Express</ActiveDebugProfile>
     <RazorPage_SelectedScaffolderID>RazorPageScaffolder</RazorPage_SelectedScaffolderID>
     <RazorPage_SelectedScaffolderCategoryPath>root/Common/RazorPage</RazorPage_SelectedScaffolderCategoryPath>
+    <NameOfLastUsedPublishProfile>Deathwatch - Web Deploy</NameOfLastUsedPublishProfile>
   </PropertyGroup>
   <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
     <DebuggerFlavor>ProjectDebugger</DebuggerFlavor>

+ 21 - 64
Dotnet/Deathwatch/Pages/Weapon.razor

@@ -1,67 +1,24 @@
 @page "/weapon"
-@attribute [StreamRendering(true)]
 
-<h3>Weapon</h3>
-@if (Weapons == null)
-{
-    <p><em>Loading...</em></p>
-}
-else
-{
-    <table class="table">
-        <thead>
-            <tr>
-                <th>Id</th>
-                <th>Nom</th>
-                <th>Genre</th>
-                <th>Type</th>
-                <th>Groupe</th>
-                <th>Portée</th>
-                <th>Modes</th>
-                <th>Dégâts</th>
-                <th>Type Dégâts</th>
-                <th>Pénétration</th>
-                <th>Autonomie</th>
-                <th>Rechargement</th>
-                <th>Attributs</th>
-                <th>Accessoires</th>
-                <th>Poids</th>
-                <th>Bonus BF</th>
-                <th>Prix</th>
-                <th>Disponibilité</th>
-                <th>Description</th>
-            </tr>
-        </thead>
-        <tbody>
-            @foreach (var weapon in Weapons)
-            {
-                <tr>
-                    <td>@weapon.Id</td>
-                    <td>@weapon.Nom</td>
-                    <td>@weapon.Genre</td>
-                    <td>@weapon.Type</td>
-                    <td>@weapon.Groupe</td>
-                    <td>@weapon.Portée</td>
-                    <td>@weapon.Modes</td>
-                    <td>@weapon.Dégâts</td>
-                    <td>@weapon.TypeDégâts</td>
-                    <td>@weapon.Pénétration</td>
-                    <td>@weapon.Autonomie</td>
-                    <td>@weapon.Rechargement</td>
-                    <td>@weapon.Attributs</td>
-                    <td>@weapon.Accessoires</td>
-                    <td>@weapon.Poids</td>
-                    <td>@weapon.BonusBf</td>
-                    <td>@weapon.Prix</td>
-                    <td>@weapon.Disponibilité</td>
-                    <td>@weapon.Description</td>
-                </tr>
-            }
-        </tbody>
-    </table>
-}
 
-
-@code {
-
-}
+<div class="row border border-2">
+    <div class="col  border border-2">@Arme.Id</div>
+    <div class="col  border border-2">@Arme.Nom</div>
+    <div class="col  border border-2">@Arme.Genre</div>
+    <div class="col  border border-2">@Arme.Type</div>
+    <div class="col  border border-2">@Arme.Groupe</div>
+    <div class="col  border border-2">@Arme.Portée</div>
+    <div class="col  border border-2">@Arme.Modes</div>
+    <div class="col  border border-2">@Arme.Dégâts</div>
+    <div class="col  border border-2">@Arme.TypeDégâts</div>
+    <div class="col  border border-2">@Arme.Pénétration</div>
+    <div class="col  border border-2">@Arme.Autonomie</div>
+    <div class="col  border border-2">@Arme.Rechargement</div>
+    <div class="col  border border-2">@Arme.Attributs</div>
+    <div class="col  border border-2">@Arme.Accessoires</div>
+    <div class="col  border border-2">@Arme.Poids</div>
+    <div class="col  border border-2">@Arme.BonusBf</div>
+    <div class="col  border border-2">@Arme.Prix</div>
+    <div class="col  border border-2">@Arme.Disponibilité</div>
+  
+</div>

+ 15 - 6
Dotnet/Deathwatch/Pages/Weapon.razor.cs

@@ -1,4 +1,3 @@
-using DataLayer.Interfaces;
 using Domain.XML_Model;
 using Microsoft.AspNetCore.Components;
 
@@ -6,15 +5,25 @@ namespace Deathwatch.Pages
 {
     public partial class Weapon
     {
-        [Inject]
-        public IAbstractRepository<Arme>? WeaponRepository { get; set; }
+        [Parameter]
+        public Arme Arme { get; set; }
+        public bool ShowDetails { get; set; }
 
-        public List<Arme> Weapons { get; set; } = new List<Arme>();
+        private void OnStateChanged() => this.InvokeAsync(StateHasChanged);
 
-        protected override async Task OnInitializedAsync()
+        public Weapon()
         {
-            Weapons = (await WeaponRepository?.GetAll()).ToList();
+
+        }
+
+        public Weapon(Arme arme)
+        {
+            Arme = arme;
         }
 
+        public void ToggleDescription()
+        {
+            ShowDetails = !ShowDetails;
+        }
     }
 }

+ 58 - 0
Dotnet/Deathwatch/Pages/WeaponList.razor

@@ -0,0 +1,58 @@
+@page "/weapon-list"
+@using Domain.XML_Model
+@attribute [StreamRendering(true)]
+
+<div>
+    <h3>Weapon</h3>
+</div>
+<div>
+    @if (Weapons == null)
+    {
+        <p><em>Loading...</em></p>
+    }
+    else
+    {
+        <div class="container-fluid">
+            <div class="row  border border-2">
+                <div class="col">Id</div>
+                <div class="col">Nom</div>
+                <div class="col">Genre</div>
+                <div class="col">Type</div>
+                <div class="col">Groupe</div>
+                <div class="col">Portée</div>
+                <div class="col">Modes</div>
+                <div class="col">Dégâts</div>
+                <div class="col">Type Dégâts</div>
+                <div class="col">Pénétration</div>
+                <div class="col">Autonomie</div>
+                <div class="col">Rechargement</div>
+                <div class="col">Attributs</div>
+                <div class="col">Accessoires</div>
+                <div class="col">Poids</div>
+                <div class="col">Bonus BF</div>
+                <div class="col">Prix</div>
+                <div class="col">Disponibilité</div>
+            </div>
+            <div>
+                @foreach (var weapon in Weapons)
+                {
+                    <div @onclick="() => weapon.ToggleDescription()">
+                        <Weapon Arme="weapon.Arme" />
+                        @if (weapon.ShowDetails)
+                        {
+                            <div class="description">
+                                Description : @weapon.Arme.Description
+                            </div>
+                        }
+                    </div>
+                }
+            </div>
+        </div>
+    }
+</div>
+
+
+
+@code {
+    
+}

+ 24 - 0
Dotnet/Deathwatch/Pages/WeaponList.razor.cs

@@ -0,0 +1,24 @@
+using DataLayer.Interfaces;
+using Domain.Weapons;
+using Domain.XML_Model;
+using Microsoft.AspNetCore.Components;
+
+namespace Deathwatch.Pages
+{
+    public partial class WeaponList
+    {
+        [Inject]
+        public IAbstractRepository<Arme>? WeaponRepository { get; set; }
+
+        public List<Weapon> Weapons { get; set; } = new List<Weapon>();
+        public Weapon? SelectedWeapon { get; set; }
+
+        protected override async Task OnInitializedAsync()
+        {
+            var armes = (await WeaponRepository?.GetAll()).OrderBy(a => a.ArmeId).ToList();
+            armes.ForEach(a => Weapons.Add(new Weapon(a)));
+            SelectedWeapon = Weapons.FirstOrDefault();
+        }
+     
+    }
+}

+ 1 - 7
Dotnet/Deathwatch/Program.cs

@@ -1,11 +1,9 @@
 using DataLayer;
 using DataLayer.Interfaces;
 using Deathwatch.Data;
+using Microsoft.EntityFrameworkCore;
 using Services;
 using Services.Interfaces;
-using Microsoft.EntityFrameworkCore;
-using Infrastructure;
-using Microsoft.Extensions.DependencyInjection;
 
 var builder = WebApplication.CreateBuilder(args);
 
@@ -24,10 +22,6 @@ builder.Services.AddTransient<IPlayerRepository, PlayerRepository>();
 builder.Services.AddHttpClient();
 //builder.Services.AddSqlite<DeathwatchDbContext>("Data Source=deathwatch.db");
 
-var currentDirectory = Directory.GetCurrentDirectory();
-string folderPath = $"{currentDirectory}/XML/";
-string outputJsonFilePath = $"{currentDirectory}/outputfile.json";
-
 var app = builder.Build();
 
 var scopeFactory = app.Services.GetRequiredService<IServiceScopeFactory>();

+ 1 - 1
Dotnet/Deathwatch/Shared/NavMenu.razor

@@ -28,7 +28,7 @@
         </div>
 
         <div class="nav-item px-3">
-            <NavLink class="nav-link" href="weapon">
+            <NavLink class="nav-link" href="weapon-list">
                 <span class="oi oi-list-rich" aria-hidden="true"></span> Weapons
             </NavLink>
         </div>

+ 1 - 1
Dotnet/Domain/XML Model/Accessoire.cs

@@ -27,7 +27,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int AccessoireId { get; set; }
+        [XmlIgnore] public int AccessoireId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Archétype.cs

@@ -61,7 +61,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int ArchétypeId { get; set; }
+        [XmlIgnore] public int ArchétypeId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Armure.cs

@@ -45,7 +45,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int ArmureId { get; set; }
+        [XmlIgnore] public int ArmureId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Assermentation.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int AssermentationId { get; set; }
+        [XmlIgnore] public int AssermentationId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Attribut.cs

@@ -18,7 +18,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int AttributId { get; set; }
+        [XmlIgnore] public int AttributId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Carrière.cs

@@ -21,7 +21,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int CarrièreId { get; set; }
+        [XmlIgnore] public int CarrièreId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Competence.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int CompetenceId { get; set; }
+        [XmlIgnore] public int CompetenceId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Coordonnée.cs

@@ -27,7 +27,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int CoordonnéeId { get; set; }
+        [XmlIgnore] public int CoordonnéeId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Cybernétique.cs

@@ -36,7 +36,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int CybernétiqueId { get; set; }
+        [XmlIgnore] public int CybernétiqueId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Discipline.cs

@@ -15,7 +15,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int DisciplineId { get; set; }
+        [XmlIgnore] public int DisciplineId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Divination.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int DivinationId { get; set; }
+        [XmlIgnore] public int DivinationId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Equipement.cs

@@ -27,7 +27,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string Description { get; set; }
-        [XmlIgnoreAttribute] public int EquipementId { get; set; }
+        [XmlIgnore] public int EquipementId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Implant.cs

@@ -18,7 +18,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int ImplantId { get; set; }
+        [XmlIgnore] public int ImplantId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Monde.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int MondeId { get; set; }
+        [XmlIgnore] public int MondeId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Mutation.cs

@@ -27,7 +27,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int MutationId { get; set; }
+        [XmlIgnore] public int MutationId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Pouvoir.cs

@@ -33,7 +33,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int PouvoirId { get; set; }
+        [XmlIgnore] public int PouvoirId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Promote.cs

@@ -27,7 +27,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int PromotionId { get; set; }
+        [XmlIgnore] public int PromotionId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Seuil.cs

@@ -18,7 +18,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "valeur_max")]
         public int ValeurMax { get; set; }
-        [XmlIgnoreAttribute] public int SeuilId { get; set; }
+        [XmlIgnore] public int SeuilId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Sousmonde.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int SousmondeId { get; set; }
+        [XmlIgnore] public int SousmondeId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Talent.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int TalentId { get; set; }
+        [XmlIgnore] public int TalentId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Trait.cs

@@ -21,7 +21,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int TraitId { get; set; }
+        [XmlIgnore] public int TraitId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/Trouble.cs

@@ -18,7 +18,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int TroubleId { get; set; }
+        [XmlIgnore] public int TroubleId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/TypeMonde.cs

@@ -36,7 +36,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "description")]
         public string? Description { get; set; }
-        [XmlIgnoreAttribute] public int TypeMondeId { get; set; }
+        [XmlIgnore] public int TypeMondeId { get; set; }
     }
 
 

+ 1 - 1
Dotnet/Domain/XML Model/TypeName.cs

@@ -24,7 +24,7 @@ namespace Domain.XML_Model
 
         [XmlAttribute(AttributeName = "seuil_max")]
         public int SeuilMax { get; set; }
-        [XmlIgnoreAttribute]
+        [XmlIgnore]
         public int TypeNomId { get; set; }
     }