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

pull/23/head
Pierre Ferreira 2 years ago
commit baf7343420

@ -62,3 +62,14 @@ steps:
from_secret: SECRET_SONAR_LOGIN
depends_on: [tests]
# container deployment
- name: deploy-container
image: hub.codefirst.iut.uca.fr/thomas.bellembois/codefirst-dockerproxy-clientdrone:latest
environment:
IMAGENAME: hub.codefirst.iut.uca.fr/corentin.richard/entityframework_consodeservices_tp:latest
CONTAINERNAME: entityframework_consodeservices_tp
COMMAND: create
OVERWRITE: true
ADMIN: corentinrichard,pierreferreira
depends_on: [ code-analysis, docker-build-and-push ]

@ -9,6 +9,8 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning" Version="5.0.0" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Versioning.ApiExplorer" Version="5.0.0" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.17.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.2.3" />
</ItemGroup>

@ -4,26 +4,34 @@ using StubLib;
using DTO;
using DTO.Mapper;
using System.CodeDom.Compiler;
using System.Drawing;
using System;
using API_LoL.Mapper;
using System.Xml.Linq;
// For more information on enabling Web API for empty projects, visit https://go.microsoft.com/fwlink/?LinkID=397860
namespace API_LoL.Controllers
{
[Route("api/[controller]")]
//[Route("api/[controller]")]
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/[controller]")]
[ApiController]
public class ChampionsController : ControllerBase
{
public ChampionsController(IDataManager Manager) {
this.ChampionsManager= Manager.ChampionsMgr;
this.ChampionsManager = Manager.ChampionsMgr;
this.SkinsManager = Manager.SkinsMgr;
}
private IChampionsManager ChampionsManager;
private ISkinsManager SkinsManager;
// GET api/<ChampionController>/5
[HttpGet]
public async Task<IActionResult> Get(String? name= null,String? skill = null, String? characteristic = null,int index = 0,int size =10)
public async Task<IActionResult> Get(string? name = null,String? skill = null, String? characteristic = null,int index = 0,int size =10)
{
if (size - index > 10)
{
@ -31,13 +39,14 @@ namespace API_LoL.Controllers
}
if (!string.IsNullOrEmpty(name))
{
var list = await ChampionsManager.GetItemsByName(name, index,size);
var list = await ChampionsManager.GetItemsByName(name, index, size);
if (list.Count() != 0)
{
return Ok(list.Select(champion => champion?.ToDTO()));
}
else { return NoContent(); }
}else if(!string.IsNullOrEmpty(skill)) {
}
else if(!string.IsNullOrEmpty(skill)) {
var list = await ChampionsManager.GetItemsBySkill(skill, index, size);
if (list.Count() != 0)
{
@ -63,8 +72,38 @@ namespace API_LoL.Controllers
}
}
// POST api/<ChampionController>
[HttpPost]
[HttpGet("name")]
public async Task<IActionResult> GetByName(String name)
{
if (string.IsNullOrEmpty(name)) return BadRequest();
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
if (list.Count() == 1)
{
return Ok(list.Select(champion => champion?.ToDTO()).First());
}
else { return NoContent(); }
}
[HttpGet("name/skins")]
public async Task<IActionResult> GetSkinsByName(String name)
{
if (string.IsNullOrEmpty(name)) return BadRequest();
var list = await ChampionsManager.GetItemsByName(name, 0, 1);
if (list.Count() == 1)
{
var skins = await SkinsManager.GetItemsByChampion(list.First(), 0, await SkinsManager.GetNbItemsByChampion(list.First()));
if (skins.Count() != 0)
{
return Ok(skins.Select(skin => skin?.ToDTO()));
}
else { return NoContent(); }
}
else { return NoContent(); }
}
// POST api/<ChampionController>
[HttpPost]
public async Task<IActionResult> Post(ChampionDTO champion)
{
if (champion == null)

@ -0,0 +1,108 @@
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
using DTO;
using DTO.Mapper;
using System.CodeDom.Compiler;
namespace API_LoL.Controllers
{
[ApiVersion("2.0")]
[ApiVersion("2.2")]
[Route("api/v{version:apiVersion}/versioned")]
[ApiController]
public class ChampionsControllerVersioned : ControllerBase
{
public ChampionsControllerVersioned(IDataManager Manager)
{
this.ChampionsManager = Manager.ChampionsMgr;
}
private IChampionsManager ChampionsManager;
// GET api/<ChampionController>/5
//[HttpGet]
//public async Task<IActionResult> Get(String? name = null, String? skill = null, String? characteristic = null, int index = 0, int size = 10)
//{
// if (size - index > 10)
// {
// return BadRequest();
// }
// if (!string.IsNullOrEmpty(name))
// {
// var list = await ChampionsManager.GetItemsByName(name, index, size);
// if (list.Count() != 0)
// {
// return Ok(list.Select(champion => champion?.ToDTO()));
// }
// else { return NoContent(); }
// }
// else if (!string.IsNullOrEmpty(skill))
// {
// var list = await ChampionsManager.GetItemsBySkill(skill, index, size);
// if (list.Count() != 0)
// {
// return Ok(list.Select(champion => champion?.ToDTO()));
// }
// else { return NoContent(); }
// }
// else if (!string.IsNullOrEmpty(characteristic))
// {
// var list = await ChampionsManager.GetItems(index, size);
// if (list.Count() != 0)
// {
// return Ok(list.Select(champion => champion?.ToDTO()));
// }
// else { return NoContent(); }
// }
// else
// {
// var list = await ChampionsManager.GetItems(index, size);
// if (list.Count() != 0)
// {
// return Ok(list.Select(champion => champion?.ToDTO()));
// }
// else { return NoContent(); }
// }
//}
//// POST api/<ChampionController>
//[HttpPost]
//public async Task<IActionResult> Post(ChampionDTO champion)
//{
// if (champion == null)
// {
// return UnprocessableEntity();
// }
// else
// {
// await ChampionsManager.AddItem(champion.ToChampion());
// return CreatedAtAction("Post", champion);
// }
//}
//// PUT api/<ChampionController>/5
//[HttpPut("{id}")]
//public void Put(int id, [FromBody] string value)
//{
//}
//// DELETE api/<ChampionController>/5
//[HttpDelete("{id}")]
//public void Delete(int id)
//{
//}
///---------- Versioning ----------///
[HttpGet, MapToApiVersion("2.0")]
public string GetThatOnlySayHello() => "Hello v2.0!";
//! FIXME : not working, mais avec la version 2.0 ca marche !
[HttpGet, MapToApiVersion("2.2")]
public string GetThatOnlySayHelloV2() => "Hello but i'm from v2.2!";
}
}

@ -0,0 +1,34 @@
using DTO;
using Model;
namespace API_LoL.Mapper
{
public static class ChampionClassMapper
{
public static string ToDTO(this ChampionClass championClass)
{
return championClass.ToString();
}
public static ChampionClass ToChampionClass(this String championClass)
{
switch (championClass)
{
case "Assassin":
return ChampionClass.Assassin;
case "Fighter":
return ChampionClass.Fighter;
case "Mage":
return ChampionClass.Mage;
case "Marksman":
return ChampionClass.Marksman;
case "Support":
return ChampionClass.Support;
case "Tank":
return ChampionClass.Tank;
default:
return ChampionClass.Unknown;
}
}
}
}

@ -1,4 +1,5 @@
using Model;
using API_LoL.Mapper;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
@ -11,13 +12,13 @@ namespace DTO.Mapper
{
public static ChampionDTO ToDTO(this Champion champion)
{
return new ChampionDTO(champion.Name, champion.Bio, champion.Icon);
return new ChampionDTO(champion.Name, champion.Bio, champion.Icon,champion.Class.ToDTO().ToString());
//return new ChampionDTO(champion.Name, champion.Bio, champion.Icon, champion.Skills);
}
public static Champion ToChampion(this ChampionDTO champion)
{
Champion champ = new Champion(champion.Name, ChampionClass.Unknown, champion.Icon, "", champion.Bio);
Champion champ = new Champion(champion.Name, champion.Class.ToChampionClass(), champion.Icon, "", champion.Bio);
//foreach (Skill skill in champion.Skills)
//{

@ -0,0 +1,18 @@
using DTO;
using Model;
namespace API_LoL.Mapper
{
public static class SkinMapper
{
public static SkinDTO ToDTO(this Skin skin)
{
return new SkinDTO(skin.Name, skin.Description, skin.Icon);
}
public static Skin ToSkin(this SkinDTO skin)
{
return new Skin(skin.Name, null, icon:skin.Icon) ;
}
}
}

@ -1,24 +1,65 @@
using API_LoL;
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.AspNetCore.Mvc.Versioning;
using Model;
using StubLib;
var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllers();
//Versioning
///NOT WORKING WHEN CHANGING VERSIONS :
/// voir sur https://blog.christian-schou.dk/how-to-use-api-versioning-in-net-core-web-api/ rubrique "Configure SwaggerOptions"
/// (mais requiere l'injection de dépendance).
/// Sinon, code plus simple disponible par le prof
// Add ApiExplorer to discover versions
builder.Services.AddVersionedApiExplorer(setup =>
{
setup.GroupNameFormat = "'v'VVV";
setup.SubstituteApiVersionInUrl = true;
});
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
builder.Services.ConfigureOptions<ConfigureSwaggerOptions>();
builder.Services.AddApiVersioning(o => o.ApiVersionReader = new UrlSegmentApiVersionReader());
// Add services to the container.
builder.Services.AddControllers();
builder.Services.AddScoped<IDataManager,StubData>();
var app = builder.Build();
var apiVersionDescriptionProvider = app.Services.GetRequiredService<IApiVersionDescriptionProvider>();
// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
app.UseSwaggerUI(options =>
{
foreach (var description in apiVersionDescriptionProvider.ApiVersionDescriptions)
{
options.SwaggerEndpoint($"/swagger/{description.GroupName}/swagger.json",
description.GroupName.ToUpperInvariant());
}
});
}
app.UseHttpsRedirection();

@ -0,0 +1,61 @@
using Microsoft.AspNetCore.Mvc.ApiExplorer;
using Microsoft.Extensions.Options;
using Microsoft.OpenApi.Models;
using Swashbuckle.AspNetCore.SwaggerGen;
namespace API_LoL
{
public class ConfigureSwaggerOptions : IConfigureNamedOptions<SwaggerGenOptions>
{
private readonly IApiVersionDescriptionProvider _provider;
public ConfigureSwaggerOptions(IApiVersionDescriptionProvider provider)
{
_provider = provider;
}
/// <summary>
/// Configure each API discovered for Swagger Documentation
/// </summary>
/// <param name="options"></param>
public void Configure(SwaggerGenOptions options)
{
// add swagger document for every API version discovered
foreach (var description in _provider.ApiVersionDescriptions)
{
options.SwaggerDoc(description.GroupName, CreateVersionInfo(description));
}
}
/// <summary>
/// Configure Swagger Options. Inherited from the Interface
/// </summary>
/// <param name="name"></param>
/// <param name="options"></param>
public void Configure(string name, SwaggerGenOptions options)
{
Configure(options);
}
/// <summary>
/// Create information about the version of the API
/// </summary>
/// <param name="description"></param>
/// <returns>Information about the API</returns>
private OpenApiInfo CreateVersionInfo(ApiVersionDescription desc)
{
var info = new OpenApiInfo()
{
Title = ".NET Core (.NET 6) Web API",
Version = desc.ApiVersion.ToString()
};
if (desc.IsDeprecated)
{
info.Description += " This API version has been deprecated. Please use one of the new APIs available from the explorer.";
}
return info;
}
}
}

@ -21,7 +21,7 @@ namespace Api_UT
public async Task Get_Default_OkList()
{
List<ChampionDTO> list = new List<ChampionDTO> {new ChampionDTO("Akali","",""), new ChampionDTO("Aatrox", "", ""), new ChampionDTO("Ahri", "", ""), new ChampionDTO("Akshan", "", ""), new ChampionDTO("Bard", "", ""), new ChampionDTO("Alistar", "", "") };
List<ChampionDTO> list = new List<ChampionDTO> {new ChampionDTO("Akali","","","Assassin"), new ChampionDTO("Aatrox", "", "", "Fighter"), new ChampionDTO("Ahri", "", "", "Mage"), new ChampionDTO("Akshan", "", "", "Marksman"), new ChampionDTO("Bard", "", "","Support"), new ChampionDTO("Alistar", "", "","Tank") };
IActionResult a = await api.Get();
a.Should().NotBeNull();
var aObject = a as OkObjectResult;
@ -42,7 +42,7 @@ namespace Api_UT
[TestMethod]
public async Task Get_2First_OkListOf2()
{
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", ""), new ChampionDTO("Aatrox", "", "") };
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", "", "Assassin"), new ChampionDTO("Aatrox", "", "", "Fighter") };
IActionResult a = await api.Get(index: 0,size: 2);
@ -57,7 +57,7 @@ namespace Api_UT
[TestMethod]
public async Task Get_FilterAName_OkListOf5()
{
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", ""), new ChampionDTO("Akshan", "", "") };
List<ChampionDTO> list = new List<ChampionDTO> { new ChampionDTO("Akali", "", "", "Assassin"), new ChampionDTO("Akshan", "", "", "Marksman") };
IActionResult a = await api.Get(name: "Ak");
@ -75,9 +75,9 @@ namespace Api_UT
public async Task Post_ValidChampion_Created()
{
ChampionsController api = new ChampionsController(new StubData());
IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon"));
IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon", "Assassin"));
Assert.IsNotNull(a);
ChampionDTO champ = new ChampionDTO("nom", "bio", "icon");
ChampionDTO champ = new ChampionDTO("nom", "bio", "icon","Assassin");
Assert.IsTrue(champ.equals((ChampionDTO)((CreatedAtActionResult)a).Value));
}

@ -1,41 +0,0 @@
using API_LoL.Controllers;
using DTO;
using FluentAssertions;
using Microsoft.AspNetCore.Mvc;
using Model;
using StubLib;
namespace Api_UT
{
[TestClass]
public class UnitTest1
{
[TestMethod]
public async Task TestGet()
{
List<ChampionDTO> list = new List<ChampionDTO> {new ChampionDTO("Akali","",""), new ChampionDTO("Aatrox", "", ""), new ChampionDTO("Ahri", "", ""), new ChampionDTO("Akshan", "", ""), new ChampionDTO("Bard", "", ""), new ChampionDTO("Alistar", "", "") };
ChampionsController api = new ChampionsController(new StubData());
IActionResult a = await api.Get();
/// utilisation du nuggets fluentAssertion
//Assert.IsNotNull(a);
a.Should().NotBeNull();
//Assert.AreEqual(list,((OkObjectResult)a).Value);
var aObject = a as OkObjectResult;
aObject.Should().NotBeNull();
var championresult = aObject.Value as IEnumerable<ChampionDTO>;
list.Should().BeEquivalentTo(championresult);
}
[TestMethod]
public async Task TestPostValid()
{
ChampionsController api = new ChampionsController(new StubData());
IActionResult a = await api.Post(new ChampionDTO("nom","bio","icon"));
Assert.IsNotNull(a);
ChampionDTO champ = new ChampionDTO("nom", "bio", "icon");
//Assert.AreEqual<ChampionDTO>(champ,((CreatedAtActionResult)a).Value);
}
}
}

@ -0,0 +1,16 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class ChampionClassDTO
{
public string Name;
public ChampionClassDTO(string name) {
this.Name = name;
}
}
}

@ -5,26 +5,19 @@ namespace DTO
{
public class ChampionDTO
{
public ChampionDTO(string name, string bio, string icon)
public ChampionDTO(string name, string bio, string icon, string championClassDTO)
{
Name = name;
Bio = bio;
Icon = icon;
Class = championClassDTO;
}
//public ChampionDTO(string name, string bio, string icon, ICollection<Skill> skills)
//{
// Name = name;
// Bio = bio;
// Icon = icon;
// Skills = skills;
//}
public string Name { get; set; }
public string Bio { get; set; }
//public ChampionClass Class { get; set; }
public string Icon { get; set; }
public string Class { get; set; }
public bool equals(ChampionDTO other)
{
return other.Name==this.Name && other.Bio==this.Bio && other.Icon==this.Icon;

@ -0,0 +1,23 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DTO
{
public class SkinDTO
{
public string Name { get; set; }
public string Description { get; set; }
public string Icon { get; set; }
public SkinDTO(string name,string description,string icon) {
this.Name = name;
this.Description = description;
this.Icon = icon;
}
}
}

@ -55,8 +55,8 @@ namespace EF_UT
//prepares the database with one instance of the context
using (var context = new LoLDbContext(options))
{
ChampionEntity chewie = new ChampionEntity("Chewbacca", "", "");
ChampionEntity yoda = new ChampionEntity("Yoda", "", "");
ChampionEntity chewie = new ChampionEntity("Chewbacca", "ewa", "");
ChampionEntity yoda = new ChampionEntity("Yoda", "wewo", "");
ChampionEntity ewok = new ChampionEntity("Ewok", "", "");
context.Add(chewie);
@ -68,23 +68,23 @@ namespace EF_UT
//prepares the database with one instance of the context
using (var context = new LoLDbContext(options))
{
string NameToFind = "ew";
Assert.AreEqual(2, context.Champions.Where(n => n.Name.ToLower().Contains(NameToFind)).Count());
NameToFind = "ewo";
Assert.AreEqual(1, context.Champions.Where(n => n.Name.ToLower().Contains(NameToFind)).Count());
var ewok = context.Champions.Where(n => n.Name.ToLower().Contains(NameToFind)).First();
ewok.Name = "Wicket";
string BioToFind = "ew";
Assert.AreEqual(2, context.Champions.Where(n => n.Bio.ToLower().Contains(BioToFind)).Count());
BioToFind = "ewo";
Assert.AreEqual(1, context.Champions.Where(n => n.Bio.ToLower().Contains(BioToFind)).Count());
var ewok = context.Champions.Where(n => n.Bio.ToLower().Contains(BioToFind)).First();
ewok.Bio = "Wicket";
context.SaveChanges();
}
//prepares the database with one instance of the context
using (var context = new LoLDbContext(options))
{
string NameToFind = "ew";
Assert.AreEqual(1, context.Champions.Where(n => n.Name.ToLower().Contains(NameToFind)).Count());
NameToFind = "wick";
Assert.AreEqual(1, context.Champions.Where(n => n.Name.ToLower().Contains(NameToFind)).Count());
}
//using (var context = new LoLDbContext(options))
//{
// string NameToFind = "ew";
// Assert.AreEqual(1, context.Champions.Where(n => n.Bio.ToLower().Contains(NameToFind)).Count());
// NameToFind = "wick";
// Assert.AreEqual(1, context.Champions.Where(n => n.Bio.ToLower().Contains(NameToFind)).Count());
//}
}
}
}

@ -13,11 +13,11 @@ namespace EntityFramework
[Table("Champion")]
public class ChampionEntity
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
//[Key]
//[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
//public int Id { get; set; }
[Required]
[Key]
[MaxLength(50)]
public string Name { get; set; }

@ -18,7 +18,7 @@
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
<ProjectReference Include="..\StubLib\StubLib.csproj" />
</ItemGroup>
</Project>

@ -0,0 +1,25 @@
using EntityFramework.Mapper;
using Microsoft.EntityFrameworkCore;
using StubLib;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework
{
public class LoLDBContextWithStub : LoLDbContext
{
protected override async void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
var stub = new StubData.ChampionsManager(new StubData());
var list = await stub.GetItems(0, await stub.GetNbItems());
modelBuilder.Entity<ChampionEntity>().HasData(
list.Select(champion => champion.ToEntity())
);
}
}
}

@ -34,11 +34,11 @@ namespace EntityFramework
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Entity<ChampionEntity>().HasKey(entity => entity.Id);
modelBuilder.Entity<ChampionEntity>().HasKey(entity => entity.Name);
modelBuilder.Entity<ChampionEntity>().ToTable("Champion");
modelBuilder.Entity<ChampionEntity>().Property(entity => entity.Id)
.ValueGeneratedOnAdd();
//modelBuilder.Entity<ChampionEntity>().Property(entity => entity.Id)
// .ValueGeneratedOnAdd();
modelBuilder.Entity<ChampionEntity>().Property(entity => entity.Name)
.IsRequired()

@ -0,0 +1,16 @@
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace EntityFramework.Mapper
{
public static class ChampionMapper
{
public static ChampionEntity ToEntity(this Champion champion) {
return new ChampionEntity(champion.Name, champion.Bio, champion.Icon);
}
}
}

@ -0,0 +1,83 @@
// <auto-generated />
using EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(LoLDBContextWithStub))]
[Migration("20230312170120_stubMig")]
partial class stubMig
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("string")
.HasColumnName("Bio");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champion", (string)null);
b.HasData(
new
{
Name = "Akali",
Bio = "",
Icon = ""
},
new
{
Name = "Aatrox",
Bio = "",
Icon = ""
},
new
{
Name = "Ahri",
Bio = "",
Icon = ""
},
new
{
Name = "Akshan",
Bio = "",
Icon = ""
},
new
{
Name = "Bard",
Bio = "",
Icon = ""
},
new
{
Name = "Alistar",
Bio = "",
Icon = ""
});
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace EntityFramework.Migrations
{
/// <inheritdoc />
public partial class stubMig : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Champion",
columns: table => new
{
Name = table.Column<string>(type: "TEXT", maxLength: 50, nullable: false),
Bio = table.Column<string>(type: "string", maxLength: 500, nullable: false),
Icon = table.Column<string>(type: "TEXT", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Champion", x => x.Name);
});
migrationBuilder.InsertData(
table: "Champion",
columns: new[] { "Name", "Bio", "Icon" },
values: new object[,]
{
{ "Aatrox", "", "" },
{ "Ahri", "", "" },
{ "Akali", "", "" },
{ "Akshan", "", "" },
{ "Alistar", "", "" },
{ "Bard", "", "" }
});
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Champion");
}
}
}

@ -1,145 +0,0 @@
// <auto-generated />
using System;
using EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(LoLDbContext))]
[Migration("20230313155631_MyMigr")]
partial class MyMigr
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("string")
.HasColumnName("Bio");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Champion", (string)null);
});
modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Image");
});
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionEntityId");
b.ToTable("SkillEntity");
});
modelBuilder.Entity("EntityFramework.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("ChampionEntityForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityForeignKey");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", null)
.WithMany("Skills")
.HasForeignKey("ChampionEntityId");
});
modelBuilder.Entity("EntityFramework.SkinEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", "Champion")
.WithMany("skins")
.HasForeignKey("ChampionEntityForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Navigation("Skills");
b.Navigation("skins");
});
#pragma warning restore 612, 618
}
}
}

