Arthur_ConnectionString #4

Merged
arthur.valin merged 3 commits from Arthur_ConnectionString into master 2 years ago

@ -14,6 +14,7 @@
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Business\Business.csproj" />
<ProjectReference Include="..\DTO\DTO.csproj" /> <ProjectReference Include="..\DTO\DTO.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" /> <ProjectReference Include="..\Entities\Entities.csproj" />
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />

@ -4,7 +4,6 @@ using DTO;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Model; using Model;
using StubLib; using StubLib;
using System.Text.Json;
using System.Xml.Linq; using System.Xml.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@ -43,9 +42,9 @@ namespace API_LoL_Project.Controllers
return BadRequest("No chamions found with Id "); return BadRequest("No chamions found with Id ");
} }
_logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);; _logger.LogInformation("Executing {Action} with parameters: {Parameters}", nameof(Get), request);;
var champions = await dataManager.GetItems(request.PageNumber, totalcount, request.orderingPropertyName, (request.descending == null ? false : (bool)request.descending)); var champions = await dataManager.GetItems(request.index, request.count, request.orderingPropertyName, request.descending);
IEnumerable<ChampionDTO> res = champions.Select(c => c.toDTO()); IEnumerable<ChampionDTO> res = champions.Select(c => c.ToDTO());
if (res.Count() >= 0 || res == null) if (res.Count() <= 0 || res == null)
{ {
_logger.LogWarning("No chamions found with Id"); _logger.LogWarning("No chamions found with Id");
return BadRequest("No chamions found with Id "); return BadRequest("No chamions found with Id ");
@ -73,7 +72,7 @@ namespace API_LoL_Project.Controllers
var champion = await dataManager var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems()); .GetItemsByName(name, 0, await dataManager.GetNbItems());
_logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name); _logger.LogInformation("Executing {Action} with name : {championName}", nameof(GetChampionsByName), name);
ChampionDTO res = champion.First().toDTO(); ChampionDTO res = champion.First().ToDTO();
if (res == null) if (res == null)
{ {
_logger.LogWarning("No chamions found with {name}", name); ; _logger.LogWarning("No chamions found with {name}", name); ;
@ -96,7 +95,7 @@ namespace API_LoL_Project.Controllers
{ {
try try
{ {
var newChampion = value.toModel(); var newChampion = value.ToModel();
await dataManager.AddItem(newChampion); await dataManager.AddItem(newChampion);
return CreatedAtAction(nameof(Get), newChampion) ; return CreatedAtAction(nameof(Get), newChampion) ;
} }
@ -118,7 +117,7 @@ namespace API_LoL_Project.Controllers
{ {
var champion = await dataManager var champion = await dataManager
.GetItemsByName(name, 0, await dataManager.GetNbItems()); .GetItemsByName(name, 0, await dataManager.GetNbItems());
await dataManager.UpdateItem(champion.First(), value.toModel()); await dataManager.UpdateItem(champion.First(), value.ToModel());
return Ok(); return Ok();
} }
catch(Exception e) catch(Exception e)

@ -2,28 +2,9 @@
{ {
public class PageRequest public class PageRequest
{ {
//max leght
public string? orderingPropertyName { get; set; } = null; public string? orderingPropertyName { get; set; } = null;
public bool? descending { get; set; } = false; public bool descending { get; set; } = false;
const int maxPageSize = 50;
public int PageNumber { get; set; } = 1;
public int index { get; set; } = 1; public int index { get; set; } = 1;
public int count { get; set; } = 1; public int count { get; set; } = 1;
//max lentght
private int _pageSize;
public int PageSize
{
get
{
return _pageSize;
}
set
{
_pageSize = (value > maxPageSize) ? maxPageSize : value;
}
}
} }
} }

@ -12,7 +12,7 @@ namespace API_LoL_Project.Controllers
[ApiController] [ApiController]
public class RuneController : ControllerBase public class RuneController : ControllerBase
{ {
public IRunesManager runesManager; /*public IRunesManager runesManager;
// you should create a custom logger to be prety // you should create a custom logger to be prety
private readonly ILogger<RuneController> _logger; private readonly ILogger<RuneController> _logger;
@ -26,7 +26,7 @@ namespace API_LoL_Project.Controllers
/*// GET: api/<RuneController> *//*// GET: api/<RuneController>
[HttpGet] [HttpGet]
public async Task<IEnumerable<RuneDTO>> Get() public async Task<IEnumerable<RuneDTO>> Get()
{ {
@ -42,7 +42,7 @@ namespace API_LoL_Project.Controllers
return BadRequest(e.Message); return BadRequest(e.Message);
} }
}*/ }*//*
// GET: api/<RuneController> // GET: api/<RuneController>
[HttpGet] [HttpGet]
@ -127,6 +127,6 @@ namespace API_LoL_Project.Controllers
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {
} }*/
} }
} }

