Ajout de la class Skin et création de la branche
continuous-integration/drone/push Build is failing Details

pull/23/head
Pierre Ferreira 2 years ago
parent fc4a1e5a89
commit e3a9577eaa

@ -34,11 +34,15 @@ namespace EntityFramework
private ICollection<SkillEntity> Skills { get; set; }
public ReadOnlyCollection<SkinEntity> Skins { get; private set; }
private List<SkinEntity> skins = new();
public ChampionEntity(string name,string bio,string icon) {
this.Name = name;
this.Bio = bio;
this.Icon = icon;
Skills= new List<SkillEntity>();
Skins = new ReadOnlyCollection<SkinEntity>(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;
}
}
}

@ -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;
}
}
}

@ -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;
}
}
}
Loading…
Cancel
Save