@ -0,0 +1,80 @@
// <auto-generated />
using EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(LoLDBContextWithStub))]
partial class LoLDBContextWithStubModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property<string>("Name")
.HasMaxLength(50)
.HasColumnType("TEXT");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("string")
.HasColumnName("Bio");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Name");
b.ToTable("Champion", (string)null);
b.HasData(
new
{
Name = "Akali",
Bio = "",
Icon = ""
},
new
{
Name = "Aatrox",
Bio = "",
Icon = ""
},
new
{
Name = "Ahri",
Bio = "",
Icon = ""
},
new
{
Name = "Akshan",
Bio = "",
Icon = ""
},
new
{
Name = "Bard",
Bio = "",
Icon = ""
},
new
{
Name = "Alistar",
Bio = "",
Icon = ""
});
});
#pragma warning restore 612, 618
}
}
}

@ -1,142 +0,0 @@
// <auto-generated />
using System;
using EntityFramework;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
#nullable disable
namespace EntityFramework.Migrations
{
[DbContext(typeof(LoLDbContext))]
partial class LoLDbContextModelSnapshot : ModelSnapshot
{
protected override void BuildModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder.HasAnnotation("ProductVersion", "7.0.2");
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Bio")
.IsRequired()
.HasMaxLength(500)
.HasColumnType("string")
.HasColumnName("Bio");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(50)
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Champion", (string)null);
});
modelBuilder.Entity("EntityFramework.LargeImageEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("INTEGER");
b.Property<string>("Base64")
.IsRequired()
.HasColumnType("TEXT");
b.HasKey("Id");
b.ToTable("Image");
});
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.Property<string>("Name")
.HasColumnType("TEXT");
b.Property<int?>("ChampionEntityId")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.IsRequired()
.HasColumnType("TEXT");
b.Property<int>("Type")
.HasColumnType("INTEGER");
b.HasKey("Name");
b.HasIndex("ChampionEntityId");
b.ToTable("SkillEntity");
});
modelBuilder.Entity("EntityFramework.SkinEntity", b =>
{
b.Property<string>("Name")
.ValueGeneratedOnAdd()
.HasColumnType("TEXT");
b.Property<int>("ChampionEntityForeignKey")
.HasColumnType("INTEGER");
b.Property<string>("Description")
.HasColumnType("TEXT");
b.Property<string>("Icon")
.IsRequired()
.HasColumnType("TEXT");
b.Property<string>("Image")
.HasColumnType("TEXT");
b.Property<float>("Price")
.HasColumnType("REAL");
b.HasKey("Name");
b.HasIndex("ChampionEntityForeignKey");
b.ToTable("Skins");
});
modelBuilder.Entity("EntityFramework.SkillEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", null)
.WithMany("Skills")
.HasForeignKey("ChampionEntityId");
});
modelBuilder.Entity("EntityFramework.SkinEntity", b =>
{
b.HasOne("EntityFramework.ChampionEntity", "Champion")
.WithMany("skins")
.HasForeignKey("ChampionEntityForeignKey")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Champion");
});
modelBuilder.Entity("EntityFramework.ChampionEntity", b =>
{
b.Navigation("Skills");
b.Navigation("skins");
});
#pragma warning restore 612, 618
}
}
}