@ -1,4 +1,5 @@
using Microsoft.AspNetCore.Mvc; using DTO;
using Microsoft.AspNetCore.Mvc;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860 // For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
@ -8,7 +9,7 @@ namespace API_LoL_Project.Controllers
[ApiController] [ApiController]
public class RunePageController : ControllerBase public class RunePageController : ControllerBase
{ {
// GET: api/<RunePageController> /* // GET: api/<RunePageController>
[HttpGet] [HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request) public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{ {
@ -65,6 +66,6 @@ namespace API_LoL_Project.Controllers
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {
} }*/
} }
} }

@ -8,7 +8,7 @@ namespace API_LoL_Project.Controllers
[ApiController] [ApiController]
public class SkillController : ControllerBase public class SkillController : ControllerBase
{ {
// GET: api/<SkillController> /* // GET: api/<SkillController>
[HttpGet] [HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request) public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{ {
@ -65,6 +65,6 @@ namespace API_LoL_Project.Controllers
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {
} }*/
} }
} }

@ -8,7 +8,7 @@ namespace API_LoL_Project.Controllers
[ApiController] [ApiController]
public class SkinController : ControllerBase public class SkinController : ControllerBase
{ {
// GET: api/<SkinController> /* // GET: api/<SkinController>
[HttpGet] [HttpGet]
public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request) public async Task<ActionResult<IEnumerable<RuneDTO>>> Get([FromQuery] Request.PageRequest request)
{ {
@ -65,6 +65,6 @@ namespace API_LoL_Project.Controllers
[HttpDelete("{id}")] [HttpDelete("{id}")]
public void Delete(int id) public void Delete(int id)
{ {
} }*/
} }
} }

@ -43,10 +43,9 @@ namespace API_LoL_Project.Mapper
{ {
Name = item.Name, Name = item.Name,
Bio = item.Bio, Bio = item.Bio,
Characteristics = item.Characteristics,
skills = item.Skills, skills = item.Skills,
skins = item.Skins, skins = item.Skins,
LargeImage = item.Image LargeImage = item.Image.Base64
}; };

@ -1,27 +1,31 @@
namespace API_LoL_Project.Mapper namespace API_LoL_Project.Mapper
{ {
using DTO; using DTO;
using Entities;
using Model; using Model;
namespace API_LoL_Project.Mapper namespace API_LoL_Project.Mapper
{ {
public static class RuneMapper public static class RuneMapper
{ {
public static RuneEntity ToEntity(this Rune item) public static RuneDTO ToDTO(this Rune item)
{ {
throw new NotImplementedException();
}
return new RuneDTO()
{
Name = item.Name,
Family = item.Family,
};
}
public static Rune ToModel(this RuneEntity entity) public static Rune ToModel(this RuneDTO dto)
{ {
throw new NotImplementedException(); /*if (dto == null)
{
*//* var message = string.Format("Champion with name = {} not found", dto.Name);
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));*//*
}*/
return new Rune(dto.Name, dto.Family);
} }
} }
} }
} }
}

@ -5,15 +5,6 @@ namespace API_LoL_Project.Mapper
{ {
public static class RunePageMapper public static class RunePageMapper
{ {
public static RunePageEntity ToEntity(this RunePage item)
{
throw new NotImplementedException();
}
public static RunePage ToModel(this RunePageEntity entity)
{
throw new NotImplementedException();
}
} }
} }

@ -1,29 +0,0 @@
using DTO;
using Model;
namespace API_LoL_Project.Mapper
{
public static class RunesMappeur
{
public static RuneDTO toDTO(this Rune item)
{
return new RuneDTO()
{
Name = item.Name,
Family = item.Family,
};
}
public static Rune toModel(this RuneDTO dto)
{
/*if (dto == null)
{
*//* var message = string.Format("Champion with name = {} not found", dto.Name);
throw new HttpResponseException(Request.CreateErrorResponse(HttpStatusCode.NotFound, message));*//*
}*/
return new Rune(dto.Name, dto.Family);
}
}
}

@ -6,18 +6,8 @@ namespace API_LoL_Project.Mapper
{ {
public static class SkinMapper public static class SkinMapper
{ {
public static SkinEntity ToEntity(this Skin item)
{
throw new NotImplementedException();
}
public static Skin ToModel(this SkinEntity entity)
{
throw new NotImplementedException();
}
} }
} }
}

