feat : création d'une question entity
continuous-integration/drone/push Build is passing Details

API
Damien NORTIER 1 year ago
parent 075569cb16
commit 62957eb56f

@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Entities
{
public class QuestionEntity
{
public int Id { get; set; }
public string Content { get; set; }
public int difficuty { get; set; }
public int NbFalls { get; set; }
public int IdChapter { get; set; }
[ForeignKey(nameof(AnswerEntity))]
public int IdAnswerGood { get; set; }
}
}

@ -0,0 +1,94 @@
using DTOs;
using Entities;
using Model;
namespace ExtensionsClassLibrairie
{
public static class AnswerExtensionMethods
{
/// <summary>
/// convet a dto answer into a model answer
/// </summary>
/// <param name="a">the dto answer to convert</param>
/// <returns>the model answer that correspond</returns>
public static Answer ToModel(this AnswerDto a)
{
return new Answer(a.Content, a.Id);
}
/// <summary>
/// convet an entity answer into a model answer
/// </summary>
/// <param name="a">the entity answer to convert</param>
/// <returns>the model answer that correspond</returns>
public static Answer ToModel(this AnswerEntity a)
{
return new Answer(a.Content, a.Id);
}
/// <summary>
/// convet a model answer into an entity answer
/// </summary>
/// <param name="a">the model answer to convert</param>
/// <returns>the entity answer that correspond</returns>
public static AnswerEntity ToEntity(this Answer a)
{
return new AnswerEntity
{
Id = a.Id,
Content = a.Content
};
}
/// <summary>
/// convet a dto answer into an entity answer
/// </summary>
/// <param name="a">the dto answer to convert</param>
/// <returns>the entity answer that correspond</returns>
public static AnswerEntity ToEntity(this AnswerDto a)
{
return new AnswerEntity
{
Id = a.Id,
Content = a.Content
};
}
/// <summary>
/// convet a model answer into a dto answer
/// </summary>
/// <param name="a">the model answer to convert</param>
/// <returns>the dto answer that correspond</returns>
public static AnswerDto ToDto(this Answer a)
{
return new AnswerDto(a.Content, a.Id);
}
/// <summary>
/// convet an entity answer into a dto answer
/// </summary>
/// <param name="a">the entity answer to convert</param>
/// <returns>the dto answer that correspond</returns>
public static AnswerDto ToDto(this AnswerEntity a)
{
return new AnswerDto(a.Content, a.Id);
}
/// <summary>
/// equality protocole
/// </summary>
/// <param name="obj">an object</param>
/// <returns>
/// true if the object is an AnswerEntity
/// and the two contents are equals
/// (we don't care about the id because
/// he's set by the database
/// </returns>
public static bool Equals(this AnswerEntity a, object? obj)
{
return obj != null && obj is AnswerEntity other
&& other.Content == a.Content;
}
}
}

@ -0,0 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\DTOs\DTOs.csproj" />
<ProjectReference Include="..\Entities\Entities.csproj" />
<ProjectReference Include="..\Model\Model.csproj" />
</ItemGroup>
</Project>
Loading…
Cancel
Save