avancement
continuous-integration/drone/push Build is failing Details

master
Jolys Enzo 2 years ago
parent 140b06719d
commit eb4fb9c92f

@ -8,7 +8,30 @@ namespace Api_lol.Factories
{
public static Champion DtoToModel(this DtoChampions champDto)
{
return new Champion(champDto.name);
ChampionClass classe = ChampionClass.Unknown;
switch (champDto.classe)
{
case "Assassin":
classe = ChampionClass.Assassin;
break;
case "Fighter":
classe = ChampionClass.Fighter;
break;
case "Mage":
classe = ChampionClass.Mage;
break;
case "Support":
classe = ChampionClass.Support;
break;
case "Tank":
classe = ChampionClass.Tank;
break;
}
return new Champion(champDto.name,champClass:classe,icon:champDto.icon,bio:champDto.bio,image:champDto.image);
}
public static DtoChampions ModelToDto(this Champion champ)

@ -14,5 +14,7 @@ namespace DTO
public string bio { get; set; }
public string icon { get; set; }
public string image { get; set; }
}
}

@ -6,7 +6,7 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
namespace EntityFramwork
{
public class EntityChampions
{

@ -1,11 +1,15 @@
using DTO;
using Model;
using static System.Net.Mime.MediaTypeNames;
using System.Threading.Tasks;
namespace EntityFramwork.Factories
{
public class Factories
public static class Factories
{
public EntityChampions ChampionModelToEntity(Champion champ)
// Factorie Champion
public static EntityChampions ChampionModelToEntity(this Champion champ)
{
EntityChampions entity = new EntityChampions();
@ -17,7 +21,42 @@ namespace EntityFramwork.Factories
return entity;
}
public EntitySkins SkinsModelToEntity(Skin skin,int id)
public static Champion EntityChampionToModele(this EntityChampions entity)
{
ChampionClass classe = ChampionClass.Unknown;
switch (entity.Classe)
{
case "Assassin":
classe = ChampionClass.Assassin;
break;
case "Fighter":
classe = ChampionClass.Fighter;
break;
case "Mage":
classe = ChampionClass.Mage;
break;
case "Support":
classe = ChampionClass.Support;
break;
case "Tank":
classe = ChampionClass.Tank;
break;
}
// Attention l'image !!
return new Champion(entity.Name,champClass:classe,icon:entity.Icon,bio:entity.Bio);
}
public
// Skins
public static EntitySkins SkinsModelToEntity(this Skin skin,int id)
{
EntitySkins entity= new EntitySkins();
@ -31,7 +70,7 @@ namespace EntityFramwork.Factories
}
public EntityRunes RuneModelToEntity(Rune rune)
public static EntityRunes RuneModelToEntity(this Rune rune)
{
EntityRunes entity = new EntityRunes();
@ -43,7 +82,7 @@ namespace EntityFramwork.Factories
return entity;
}
public EntitySkill SkillModeleToEntity(Skill skill,int championId)
public static EntitySkill SkillModeleToEntity(this Skill skill,int championId)
{
EntitySkill entity = new EntitySkill();

@ -1,27 +1,63 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using EntityFramwork.Factories;
using Model;
namespace EntityFramwork.Manager
{
public class ManagerChampion : IChampionsManager
{
public Task<Champion?> AddItem(Champion? item)
{
throw new NotImplementedException();
try
{
using (BDDContext db = new BDDContext())
{
db.Champions.Add(item.ChampionModelToEntity());
db.SaveChanges();
}
}
catch (Exception ex)
{
return Task.FromResult<Champion?>(null);
}
return Task.FromResult<Champion?>(item);
}
public Task<bool> DeleteItem(Champion? item)
{
throw new NotImplementedException();
if(item == null)
{
return Task.FromResult(false);
}
using (BDDContext db = new BDDContext())
{
EntityChampions ?entityChamp = db.Champions.Where(e => e.Name == item.Name).FirstOrDefault();
if ( entityChamp == null)
{
return Task.FromResult(false);
}
db.Champions.Remove(entityChamp);
db.SaveChanges();
}
return Task.FromResult(true);
}
public Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{
throw new NotImplementedException();
IEnumerable<Champion?> items = new List<Champion>();
using (BDDContext db = new BDDContext())
{
if ( descending == false)
{
items = db.Champions.Skip(index).Take(count).OrderBy(e => e.Name).Select(e => e.EntityChampionToModele());
}
else
{
items = db.Champions.Skip(index).Take(count).OrderByDescending(e => e.Name).Select(e => e.EntityChampionToModele());
}
}
return Task.FromResult<IEnumerable<Champion?>>(items);
}
public Task<IEnumerable<Champion?>> GetItemsByCharacteristic(string charName, int index, int count, string? orderingPropertyName = null, bool descending = false)

@ -9,6 +9,49 @@ namespace EntityFramwork.Manager
{
public class ManagerSkins : ISkinsManager
{
public Task<Skin?> AddItem(Skin? item)
{
throw new NotImplementedException();
}
public Task<bool> DeleteItem(Skin? item)
{
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();
}
}
}

@ -6,12 +6,15 @@ namespace RelationApi
public class Relation : IDataManager
{
private readonly string ipApi = "https://localhost:7081/";
static HttpClient http = new HttpClient();
public Relation()
{
ChampionsMgr = new RelationChampion();
SkinsMgr = new RelationSkins();
RunesMgr = new RelationRune();
RunePagesMgr = new RelationRunePage();
ChampionsMgr = new RelationChampion(ipApi,http);
SkinsMgr = new RelationSkins(ipApi,http);
RunesMgr = new RelationRune(ipApi,http);
RunePagesMgr = new RelationRunePage(ipApi,http);
}
public IChampionsManager ChampionsMgr { get; }

@ -6,4 +6,8 @@
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\..\SourcesMobileApp\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -2,17 +2,27 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Http.Json;
using System.Text;
using System.Threading.Tasks;
using static System.Net.WebRequestMethods;
namespace RelationApi
{
public class RelationChampion : IChampionsManager
{
private readonly string IpApi;
private readonly HttpClient _httpClient;
public Task<Champion?> AddItem(Champion? item)
public RelationChampion(string ipApi,HttpClient http)
{
throw new NotImplementedException();
IpApi = ipApi;
_httpClient = http;
}
public async Task<Champion?> AddItem(Champion? item)
{
HttpResponseMessage response = await _httpClient.PostAsJsonAsync();
}
public Task<bool> DeleteItem(Champion? item)

@ -9,6 +9,15 @@ namespace RelationApi
{
public class RelationRune : IRunesManager
{
private readonly string IpApi;
private readonly HttpClient _httpClient;
public RelationRune(string ipApi, HttpClient http)
{
IpApi = ipApi;
_httpClient = http;
}
public Task<Model.Rune?> AddItem(Model.Rune? item)
{
throw new NotImplementedException();

@ -9,6 +9,15 @@ namespace RelationApi
{
internal class RelationRunePage : IRunePagesManager
{
private readonly string IpApi;
private readonly HttpClient _httpClient;
public RelationRunePage(string ipApi, HttpClient http)
{
IpApi = ipApi;
_httpClient = http;
}
public Task<RunePage?> AddItem(RunePage? item)
{
throw new NotImplementedException();

@ -9,6 +9,15 @@ namespace RelationApi
{
public class RelationSkins : ISkinsManager
{
private readonly string IpApi;
private readonly HttpClient _httpClient;
public RelationSkins(string ipApi, HttpClient http)
{
IpApi = ipApi;
_httpClient = http;
}
public Task<Skin?> AddItem(Skin? item)
{
throw new NotImplementedException();

Loading…
Cancel
Save