@ -1,31 +1,38 @@
using Business;
using Entities;
using Microsoft.EntityFrameworkCore;
using Model; using Model;
using StubLib; using StubLib;
var builder = WebApplication.CreateBuilder(args); var builder = WebApplication.CreateBuilder(args);
// Add services to the container. var connectionString = builder.Configuration.GetConnectionString("LolDatabase");
builder.Services.AddDbContext<LolDbContext>(options =>
builder.Services.AddControllers(); options.UseSqlite(connectionString), ServiceLifetime.Singleton);
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer(); builder.Services.AddControllers();
builder.Services.AddSwaggerGen(); builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.AddSingleton<IDataManager, StubData>();
var app = builder.Build(); builder.Services.AddSingleton<IDataManager, DbData>();
//builder.Services.AddSingleton<IDataManager, StubData>();
// Configure the HTTP request pipeline. var app = builder.Build();
if (app.Environment.IsDevelopment())
{ app?.Services?.GetService<LolDbContext>()?.Database.EnsureCreated();
app.UseSwagger();
app.UseSwaggerUI(); // Configure the HTTP request pipeline.
} if (app.Environment.IsDevelopment())
{
app.UseHttpsRedirection(); app.UseSwagger();
app.UseSwaggerUI();
app.UseAuthorization(); }
app.MapControllers(); app.UseHttpsRedirection();
app.UseAuthorization();
app.Run();
app.MapControllers();
app.Run();

@ -4,5 +4,8 @@
"Default": "Information", "Default": "Information",
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
},
"ConnectionStrings": {
"LolDatabase": "Data Source=Entities.LolDatabase.db"
} }
} }

@ -0,0 +1,11 @@
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"ConnectionStrings": {
"LolDatabase": "Data Source=Entities.LolDatabase.db"
}
}

@ -5,5 +5,8 @@
"Microsoft.AspNetCore": "Warning" "Microsoft.AspNetCore": "Warning"
} }
}, },
"ConnectionStrings": {
"LolDatabase": "Data Source=Entities.LolDatabase.db"
},
"AllowedHosts": "*" "AllowedHosts": "*"
} }

@ -7,8 +7,8 @@
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\API_LoL_Project\API_LoL_Project.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" /> <ProjectReference Include="..\Entities\Entities.csproj" />
<ProjectReference Include="..\EntityMappers\EntityMappers.csproj" />
<ProjectReference Include="..\Model\Model.csproj" /> <ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup> </ItemGroup>