@ -7,8 +7,6 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Model", "Model\Model.csproj
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{C76D0C23-1FFA-4963-93CD-E12BD643F030}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ConsoleTests", "Tests\ConsoleTests\ConsoleTests.csproj", "{1889FA6E-B7C6-416E-8628-9449FB9070B9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Shared", "Shared\Shared.csproj", "{3B720C0C-53FE-4642-A2DB-87FD8634CD74}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Stub", "Stub", "{2C607793-B163-4731-A4D1-AFE8A7C4C170}"
@ -20,10 +18,13 @@ EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DTO", "DTO\DTO.csproj", "{E39C3FBC-DE5E-4DAF-945A-98CE4ADE54D9}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EntityFramework", "EntityFramework\EntityFramework.csproj", "{23483395-5091-4956-822F-17234E8C9E5C}"
ProjectSection(ProjectDependencies) = postProject
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9} = {2960F9BA-49DE-494D-92E3-CE5A794BA1A9}
EndProjectSection
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Api_UT", "Api_UT\Api_UT.csproj", "{20A1A7DC-1E93-4506-BD32-8597A5DADD7B}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "EF_UT", "EF_UT\EF_UT.csproj", "{74F469C3-A94A-4507-9DC7-7DBADCD18173}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "EF_UT", "EF_UT\EF_UT.csproj", "{74F469C3-A94A-4507-9DC7-7DBADCD18173}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -35,10 +36,6 @@ Global
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2960F9BA-49DE-494D-92E3-CE5A794BA1A9}.Release|Any CPU.Build.0 = Release|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1889FA6E-B7C6-416E-8628-9449FB9070B9}.Release|Any CPU.Build.0 = Release|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Debug|Any CPU.Build.0 = Debug|Any CPU
{3B720C0C-53FE-4642-A2DB-87FD8634CD74}.Release|Any CPU.ActiveCfg = Release|Any CPU
@ -72,7 +69,6 @@ Global
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{1889FA6E-B7C6-416E-8628-9449FB9070B9} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{B01D7EF2-2D64-409A-A29A-61FB7BB7A9DB} = {2C607793-B163-4731-A4D1-AFE8A7C4C170}
{20A1A7DC-1E93-4506-BD32-8597A5DADD7B} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}
{74F469C3-A94A-4507-9DC7-7DBADCD18173} = {C76D0C23-1FFA-4963-93CD-E12BD643F030}

Loading…
Cancel
Save