Skip to content

Commit

Permalink
refactor: remove Guid id key
Browse files Browse the repository at this point in the history
  • Loading branch information
Joaoms98 committed Feb 16, 2023
1 parent 046c7eb commit bd5699a
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 19 deletions.
6 changes: 3 additions & 3 deletions PokedexApi.Domain/Entities/Evolution.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ public class Evolution
{
[Key]
[ForeignKey("Pokemon")]
public Guid PokemonId { get; set; }
public int PokemonId { get; set; }
public Pokemon Pokemon { get; set; }

public Guid? PreEvolution { get; set; }
public Guid? EvolutionForm { get; set; }
public int? PreEvolution { get; set; }
public int? EvolutionForm { get; set; }
}
}
4 changes: 0 additions & 4 deletions PokedexApi.Domain/Entities/Pokemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,9 @@ namespace PokedexApi.Domain.Entities
public class Pokemon
{
[Key]
public Guid Id { get; set; }

[Required]
public int DexNumber { get; set; }

[Required]

public int RelationshipPage { get; set; }

[Required]
Expand Down
7 changes: 2 additions & 5 deletions PokedexApi.Domain/Entities/SpecialStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,13 @@ namespace PokedexApi.Domain.Entities
public class SpecialStage
{
[Key]
public Guid Id { get; set; }
public int DexNumber { get; set; }

[Required]
[ForeignKey("Pokemon")]
public Guid PokemonId { get; set; }
public int PokemonId { get; set; }
public Pokemon Pokemon { get; set; }

[Required]
public int DexNumber { get; set; }

[Required]
[StringLength(50, ErrorMessage = "The length of the field must be up to 50 characters long")]
public string Name { get; set; }
Expand Down
5 changes: 2 additions & 3 deletions PokedexApi.Domain/Entities/Stats.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,18 @@

namespace PokedexApi.Domain.Entities
{

[Table("Stats")]
public class Stats
{
[Key]
public Guid Id { get; set; }

[ForeignKey("Pokemon")]
public Guid? PokemonId { get; set; }
public int? PokemonId { get; set; }
public Pokemon Pokemon { get; set; }

[ForeignKey("SpecialStage")]
public Guid? SpecialStageId { get; set; }
public int? SpecialStageId { get; set; }
public SpecialStage SpecialStage { get; set; }

[Required]
Expand Down
4 changes: 2 additions & 2 deletions PokedexApi.Domain/Entities/TypePokemon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class TypePokemon
public Guid Id { get; set; }

[ForeignKey("Pokemon")]
public Guid? PokemonId { get; set; }
public int? PokemonId { get; set; }
public Pokemon Pokemon { get; set; }

[ForeignKey("SpecialStage")]
public Guid? SpecialStageId { get; set; }
public int? SpecialStageId { get; set; }
public SpecialStage SpecialStage { get; set; }

[Required]
Expand Down
4 changes: 2 additions & 2 deletions PokedexApi.Domain/Entities/Weakness.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ public class Weakness
public Guid Id { get; set; }

[ForeignKey("Pokemon")]
public Guid? PokemonId { get; set; }
public int? PokemonId { get; set; }
public Pokemon Pokemon { get; set; }

[ForeignKey("SpecialStage")]
public Guid? SpecialStageId { get; set; }
public int? SpecialStageId { get; set; }
public SpecialStage SpecialStage { get; set; }

[Required]
Expand Down
2 changes: 2 additions & 0 deletions PokedexApi.Web/Mapper/DomainProfile.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using AutoMapper;
using PokedexApi.Domain.Entities;
using PokedexApi.Domain.Responses;
using PokedexApi.Web.Models;

namespace PokedexApi.Web.Mapper
Expand All @@ -9,6 +10,7 @@ public class DomainProfile : Profile
public DomainProfile()
{
CreateMap<Pokemon, PokemonModel>(MemberList.Destination);
CreateMap<EvolutionResponse, EvolutionModel>(MemberList.Destination);
}
}
}
11 changes: 11 additions & 0 deletions PokedexApi.Web/Models/EvolutionModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using PokedexApi.Domain.Entities;

namespace PokedexApi.Web.Models
{
public class EvolutionModel
{
public PokemonModel PreEvolution { get; set; }
public PokemonModel ActualStage { get; set; }
public PokemonModel EvolutionForm { get; set; }
}
}

0 comments on commit bd5699a

Please sign in to comment.