|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
|
using System.ComponentModel.DataAnnotations;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
namespace Entity
|
|
|
{
|
|
|
public class Quote
|
|
|
{
|
|
|
[Key]
|
|
|
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
|
|
|
public int Id { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
[StringLength(100)]
|
|
|
public string Content { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
public int Likes { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
public LangEnum Langage { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
public bool IsValid { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
[ForeignKey(nameof(Character))]
|
|
|
public int IdCharacter { get; set; }
|
|
|
|
|
|
[Required]
|
|
|
[ForeignKey(nameof(Source))]
|
|
|
public int IdSource { get; set; }
|
|
|
|
|
|
[ForeignKey(nameof(Users))]
|
|
|
public int? IdUsersPropose { get; set; }
|
|
|
//Réson de pour quoi j'ai mis le user en nullable et mis .OnDelete(DeleteBehavior.ClientSetNull) dans WTFContext
|
|
|
//https://learn.microsoft.com/fr-fr/ef/core/saving/cascade-delete
|
|
|
//Les suppressions en cascade sont nécessaires quand une entité dépendante/enfant ne peut plus être associée à son entité principale/parente actuelle. Cela peut se produire à la suite de la suppression de l’entité principale/parente, ou quand l’entité principale/parente existe toujours mais que l’entité dépendante/enfant ne lui est plus associée.
|
|
|
public Users? User { get; set; } = null!;
|
|
|
|
|
|
public Source Source { get; set; } = null!;
|
|
|
|
|
|
public Character Character { get; set; } = null!;
|
|
|
|
|
|
public ICollection<DailyQuote> DailyQuotes { get; set; } = new List<DailyQuote>();
|
|
|
|
|
|
public ICollection<Commentary> Commentarys { get; set; } = new List<Commentary>();
|
|
|
|
|
|
public ICollection<Users> Favorite { get; } = new List<Users>();
|
|
|
}
|
|
|
}
|