@ -1,7 +1,6 @@
using API_LoL_Project.Mapper; using EntityMapper;
using Model; using Model;
using Shared; using Shared;
using System.Data.SqlTypes;
namespace Business namespace Business
{ {
@ -28,6 +27,7 @@ namespace Business
public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false) public async Task<IEnumerable<Champion?>> GetItems(int index, int count, string? orderingPropertyName = null, bool descending = false)
{ {
Console.WriteLine("GET");
return parent.DbContext.champions.GetItemsWithFilterAndOrdering( return parent.DbContext.champions.GetItemsWithFilterAndOrdering(
c => true, c => true,
index, count, index, count,

@ -1,7 +1,5 @@
using API_LoL_Project.Mapper; using EntityMapper;
using Model; using Model;
using System.Data.SqlTypes;
using System.Linq;
namespace Business namespace Business
{ {

@ -1,5 +1,4 @@
using API_LoL_Project.Mapper; using EntityMapper;
using API_LoL_Project.Mapper.API_LoL_Project.Mapper;
using Model; using Model;
using Shared; using Shared;

@ -1,7 +1,5 @@
using API_LoL_Project.Mapper; using EntityMapper;
using API_LoL_Project.Mapper.API_LoL_Project.Mapper;
using Model; using Model;
using System.Data.SqlTypes;
namespace Business namespace Business
{ {

@ -6,7 +6,6 @@ namespace Business
{ {
public partial class DbData : IDataManager public partial class DbData : IDataManager
{ {
public DbData(LolDbContext dbContext) public DbData(LolDbContext dbContext)
{ {
DbContext = dbContext; DbContext = dbContext;
@ -15,6 +14,7 @@ namespace Business
RunesMgr = new RunesManager(this); RunesMgr = new RunesManager(this);
RunePagesMgr = new RunePagesManager(this); RunePagesMgr = new RunePagesManager(this);
} }
protected LolDbContext DbContext{ get; } protected LolDbContext DbContext{ get; }
public IChampionsManager ChampionsMgr { get; } public IChampionsManager ChampionsMgr { get; }

@ -22,7 +22,7 @@ namespace Business
: temp.OrderBy(item => prop.GetValue(item)); : temp.OrderBy(item => prop.GetValue(item));
} }
} }
return temp.Skip(index * count).Take(count) return temp.Skip(index * count).Take(count);
} }
} }
} }

@ -1,4 +1,5 @@
using Model; using Model;
using System.Buffers.Text;
namespace DTO namespace DTO
{ {
@ -14,7 +15,7 @@ namespace DTO
public string Name { get; set; } public string Name { get; set; }
public string Bio { get; set; } public string Bio { get; set; }
public string Characteristics { get; set; } public string Characteristics { get; set; }
public byte[] LargeImage { get; set; } public string LargeImage { get; set; }
public IEnumerable<Skin> skins { get; set; } public IEnumerable<Skin> skins { get; set; }
public IEnumerable<Skill> skills { get; set; } public IEnumerable<Skill> skills { get; set; }

@ -1,4 +1,5 @@
using Model; using Model;
using Shared;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;

@ -1,4 +1,5 @@
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Shared; using Shared;
using System.Reflection.Metadata; using System.Reflection.Metadata;
using System.Security.Claims; using System.Security.Claims;
@ -15,11 +16,14 @@ namespace Entities
public DbSet<RuneEntity> runes { get; set; } public DbSet<RuneEntity> runes { get; set; }
public DbSet<RunePageEntity> runepages { get; set; } public DbSet<RunePageEntity> runepages { get; set; }
public DbSet<LargeImageEntity> largeimages { get; set; } public DbSet<LargeImageEntity> largeimages { get; set; }
public LolDbContext(DbContextOptions configuration) : base(configuration){}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder) protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{ {
optionsBuilder.UseSqlite($"Data Source=Entities.Champions.db"); if (!optionsBuilder.IsConfigured) {
Console.WriteLine("!IsConfigured...");
optionsBuilder.UseSqlite($"Data Source=Entities.Champions.db");
}
} }
protected override void OnModelCreating(ModelBuilder modelBuilder) protected override void OnModelCreating(ModelBuilder modelBuilder)

@ -7,7 +7,7 @@ ChampionEntity imri = new()
Bio = "Fou Furieux", Bio = "Fou Furieux",
Class = ChampionClass.Assassin Class = ChampionClass.Assassin
}; };
using (var context = new LolDbContext()) using (var context = new LolDbContext(null))
{ {
// Crée des nounours et les insère dans la base // Crée des nounours et les insère dans la base
Console.WriteLine("Creates and inserts new Champion"); Console.WriteLine("Creates and inserts new Champion");

@ -1,19 +0,0 @@
using EntityFramework.Entities;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework.DbContexts
{
internal class ChampionDbContext : DbContext
{
public DbSet<ChampionEntity> champions { get; set; }
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
optionsBuilder.UseSqlite($"Data Source=EntityFramework.Champions.db");
}
}
}

@ -1,17 +0,0 @@
using System.ComponentModel.DataAnnotations;
namespace EntityFramework.Entities
{
internal class ChampionEntity
{
[Key]
[MaxLength(256)]
public string Name { get; set; }
[Required]
[MaxLength(500)]
public string Bio { get; set; }
[Required]
public string Icon { get; set; }
}
}

@ -1,30 +0,0 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<StartWorkingDirectory>$(MSBuildProjectDirectory)</StartWorkingDirectory>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="7.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="7.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>

@ -1,44 +0,0 @@
// <auto-generated />
using EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(ChampionDbContext))]
[Migration("20230201154310_migr")]
partial class migr
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,34 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFramework.Migrations
{
/// <inheritdoc />
public partial class migr : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "champions",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 256, nullable: false),
Bio = table.Column<string>(type: "TEXT", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_champions", x => x.Name);
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "champions");
}
}
}

@ -1,44 +0,0 @@
// <auto-generated />
using EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(ChampionDbContext))]
[Migration("20230209124258_myFirstMigration")]
partial class myFirstMigration
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,22 +0,0 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace EntityFramework.Migrations
{
/// <inheritdoc />
public partial class myFirstMigration : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

@ -1,41 +0,0 @@
// <auto-generated />
using EntityFramework.DbContexts;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(ChampionDbContext))]
partial class ChampionDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.Entities.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(256)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("champions");
});
#pragma warning restore 612, 618
}
}
}

