From e3a9577eaa15d9c6632f9f76f97d250bb09a59bc Mon Sep 17 00:00:00 2001
From: Pierre Ferreira
Date: Wed, 1 Mar 2023 17:35:56 +0100
Subject: [PATCH] =?UTF-8?q?:sparkles:=20Ajout=20de=20la=20class=20Skin=20e?=
=?UTF-8?q?t=20cr=C3=A9ation=20de=20la=20branche?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Sources/EntityFramework/ChampionEntity.cs | 15 +++++
Sources/EntityFramework/LargeImageEntity.cs | 18 ++++++
Sources/EntityFramework/SkinEntity.cs | 68 +++++++++++++++++++++
3 files changed, 101 insertions(+)
create mode 100644 Sources/EntityFramework/LargeImageEntity.cs
create mode 100644 Sources/EntityFramework/SkinEntity.cs
diff --git a/Sources/EntityFramework/ChampionEntity.cs b/Sources/EntityFramework/ChampionEntity.cs
index 5d2c455..bc8de94 100644
--- a/Sources/EntityFramework/ChampionEntity.cs
+++ b/Sources/EntityFramework/ChampionEntity.cs
@@ -34,11 +34,15 @@ namespace EntityFramework
private ICollection Skills { get; set; }
+ public ReadOnlyCollection Skins { get; private set; }
+ private List skins = new();
+
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
this.Bio = bio;
this.Icon = icon;
Skills= new List();
+ Skins = new ReadOnlyCollection(skins);
}
public override string ToString()
@@ -53,5 +57,16 @@ namespace EntityFramework
public void RemoveSkill(SkillEntity skill)
=> Skills.Remove(skill);
+
+
+ public bool AddSkin(SkinEntity skin)
+ {
+ if (skins.Contains(skin))
+ return false;
+ skins.Add(skin);
+ return true;
+ }
+
+
}
}
diff --git a/Sources/EntityFramework/LargeImageEntity.cs b/Sources/EntityFramework/LargeImageEntity.cs
new file mode 100644
index 0000000..a1f8ae1
--- /dev/null
+++ b/Sources/EntityFramework/LargeImageEntity.cs
@@ -0,0 +1,18 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class LargeImageEntity
+ {
+ public string Base64 { get; set; }
+
+ public LargeImageEntity(string base64)
+ {
+ Base64 = base64;
+ }
+ }
+}
diff --git a/Sources/EntityFramework/SkinEntity.cs b/Sources/EntityFramework/SkinEntity.cs
new file mode 100644
index 0000000..a71c5ea
--- /dev/null
+++ b/Sources/EntityFramework/SkinEntity.cs
@@ -0,0 +1,68 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace EntityFramework
+{
+ public class SkinEntity //ON TO MANY
+ {
+ public string Name
+ {
+ get => name;
+ private init
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ throw new ArgumentException("A skin must have a name");
+ }
+ name = value;
+ }
+ }
+ private readonly string name = null!;
+
+ public string Description
+ {
+ get => description;
+ set
+ {
+ if (string.IsNullOrWhiteSpace(value))
+ {
+ description = "";
+ return;
+ }
+ description = value;
+ }
+ }
+ private string description = "";
+
+ public string Icon { get; set; }
+ public LargeImageEntity Image { get; set; }
+
+ public float Price { get; set; }
+
+ public ChampionEntity Champion
+ {
+ get => champion;
+ private init
+ {
+ if (value == null)
+ throw new ArgumentNullException("A skill can't have a null champion");
+ champion = value;
+ }
+ }
+ private readonly ChampionEntity champion = null!;
+
+ public SkinEntity(string name, ChampionEntity champion, float price = 0.0f, string icon = "", string image = "", string description = "")
+ {
+ Name = name;
+ Champion = champion;
+ Champion.AddSkin(this);
+ Price = price;
+ Icon = icon;
+ Image = new LargeImageEntity(image);
+ Description = description;
+ }
+ }
+}