UT_EF_Manager #9

Merged
emre.kartal merged 4 commits from UT_EF_Manager into master 2 years ago

@ -1,6 +1,4 @@
using ApiLol.Mapper;
using Microsoft.AspNetCore.Mvc;
using Model;
namespace ApiLol.Controllers
{
@ -23,13 +21,6 @@ namespace ApiLol.Controllers
[HttpGet(Name = "GetWeatherForecast")]
public IEnumerable<WeatherForecast> Get()
{
/*
var champion = new Champion("");
//var dtop = ChampionMapper.ToDto(champion);
var dto = champion.ToDto();*/
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
{
Date = DateTime.Now.AddDays(index),

@ -6,8 +6,7 @@ namespace ApiLol.Mapper
public static class ChampionMapper
{
public static ChampionDto ToDto(this Champion champion)
{
return new ChampionDto()
=> new()
{
Name = champion.Name,
Bio = champion.Bio,
@ -17,12 +16,12 @@ namespace ApiLol.Mapper
Skins = champion.Skins.Select(e => e.ToDto()),
Skills = champion.Skills.Select(e => e.ToDto())
};
}
public static Champion ToModel(this ChampionDto championDto)
{
var champ = new Champion(championDto.Name, championDto.Class.ToModel(), championDto.Icon, championDto.Image.Base64, championDto.Bio);
foreach(var skin in championDto.Skins)
foreach (var skin in championDto.Skins)
{
champ.AddSkin(skin.ToModel(champ));
}

@ -6,16 +6,9 @@ namespace ApiLol.Mapper
public static class LargeImageMapper
{
public static LargeImageDto ToDto(this LargeImage largeImage)
{
return new LargeImageDto()
{
Base64 = largeImage.Base64
};
}
=> new() { Base64 = largeImage.Base64 };
public static LargeImage ToModel(this LargeImageDto largeImageDto) => new(largeImageDto.Base64);
public static LargeImage ToModel(this LargeImageDto largeImageDto)
{
return new LargeImage(largeImageDto.Base64);
}
}
}

@ -7,8 +7,7 @@ namespace ApiLol.Mapper
public static class RuneMapper
{
public static RuneDto ToDto(this Rune rune)
{
return new RuneDto()
=> new()
{
Name = rune.Name,
Description = rune.Description,
@ -16,11 +15,8 @@ namespace ApiLol.Mapper
Icon = rune.Icon,
Image = rune.Image.ToDto()
};
}
public static Rune ToModel(this RuneDto rune)
{
return new Rune(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description);
}
public static Rune ToModel(this RuneDto rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description);
}
}

@ -6,18 +6,14 @@ namespace ApiLol.Mapper
public static class SkillMapper
{
public static SkillDto ToDto(this Skill skill)
{
return new SkillDto()
=> new()
{
Name = skill.Name,
Description = skill.Description,
Type = skill.Type.ToDto()
};
}
public static Skill ToModel(this SkillDto skillDto)
{
return new Skill(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description);
}
public static Skill ToModel(this SkillDto skillDto) => new(skillDto.Name, skillDto.Type.ToModel(), skillDto.Description);
}
}

@ -6,8 +6,7 @@ namespace ApiLol.Mapper
public static class SkinMapper
{
public static SkinDto ToDto(this Skin skin)
{
return new SkinDto()
=> new()
{
Name = skin.Name,
Description = skin.Description,
@ -15,11 +14,9 @@ namespace ApiLol.Mapper
Image = skin.Image.ToDto(),
Price = skin.Price
};
}
public static SkinDtoC ToDtoC(this Skin skin)
{
return new SkinDtoC()
=> new()
{
Name = skin.Name,
Description = skin.Description,
@ -28,17 +25,10 @@ namespace ApiLol.Mapper
Price = skin.Price,
ChampionName = skin.Champion.Name
};
}
public static Skin ToModel(this SkinDto skinDto, Champion champ)
{
return new Skin(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description);
}
public static Skin ToModel(this SkinDto skinDto, Champion champ) => new(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description);
public static Skin ToModelC(this SkinDtoC skinDto, Champion champ)
{
return new Skin(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description);
}
public static Skin ToModelC(this SkinDtoC skinDto, Champion champ) => new(skinDto.Name, champ, skinDto.Price, skinDto.Icon, skinDto.Image.Base64, skinDto.Description);
}
}

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class LargeImageDto
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class PageRequest
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class PageResponse<T>
{

@ -1,9 +1,4 @@
using DTO.enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class SkillDto
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class SkinDto
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public class SkinDtoC
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public enum ChampionClassDto
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO.enums
namespace DTO.enums
{
public enum RuneFamilyDto
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace DTO
{
public enum SkillTypeDto
{

@ -0,0 +1,105 @@
using Model;
namespace DbManager
{
public partial class DbManager
{
public class ChampionsManager : IChampionsManager
{
private readonly DbManager parent;
public ChampionsManager(DbManager parent)
=> this.parent = parent;
public Task<Champion?> AddItem(Champion? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Champion? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsByClass(ChampionClass championClass, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsByRunePage(RunePage? runePage, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsBySkill(Skill? skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Champion?>> GetItemsBySkill(string skill, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByCharacteristic(string charName)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByClass(ChampionClass championClass)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByName(string substring)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByRunePage(RunePage? runePage)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsBySkill(Skill? skill)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsBySkill(string skill)
{
throw new NotImplementedException();
}
public Task<Champion?> UpdateItem(Champion? oldItem, Champion? newItem)
{
throw new NotImplementedException();
}
}
}
}

@ -0,0 +1,80 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DbManager
{
public partial class DbManager
{
public class RunePagesManager : IRunePagesManager
{
private readonly DbManager parent;
public RunePagesManager(DbManager parent)
=> this.parent = parent;
public Task<RunePage?> AddItem(RunePage? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(RunePage? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<RunePage?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<RunePage?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<RunePage?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<RunePage?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<RunePage?>> GetItemsByRune(Model.Rune? rune, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByChampion(Champion? champion)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByName(string substring)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByRune(Model.Rune? rune)
{
throw new NotImplementedException();
}
public Task<RunePage?> UpdateItem(RunePage? oldItem, RunePage? newItem)
{
throw new NotImplementedException();
}
}
}
}

@ -0,0 +1,70 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DbManager
{
public partial class DbManager
{
public class RunesManager : IRunesManager
{
private readonly DbManager parent;
public RunesManager(DbManager parent)
=> this.parent = parent;
public Task<Model.Rune?> AddItem(Model.Rune? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Model.Rune? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Model.Rune?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Model.Rune?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Model.Rune?>> GetItemsByFamily(RuneFamily family, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Model.Rune?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByFamily(RuneFamily family)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByName(string substring)
{
throw new NotImplementedException();
}
public Task<Model.Rune?> UpdateItem(Model.Rune? oldItem, Model.Rune? newItem)
{
throw new NotImplementedException();
}
}
}
}

@ -0,0 +1,71 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DbManager
{
public partial class DbManager
{
public class SkinsManager : ISkinsManager
{
private readonly DbManager parent;
public SkinsManager(DbManager parent)
=> this.parent = parent;
public Task<Skin?> AddItem(Skin? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Skin? item)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Skin?>> GetItemByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Skin?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Skin?>> GetItemsByChampion(Champion? champion, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<IEnumerable<Skin?>> GetItemsByName(string substring, int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
}
public Task<int> GetNbItems()
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByChampion(Champion? champion)
{
throw new NotImplementedException();
}
public Task<int> GetNbItemsByName(string substring)
{
throw new NotImplementedException();
}
public Task<Skin?> UpdateItem(Skin? oldItem, Skin? newItem)
{
throw new NotImplementedException();
}
}
}
}

@ -0,0 +1,27 @@
using Model;
using MyFlib;
namespace DbManager
{
public partial class DbManager : IDataManager
{
protected LolDbContext DbContext { get; set; }
public DbManager(LolDbContext dbContext)
{
DbContext = dbContext;
ChampionsMgr = new ChampionsManager(this);
SkinsMgr = new SkinsManager(this);
RunesMgr = new RunesManager(this);
RunePagesMgr = new RunePagesManager(this);
}
public IChampionsManager ChampionsMgr { get; set; }
public ISkinsManager SkinsMgr { get; set; }
public IRunesManager RunesMgr { get; set; }
public IRunePagesManager RunePagesMgr { get; set; }
}
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
<ProjectReference Include="..\MyFlib\MyFlib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,43 @@
using DbManager.Mapper.enums;
using Model;
using MyFlib;
namespace DbManager.Mapper
{
public static class ChampionMapper
{
public static Champion ToModel(this ChampionEntity championEntity)
{
Champion champion = new (championEntity.Name, championEntity.Class.ToModel(), championEntity.Icon, championEntity.Image.Base64.ToString(), championEntity.Bio);
foreach (var skill in championEntity.Skills)
{
champion.AddSkill(skill.ToModel());
}
foreach (var skin in championEntity.Skins)
{
champion.AddSkin(skin.ToModel());
}
return champion;
}
public static ChampionEntity ToEntity(this Champion champion, LolDbContext context)
{
var champ = new ChampionEntity()
{
Name = champion.Name,
Icon = champion.Icon,
Bio = champion.Bio,
Image = champion.Image.ToEntity(),
};
foreach (var skill in champion.Skills)
{
champ.Skills.Add(skill.ToEntity(champ));
}
foreach (var skin in champion.Skins)
{
champ.Skins.Add(skin.ToEntity(context));
}
return champ;
}
}
}

@ -0,0 +1,13 @@
using Model;
using MyFlib;
namespace DbManager.Mapper
{
public static class LargeImageMapper
{
public static LargeImage ToModel(this LargeImageEntity largeImage) => new(largeImage.Base64);
public static LargeImageEntity ToEntity(this LargeImage largeImage) => new() { Base64 = largeImage.Base64 };
}
}

@ -0,0 +1,21 @@
using DbManager.Mapper.enums;
using Model;
using MyFlib;
namespace DbManager.Mapper
{
public static class RuneMapper
{
public static Rune ToModel(this RuneEntity rune) => new(rune.Name, rune.Family.ToModel(), rune.Icon, rune.Image.Base64, rune.Description);
public static RuneEntity ToEntity(this Rune rune)
=> new()
{
Name = rune.Name,
Description = rune.Description,
Family = rune.Family.ToEntity(),
Icon = rune.Icon,
Image = rune.Image.ToEntity()
};
}
}

@ -0,0 +1,24 @@
using DbManager.Mapper.enums;
using Model;
using MyFlib;
using MyFlib.Entities;
namespace DbManager.Mapper
{
public static class RunePageMapper
{
public static RunePage ToModel(this RunePageEntity runePageEntity, LolDbContext context)
{
RunePage runePage = new(runePageEntity.Name);
foreach (var d in runePageEntity.DictionaryCategoryRunes)
{
var rune = context.Runes.Find(d.RuneName);
if (rune!=null)
{
runePage[d.category.ToModel()] = rune.ToModel();
}
}
return runePage;
}
}
}

@ -0,0 +1,24 @@
using DbManager.Mapper.enums;
using Model;
using MyFlib;
namespace DbManager.Mapper
{
public static class SkillMapper
{
public static Skill ToModel(this SkillEntity skillEntity) => new(skillEntity.Name, skillEntity.Type.ToModel(), skillEntity.Description);
public static SkillEntity ToEntity(this Skill skill, ChampionEntity championEntity)
{
return new()
{
Name = skill.Name,
Description = skill.Description,
Type = skill.Type.ToEntity(),
Champion = championEntity
};
}
}
}

@ -0,0 +1,22 @@
using Model;
using MyFlib;
namespace DbManager.Mapper
{
public static class SkinMapper
{
public static Skin ToModel(this SkinEntity skinEntity)
=> new(skinEntity.Name, skinEntity.Champion.ToModel(), skinEntity.Price, skinEntity.Icon, skinEntity.Image.Base64, skinEntity.Description);
public static SkinEntity ToEntity(this Skin skin, LolDbContext context)
=> new()
{
Name = skin.Name,
Description = skin.Description,
Icon = skin.Icon,
Price = skin.Price,
Champion = context.Champions.Find(skin.Champion.Name),
Image = skin.Image.ToEntity()
};
}
}

@ -0,0 +1,50 @@
using Model;
using MyFlib.Entities.enums;
namespace DbManager.Mapper.enums
{
public static class CategoryMapper
{
public static RunePage.Category ToModel(this CategoryEntity category)
{
switch (category)
{
case CategoryEntity.Major:
return RunePage.Category.Major;
case CategoryEntity.Minor1:
return RunePage.Category.Minor1;
case CategoryEntity.Minor2:
return RunePage.Category.Minor2;
case CategoryEntity.Minor3:
return RunePage.Category.Minor3;
case CategoryEntity.OtherMinor1:
return RunePage.Category.OtherMinor1;
case CategoryEntity.OtherMinor2:
return RunePage.Category.OtherMinor2;
default:
return RunePage.Category.Major;
}
}
public static CategoryEntity ToEntity(this RunePage.Category category)
{
switch (category)
{
case RunePage.Category.Major:
return CategoryEntity.Major;
case RunePage.Category.Minor1:
return CategoryEntity.Minor1;
case RunePage.Category.Minor2:
return CategoryEntity.Minor2;
case RunePage.Category.Minor3:
return CategoryEntity.Minor3;
case RunePage.Category.OtherMinor1:
return CategoryEntity.OtherMinor1;
case RunePage.Category.OtherMinor2:
return CategoryEntity.OtherMinor2;
default:
return CategoryEntity.Major;
}
}
}
}

@ -0,0 +1,55 @@
using Model;
using MyFlib;
namespace DbManager.Mapper.enums
{
public static class ChampionClassMapper
{
public static ChampionClass ToModel(this ChampionClassEntity championClass)
{
switch (championClass)
{
case ChampionClassEntity.Unknown:
return ChampionClass.Unknown;
case ChampionClassEntity.Assassin:
return ChampionClass.Assassin;
case ChampionClassEntity.Fighter:
return ChampionClass.Fighter;
case ChampionClassEntity.Mage:
return ChampionClass.Mage;
case ChampionClassEntity.Marksman:
return ChampionClass.Marksman;
case ChampionClassEntity.Support:
return ChampionClass.Support;
case ChampionClassEntity.Tank:
return ChampionClass.Tank;
default:
return ChampionClass.Unknown;
}
}
public static ChampionClassEntity ToEntity(this ChampionClass championClass)
{
switch (championClass)
{
case ChampionClass.Unknown:
return ChampionClassEntity.Unknown;
case ChampionClass.Assassin:
return ChampionClassEntity.Assassin;
case ChampionClass.Fighter:
return ChampionClassEntity.Fighter;
case ChampionClass.Mage:
return ChampionClassEntity.Mage;
case ChampionClass.Marksman:
return ChampionClassEntity.Marksman;
case ChampionClass.Support:
return ChampionClassEntity.Support;
case ChampionClass.Tank:
return ChampionClassEntity.Tank;
default:
return ChampionClassEntity.Unknown;
}
}
}
}

@ -0,0 +1,43 @@
using Model;
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DbManager.Mapper.enums
{
public static class RuneFamilyMapper
{
public static RuneFamily ToModel(this RuneFamilyEntity runeFamily)
{
switch (runeFamily)
{
case RuneFamilyEntity.Unknown:
return RuneFamily.Unknown;
case RuneFamilyEntity.Precision:
return RuneFamily.Precision;
case RuneFamilyEntity.Domination:
return RuneFamily.Domination;
default:
return RuneFamily.Unknown;
}
}
public static RuneFamilyEntity ToEntity(this RuneFamily runeFamily)
{
switch (runeFamily)
{
case RuneFamily.Unknown:
return RuneFamilyEntity.Unknown;
case RuneFamily.Precision:
return RuneFamilyEntity.Precision;
case RuneFamily.Domination:
return RuneFamilyEntity.Domination;
default:
return RuneFamilyEntity.Unknown;
}
}
}
}

@ -0,0 +1,42 @@
using Model;
using MyFlib;
namespace DbManager.Mapper.enums
{
public static class SkillTypeMapper
{
public static SkillType ToModel(this SkillTypeEntity skillTypeEntity)
{
switch (skillTypeEntity)
{
case SkillTypeEntity.Unknown:
return SkillType.Unknown;
case SkillTypeEntity.Basic:
return SkillType.Basic;
case SkillTypeEntity.Passive:
return SkillType.Passive;
case SkillTypeEntity.Ultimate:
return SkillType.Ultimate;
default:
return SkillType.Unknown;
}
}
public static SkillTypeEntity ToEntity(this SkillType skillType)
{
switch (skillType)
{
case SkillType.Unknown:
return SkillTypeEntity.Unknown;
case SkillType.Basic:
return SkillTypeEntity.Basic;
case SkillType.Passive:
return SkillTypeEntity.Passive;
case SkillType.Ultimate:
return SkillTypeEntity.Ultimate;
default:
return SkillTypeEntity.Unknown;
}
}
}
}

@ -0,0 +1,2 @@
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

@ -19,13 +19,15 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiLol", "ApiLol\ApiLol.csp
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{3919E408-EB12-4422-989B-C6ED4816D465}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApiTests", "Tests\ApiTests\ApiTests.csproj", "{1779D8A4-2E12-47F3-BDA2-2E7F04B758EB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Client", "Client\Client.csproj", "{464DAB04-BE65-429D-9A39-3E1BB43C521A}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MyFlib", "MyFlib\MyFlib.csproj", "{2142AB69-B483-4B0A-96DC-CFA87DEB11A5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UT_EF", "Tests\UT_EF\UT_EF.csproj", "{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "UT_EF", "Tests\UT_EF\UT_EF.csproj", "{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DbManager", "DbManager\DbManager.csproj", "{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -73,6 +75,10 @@ Global
{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F896C30B-A6FE-42B2-BAC8-08360BC48DC6}.Release|Any CPU.Build.0 = Release|Any CPU
{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Debug|Any CPU.Build.0 = Debug|Any CPU
{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Release|Any CPU.ActiveCfg = Release|Any CPU
{71DDCC06-D993-47B0-92E3-5DD6E295FB8B}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

@ -1,10 +1,4 @@
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.Diagnostics.Metrics;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
{
@ -15,7 +9,6 @@ namespace MyFlib
var image1 = new LargeImageEntity { Id = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}"), Base64 = "empty" };
// Champions
ChampionEntity hecarim = new ChampionEntity { Name = "Hecarim", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
ChampionEntity nasus = new ChampionEntity { Name = "Nasus", Class = ChampionClassEntity.Tank, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
ChampionEntity ashe = new ChampionEntity { Name = "Ashe", Class = ChampionClassEntity.Marksman, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
@ -23,23 +16,21 @@ namespace MyFlib
context.AddRange(hecarim, nasus, ashe);
// Skins
SkinEntity darkJhin = new SkinEntity { Name = "Dark Cosmic Jhin", ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}"), Description = "In the depths of the universe, serial killer Jhin has found a new form of power in cosmic darkness. With his galaxy mask and strange synergy with the four elements of space, he's never been deadlier.", Icon = "empty", Price = 1820, ImageId = Guid.Parse("{7cc1b02d-29a3-4493-96b7-1e3d9f3e14e2}") };
SkinEntity kaiSaPrestige = new SkinEntity { Name = "K/DA Kai'Sa Prestige Edition", ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}"), Description = "Kai'Sa, the hottest K-pop star of the moment, knows that to make a sensation, you have to be willing to do anything. With her dazzling outfit and electrifying dance moves, she'll make waves on stage and on the battlefield.", Icon = "empty", Price = 2000, ImageId = Guid.Parse("{555c9eb9-f41f-42f1-a05b-ae5d2ee7f782}") };
SkinEntity pykeProject = new SkinEntity { Name = "PROJECT: Pyke", ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}"), Description = "Pyke, the ultimate android assassin, has recently been upgraded to carry out the most complex missions. With his new tools and enhanced programming, he can sneak into any security system and eliminate any target.", Icon = "empty", Price = 1350, ImageId = Guid.Parse("{6b47024c-0c1d-4066-bda8-2cb0d7c900fa}") };
SkinEntity darkJhin = new SkinEntity { Name = "Dark Cosmic Jhin", ChampionForeignKey = hecarim.Id, Description = "In the depths of the universe, serial killer Jhin has found a new form of power in cosmic darkness. With his galaxy mask and strange synergy with the four elements of space, he's never been deadlier.", Icon = "empty", Price = 1820, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
SkinEntity kaiSaPrestige = new SkinEntity { Name = "K/DA Kai'Sa Prestige Edition", ChampionForeignKey = nasus.Id, Description = "Kai'Sa, the hottest K-pop star of the moment, knows that to make a sensation, you have to be willing to do anything. With her dazzling outfit and electrifying dance moves, she'll make waves on stage and on the battlefield.", Icon = "empty", Price = 2000, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
SkinEntity pykeProject = new SkinEntity { Name = "PROJECT: Pyke", ChampionForeignKey = ashe.Id, Description = "Pyke, the ultimate android assassin, has recently been upgraded to carry out the most complex missions. With his new tools and enhanced programming, he can sneak into any security system and eliminate any target.", Icon = "empty", Price = 1350, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
context.AddRange(darkJhin, kaiSaPrestige, pykeProject);
// Skills
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = hecarim.Id };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = ashe.Id };
context.AddRange(yasuoTempest, LuxFinal);
// Runes
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
context.AddRange(conqueror, ravenousHunter);

@ -1,10 +1,6 @@
using System;
using System.Collections.Generic;
using MyFlib.Entities;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
{
@ -14,7 +10,7 @@ namespace MyFlib
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public Guid Id { get; set; }
[Required]
[MaxLength(64)]
[MaxLength(64, ErrorMessage = "the champion name must not exceed 64 characters")]
public string Name { get; set; }
[Required]
[MaxLength(255)]
@ -22,9 +18,10 @@ namespace MyFlib
public string Icon { get; set; }
[Required]
public ChampionClassEntity Class { get; set; }
public ICollection<SkillEntity> Skills { get; set; }
public ICollection<SkinEntity> Skins { get; set; }
public ICollection<SkillEntity> Skills { get; set; } = new List<SkillEntity>();
public ICollection<SkinEntity> Skins { get; set; } = new List<SkinEntity>();
public ICollection<CharacteristicEntity> Characteristics { get; set; }
public ICollection<RunePageEntity> RunePages { get; set; } = new List<RunePageEntity>();
public LargeImageEntity Image { get; set; }
[ForeignKey("Image")]

@ -0,0 +1,21 @@
using System.ComponentModel.DataAnnotations.Schema;
using System.ComponentModel.DataAnnotations;
namespace MyFlib.Entities
{
public class CharacteristicEntity
{
[Key]
[MaxLength(254)]
public string Name { get; set; }
[Required]
public int Value { get; set; }
[Required]
public Guid ChampionForeignKey { get; set; }
[ForeignKey("ChampionForeignKey")]
public ChampionEntity Champion { get; set; }
}
}

@ -0,0 +1,20 @@
using MyFlib.Entities;
using MyFlib.Entities.enums;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyFlib
{
public class DictionaryCategoryRune
{
public CategoryEntity category { get; set; }
[ForeignKey("RunePageName")]
public RunePageEntity runePage { get; set; }
public string RunePageName { get; set; }
[ForeignKey("RuneName")]
public RuneEntity rune { get; set; }
public string RuneName { get; set; }
}
}

@ -1,9 +1,4 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace MyFlib
{

@ -1,18 +1,13 @@
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
{
public class RuneEntity
{
[Key]
[MaxLength(64)]
[MaxLength(64, ErrorMessage = "the Rune name must not exceed 64 characters")]
public string Name { get; set; }
[Required]
@ -20,6 +15,8 @@ namespace MyFlib
public string Description { get; set; }
[Required]
public RuneFamilyEntity Family { get; set; }
public ICollection<DictionaryCategoryRune> DictionaryCategoryRunes { get; set; }
public string Icon { get; set; }
public LargeImageEntity Image { get; set; }
[ForeignKey("Image")]

@ -1,12 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
namespace MyFlib.Entities
{
public class RunePageEntity
{
[Key]
[MaxLength(64, ErrorMessage = "the RunePage name must not exceed 64 characters")]
public string Name { get; set; }
public ICollection<ChampionEntity> Champions { get; set; }
public ICollection<DictionaryCategoryRune> DictionaryCategoryRunes { get; set; }
}
}

@ -1,16 +1,12 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace MyFlib
{
public class SkillEntity
{
[Key]
[MaxLength(64)]
[MaxLength(64, ErrorMessage = "the Skill name must not exceed 64 characters")]
public string Name { get; set; }
[Required]
@ -20,5 +16,10 @@ namespace MyFlib
[Required]
public SkillTypeEntity Type { get; set; }
[Required]
[ForeignKey("ChampionForeignKey")]
public ChampionEntity Champion { get; set; }
public Guid ChampionForeignKey { get; set; }
}
}

@ -1,25 +1,22 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
{
public class SkinEntity
{
[Key]
[MaxLength(256)]
[MaxLength(254, ErrorMessage = "the Skin name must not exceed 254 characters")]
public string Name { get; set; }
[Required]
[MaxLength(500)]
[MaxLength(1000)]
public string Description { get; set; }
[Required]
public string Icon { get; set; }
[Required]
public float Price { get; set; }
[Required]
[ForeignKey("ChampionForeignKey")]
public ChampionEntity Champion { get; set; }
public Guid ChampionForeignKey { get; set; }
public LargeImageEntity Image { get; set; }

@ -1,12 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib.Entities.enums
namespace MyFlib.Entities.enums
{
enum CategoryEntity
public enum CategoryEntity
{
Major,
Minor1,

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
namespace MyFlib
{
public enum ChampionClassEntity
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib.Entities.enums
namespace MyFlib.Entities.enums
{
public enum RuneFamilyEntity
{

@ -1,10 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
namespace MyFlib
{
public enum SkillTypeEntity
{

@ -1,10 +1,6 @@
using Microsoft.EntityFrameworkCore;
using MyFlib.Entities;
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MyFlib
{
@ -15,6 +11,9 @@ namespace MyFlib
public DbSet<SkillEntity> Skills { get; set; }
public DbSet<SkinEntity> Skins { get; set; }
public DbSet<RuneEntity> Runes { get; set; }
public DbSet<DictionaryCategoryRune> CategoryRunes { get; set; }
public DbSet<RunePageEntity> RunePages { get; set; }
public DbSet<CharacteristicEntity> Characteristic { get; set; }
public LolDbContext()
{ }
@ -38,9 +37,9 @@ namespace MyFlib
//ChampionEntity
modelBuilder.Entity<ChampionEntity>().HasKey(e => e.Id);
modelBuilder.Entity<ChampionEntity>().Property(e => e.Id).ValueGeneratedOnAdd();
modelBuilder.Entity<ChampionEntity>().HasMany(champion => champion.RunePages).WithMany(runePage => runePage.Champions);
ChampionEntity Akali = new ChampionEntity { Id = Guid.Parse("{4422C524-B2CB-43EF-8263-990C3CEA7CAE}"), Name = "Akali", Class = ChampionClassEntity.Assassin, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
ChampionEntity Aatrox = new ChampionEntity { Id = Guid.Parse("{A4F84D92-C20F-4F2D-B3F9-CA00EF556E72}"), Name = "Aatrox", Class = ChampionClassEntity.Fighter, Bio = "", Icon = "", ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") };
ChampionEntity Ahri = new ChampionEntity { Id = Guid.Parse("{AE5FE535-F041-445E-B570-28B75BC78CB9}"), Name = "Ahri", Class = ChampionClassEntity.Mage, Bio = "", Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
@ -52,9 +51,14 @@ namespace MyFlib
modelBuilder.Entity<ChampionEntity>().HasData(Akali, Aatrox, Ahri, Akshan, Bard, Alistar);
//SkillEntity
modelBuilder.Entity<SkillEntity>()
.HasOne(m => m.Champion)
.WithMany(a => a.Skills)
.HasForeignKey("ChampionForeignKey");
modelBuilder.Entity<SkillEntity>().HasData(
new { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic },
new { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate }
new { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{4422C524-B2CB-43EF-8263-990C3CEA7CAE}") },
new { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{3708dcfd-02a1-491e-b4f7-e75bf274cf23}") }
);
//SkinEntity
@ -69,9 +73,63 @@ namespace MyFlib
);
//RuneEntity
modelBuilder.Entity<RuneEntity>().HasData(
new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") },
new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") }
RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity runeManaflow = new RuneEntity { Name = "Manaflow Band ", Description = "Hitting enemy champions with a spell grants 25 maximum mana, up to 250 mana.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{9f9086f5-5cc5-47b5-af9b-a935f4e9b89c}") };
modelBuilder.Entity<RuneEntity>().HasData(runeHextech, runeManaflow);
//RunePageEntity
RunePageEntity page1 = new RunePageEntity { Name = "Page 1" };
RunePageEntity page2 = new RunePageEntity { Name = "Page 2" };
modelBuilder.Entity<RunePageEntity>().HasData(page1, page2);
//DictionaryCategoryRune
modelBuilder.Entity<DictionaryCategoryRune>().HasKey(dictionary => new { dictionary.RunePageName, dictionary.RuneName });
modelBuilder.Entity<DictionaryCategoryRune>().HasData(
new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name },
new DictionaryCategoryRune { category = CategoryEntity.Minor1, RuneName = runeManaflow.Name, RunePageName = page1.Name },
new DictionaryCategoryRune { category = CategoryEntity.OtherMinor1, RuneName = runeManaflow.Name, RunePageName = page2.Name },
new DictionaryCategoryRune { category = CategoryEntity.OtherMinor2, RuneName = runeHextech.Name, RunePageName = page2.Name }
);
//CharacteristicEntity
modelBuilder.Entity<CharacteristicEntity>().HasKey(c => new { c.Name, c.ChampionForeignKey });
modelBuilder.Entity<CharacteristicEntity>().HasData(
new CharacteristicEntity { Name = "Attack Damage", Value = 58, ChampionForeignKey = Ahri.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 92, ChampionForeignKey = Ahri.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 6, ChampionForeignKey = Ahri.Id },
new CharacteristicEntity { Name = "Health", Value = 526, ChampionForeignKey = Ahri.Id },
new CharacteristicEntity { Name = "Mana", Value = 418, ChampionForeignKey = Ahri.Id },
new CharacteristicEntity { Name = "Attack Damage", Value = 68, ChampionForeignKey = Akshan.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Akshan.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Akshan.Id },
new CharacteristicEntity { Name = "Health", Value = 570, ChampionForeignKey = Akshan.Id },
new CharacteristicEntity { Name = "Mana", Value = 350, ChampionForeignKey = Akshan.Id },
new CharacteristicEntity { Name = "Attack Damage", Value = 70, ChampionForeignKey = Aatrox.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Aatrox.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Aatrox.Id },
new CharacteristicEntity { Name = "Health", Value = 580, ChampionForeignKey = Aatrox.Id },
new CharacteristicEntity { Name = "Mana", Value = 0, ChampionForeignKey = Aatrox.Id },
new CharacteristicEntity { Name = "Attack Damage", Value = 56, ChampionForeignKey = Akali.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Akali.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Akali.Id },
new CharacteristicEntity { Name = "Health", Value = 575, ChampionForeignKey = Akali.Id },
new CharacteristicEntity { Name = "Mana", Value = 200, ChampionForeignKey = Akali.Id },
new CharacteristicEntity { Name = "Attack Damage", Value = 63, ChampionForeignKey = Alistar.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 0, ChampionForeignKey = Alistar.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 2, ChampionForeignKey = Alistar.Id },
new CharacteristicEntity { Name = "Health", Value = 573, ChampionForeignKey = Alistar.Id },
new CharacteristicEntity { Name = "Mana", Value = 278, ChampionForeignKey = Alistar.Id },
new CharacteristicEntity { Name = "Ability Power", Value = 30, ChampionForeignKey = Bard.Id },
new CharacteristicEntity { Name = "Attack Speed", Value = 1, ChampionForeignKey = Bard.Id },
new CharacteristicEntity { Name = "Health", Value = 535, ChampionForeignKey = Bard.Id },
new CharacteristicEntity { Name = "Mana", Value = 350, ChampionForeignKey = Bard.Id }
);
}

@ -5,7 +5,7 @@ using static System.Console;
using (var context = new LolDbContext())
{
WriteLine("\nChampions :\n");
WriteLine("Champions :\n");
foreach (var c in context.Champions)
{
@ -18,10 +18,6 @@ using (var context = new LolDbContext())
foreach (var c in context.Champions)
{
WriteLine($"{c.Name} - {c.Class}");
/* foreach (var s in c.Skills)
{
WriteLine($"\t\t{s.Name} - {s.Description}");
}*/
}
WriteLine("\nSkills :\n");
@ -38,7 +34,5 @@ using (var context = new LolDbContext())
WriteLine($"{c.Name} - {c.Description} - Price: {c.Price} - ChampionId: {c.ChampionForeignKey}");
}
WriteLine("\nRunes :\n");
context.SaveChangesAsync(); // or context.SaveChangesAsync
}

@ -0,0 +1,82 @@
using Microsoft.EntityFrameworkCore;
using MyFlib;
using MyFlib.Entities;
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UT_EF
{
public class RunePagesTest
{
[Fact]
public void TestAdd()
{
var options = new DbContextOptionsBuilder<LolDbContext>()
.UseInMemoryDatabase(databaseName: "Add_Test_RunePage_database")
.Options;
using (var context = new LolDbContext(options))
{
RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RunePageEntity page1 = new RunePageEntity { Name = "Page 1" };
RunePageEntity page2 = new RunePageEntity { Name = "Page 2" };
DictionaryCategoryRune dictionary = new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name };
context.CategoryRunes.Add(dictionary);
context.RunePages.AddRange(page1, page2);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
Assert.Equal(2, context.RunePages.Count());
Assert.Equal("Page 1", context.RunePages.First().Name);
}
}
[Fact]
public void Delete_Test()
{
var options = new DbContextOptionsBuilder<LolDbContext>()
.UseInMemoryDatabase(databaseName: "Delete_Test_RunePage_database")
.Options;
using (var context = new LolDbContext(options))
{
RuneEntity runeHextech = new RuneEntity { Name = "Hextech Flashtraption ", Description = "While Flash is on cooldown, it is replaced by Hexflash.", Family = RuneFamilyEntity.Unknown, ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RunePageEntity page1 = new RunePageEntity { Name = "Page 1" };
RunePageEntity page2 = new RunePageEntity { Name = "Page 2" };
DictionaryCategoryRune dictionary = new DictionaryCategoryRune { category = CategoryEntity.Major, RuneName = runeHextech.Name, RunePageName = page1.Name };
context.CategoryRunes.Add(dictionary);
context.RunePages.AddRange(page1, page2);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
var ewok = context.RunePages.First();
string nameToFind = "1";
Assert.Equal(1, context.RunePages.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
Assert.Equal(2, context.RunePages.Count());
context.RunePages.Remove(ewok);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
string nameToFind = "1";
Assert.Equal(0, context.RunePages.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
Assert.Equal(1, context.RunePages.Count());
}
}
}
}

@ -0,0 +1,121 @@
using Microsoft.EntityFrameworkCore;
using MyFlib;
using MyFlib.Entities.enums;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace UT_EF
{
public class RunesTest
{
[Fact]
public void TestAdd()
{
var options = new DbContextOptionsBuilder<LolDbContext>()
.UseInMemoryDatabase(databaseName: "Add_Test_Rune_database")
.Options;
using (var context = new LolDbContext(options))
{
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") };
RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") };
context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
Assert.Equal(4, context.Runes.Count());
Assert.Equal("Conqueror", context.Runes.First().Name);
}
}
[Fact]
public void Modify_Test()
{
var options = new DbContextOptionsBuilder<LolDbContext>()
.UseInMemoryDatabase(databaseName: "Modify_Test_Rune_database")
.Options;
using (var context = new LolDbContext(options))
{
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") };
RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") };
context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
string bioToFind = "stacks";
RuneFamilyEntity type = RuneFamilyEntity.Domination;
Assert.Equal(2, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count());
Assert.Equal(2, context.Runes.Where(c => c.Family == type).Count());
bioToFind = "dealing damage";
Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count());
var ewok = context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).First();
ewok.Description = "Rune resist";
ewok.Family = type;
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
string bioToFind = "stacks";
Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count());
bioToFind = "rune resist";
RuneFamilyEntity type = RuneFamilyEntity.Domination;
Assert.Equal(1, context.Runes.Where(c => c.Description.ToLower().Contains(bioToFind)).Count());
Assert.Equal(3, context.Runes.Where(c => c.Family == type).Count());
}
}
[Fact]
public void Delete_Test()
{
var options = new DbContextOptionsBuilder<LolDbContext>()
.UseInMemoryDatabase(databaseName: "Delete_Test_Rune_database")
.Options;
using (var context = new LolDbContext(options))
{
RuneEntity conqueror = new RuneEntity { Name = "Conqueror", Description = "by dealing damage to an enemy champion, you accumulate stacks that, once fully stacked, increase your damage and provide you with healing.", Family = RuneFamilyEntity.Unknown, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity ravenousHunter = new RuneEntity { Name = "Ravenous Hunter", Description = "killing minions, monsters, or enemy champions grants you stacks of Ravenous Hunter, which increase your damage against enemy champions and provide you with healing.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{8d121cdc-6787-4738-8edd-9e026ac16b65}") };
RuneEntity electrocute = new RuneEntity { Name = "Electrocute", Description = "hitting an enemy champion with 3 separate attacks or abilities within 3 seconds deals bonus damage.", Family = RuneFamilyEntity.Domination, Icon = "", ImageId = Guid.Parse("{e7c87f12-2c7b-44d5-8867-eba1ae5a4657}") };
RuneEntity pressTheAttack = new RuneEntity { Name = "Press the Attack", Description = "hitting an enemy champion with 3 consecutive basic attacks deals bonus damage and makes them take increased damage from all sources for a short period of time.", Family = RuneFamilyEntity.Precision, Icon = "", ImageId = Guid.Parse("{7c354729-5ecf-43d8-ae73-153740e87644}") };
context.Runes.AddRange(conqueror, ravenousHunter, electrocute, pressTheAttack);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
var ewok = context.Runes.First();
string nameToFind = "conqueror";
Assert.Equal(1, context.Runes.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
Assert.Equal(4, context.Runes.Count());
context.Runes.Remove(ewok);
context.SaveChanges();
}
using (var context = new LolDbContext(options))
{
string nameToFind = "conqueror";
Assert.Equal(0, context.Runes.Where(c => c.Name.ToLower().Contains(nameToFind)).Count());
Assert.Equal(3, context.Runes.Count());
}
}
}
}

@ -19,10 +19,10 @@ namespace UT_EF
using (var context = new LolDbContext(options))
{
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate };
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal);
context.SaveChanges();
@ -44,10 +44,10 @@ namespace UT_EF
using (var context = new LolDbContext(options))
{
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Unknown };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate };
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal);
context.SaveChanges();
@ -87,10 +87,10 @@ namespace UT_EF
using (var context = new LolDbContext(options))
{
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate };
SkillEntity fireBall = new SkillEntity { Name = "Boule de feu", Description = "Fire!", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{234F5E7F-F196-4C88-AD1C-6C392AA2E038}") };
SkillEntity whiteStar = new SkillEntity { Name = "White Star", Description = "Random damage", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{15E0C4F4-4C04-4CCE-8F4D-78F37F63E63F}") };
SkillEntity yasuoTempest = new SkillEntity { Name = "Yasuo's Steel Tempest", Description = " une attaque de mêlée qui peut être chargée pour infliger des dégâts supplémentaires et projeter les ennemis dans les airs.", Type = SkillTypeEntity.Basic, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
SkillEntity LuxFinal = new SkillEntity { Name = "Lux's Final Spark", Description = "une attaque à distance qui inflige des dégâts massifs dans une direction.", Type = SkillTypeEntity.Ultimate, ChampionForeignKey = Guid.Parse("{F32FA768-A1DC-4F6A-9366-FFEC6B0D4159}") };
context.Skills.AddRange(fireBall, whiteStar, yasuoTempest, LuxFinal);
context.SaveChanges();

Loading…
Cancel
Save