@ -1,17 +0,0 @@
using EntityFramework.DbContexts;
using EntityFramework.Entities;
using Model;
ChampionEntity dave = new ChampionEntity()
{
Name = "Dave",
Bio = "Le meilleur Jazzman de France",
Icon = "aaa"
};
using (var context = new ChampionDbContext())
{
// Crée des nounours et les insère dans la base
Console.WriteLine("Creates and inserts new Champion");
context.Add(dave);
context.SaveChanges();
}

@ -0,0 +1,26 @@
using Entities;
using Model;
namespace EntityMapper
{
public static class ChampionMapper {
public static ChampionEntity ToEntity(this Champion item)
{
return new()
{
Name = item.Name,
Bio = item.Bio,
Icon = item.Icon,
Class = item.Class,
Image = new() { Base64 = item.Image.Base64 },
};
}
public static Champion ToModel(this ChampionEntity entity)
{
return new(entity.Name, entity.Class, entity.Icon, "", entity.Bio);
}
}
}

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

@ -0,0 +1,23 @@
using Entities;
using Model;
namespace EntityMapper
{
public static class RuneMapper
{
public static RuneEntity ToEntity(this Rune item)
{
throw new NotImplementedException();
}
public static Rune ToModel(this RuneEntity entity)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,19 @@
using Entities;
using Model;
namespace EntityMapper
{
public static class RunePageMapper
{
public static RunePageEntity ToEntity(this RunePage item)
{
throw new NotImplementedException();
}
public static RunePage ToModel(this RunePageEntity entity)
{
throw new NotImplementedException();
}
}
}

@ -0,0 +1,21 @@
using Entities;
using Model;
namespace EntityMapper
{
public static class SkinMapper
{
public static SkinEntity ToEntity(this Skin item)
{
throw new NotImplementedException();
}
public static Skin ToModel(this SkinEntity entity)
{
throw new NotImplementedException();
}
}
}

@ -25,7 +25,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Entities", "Entities\Entiti
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_Api", "Test_Api\Test_Api.csproj", "{C35C38F6-5774-4562-BD00-C81BCE13A260}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Test_Api", "Test_Api\Test_Api.csproj", "{C35C38F6-5774-4562-BD00-C81BCE13A260}"
EndProject EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Business", "Business\Business.csproj", "{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Business", "Business\Business.csproj", "{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EntityMappers", "EntityMappers\EntityMappers.csproj", "{3A70A719-4F42-4CC3-846A-53437F3B4CC5}"
EndProject EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -61,10 +63,18 @@ Global
{C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Debug|Any CPU.Build.0 = Debug|Any CPU {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.ActiveCfg = Release|Any CPU {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.Build.0 = Release|Any CPU {C463E2E1-237A-4339-A4C4-6EA3BE7002AE}.Release|Any CPU.Build.0 = Release|Any CPU
{C35C38F6-5774-4562-BD00-C81BCE13A260}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C35C38F6-5774-4562-BD00-C81BCE13A260}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C35C38F6-5774-4562-BD00-C81BCE13A260}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C35C38F6-5774-4562-BD00-C81BCE13A260}.Release|Any CPU.Build.0 = Release|Any CPU
{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU {A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Debug|Any CPU.Build.0 = Debug|Any CPU {A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Release|Any CPU.ActiveCfg = Release|Any CPU {A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Release|Any CPU.Build.0 = Release|Any CPU {A447B0BE-62AE-4F66-B887-D1F3D46B0DB3}.Release|Any CPU.Build.0 = Release|Any CPU
{3A70A719-4F42-4CC3-846A-53437F3B4CC5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3A70A719-4F42-4CC3-846A-53437F3B4CC5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3A70A719-4F42-4CC3-846A-53437F3B4CC5}.Release|Any CPU.ActiveCfg = Release|Any CPU
{3A70A719-4F42-4CC3-846A-53437F3B4CC5}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE
@ -74,6 +84,7 @@ Global
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170} {B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{C463E2E1-237A-4339-A4C4-6EA3BE7002AE} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E} {C463E2E1-237A-4339-A4C4-6EA3BE7002AE} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E}
{A447B0BE-62AE-4F66-B887-D1F3D46B0DB3} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E} {A447B0BE-62AE-4F66-B887-D1F3D46B0DB3} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E}
{3A70A719-4F42-4CC3-846A-53437F3B4CC5} = {BC2FFCA4-3801-433F-A83E-B55345F3B31E}
EndGlobalSection EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9} SolutionGuid = {92F3083D-793F-4552-8A9A-0AD6534159C9}

@ -0,0 +1,7 @@
{
"profiles": {
"Model": {
"commandName": "Project"
}
}
}
Loading…
Cancel
Save