Skip to content

Commit

Permalink
Merge pull request #156 from AntonioFalcao/feature/code-smells
Browse files Browse the repository at this point in the history
Backing field collections
  • Loading branch information
AntonioFalcaoJr authored Mar 10, 2021
2 parents c9ca840 + d02330d commit 7f3d917
Show file tree
Hide file tree
Showing 16 changed files with 1,757 additions and 1,764 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)" />
<PackageReference Include="GraphQL" Version="$(GraphQL_Version)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(Microsoft_DependencyInjection_Version)" />
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6" />
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)"/>
<PackageReference Include="GraphQL" Version="$(GraphQL_Version)"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(Microsoft_DependencyInjection_Version)"/>
<PackageReference Include="Microsoft.Extensions.DependencyModel" Version="3.1.6"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(Microsoft_DependencyInjection_Version)" />
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)" />
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)"/>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="$(Microsoft_DependencyInjection_Version)"/>
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.CrossCutting\Dotnet5.GraphQL3.CrossCutting.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.CrossCutting\Dotnet5.GraphQL3.CrossCutting.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="AutoMapper" Version="$(AutoMapper_Version)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(Microsoft_EntityFrameworkCore_Version)" />
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)" />
<PackageReference Include="AutoMapper" Version="$(AutoMapper_Version)"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(Microsoft_EntityFrameworkCore_Version)"/>
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.Store.Domain\Dotnet5.GraphQL3.Store.Domain.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.Store.Domain\Dotnet5.GraphQL3.Store.Domain.csproj"/>
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="AutoMapper" Version="$(AutoMapper_Version)" />
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapper_DependencyInjection_Version)" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(Microsoft_EntityFrameworkCore_Version)" />
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)" />
<PackageReference Include="AutoMapper" Version="$(AutoMapper_Version)"/>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="$(AutoMapper_DependencyInjection_Version)"/>
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="$(Microsoft_EntityFrameworkCore_Version)"/>
<PackageReference Include="Scrutor" Version="$(Scrutor_Version)"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.CrossCutting\Dotnet5.GraphQL3.CrossCutting.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.Repositories.Abstractions\Dotnet5.GraphQL3.Repositories.Abstractions.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.Store.Domain\Dotnet5.GraphQL3.Store.Domain.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.CrossCutting\Dotnet5.GraphQL3.CrossCutting.csproj"/>
<ProjectReference Include="..\Dotnet5.GraphQL3.Repositories.Abstractions\Dotnet5.GraphQL3.Repositories.Abstractions.csproj"/>
<ProjectReference Include="..\Dotnet5.GraphQL3.Store.Domain\Dotnet5.GraphQL3.Store.Domain.csproj"/>
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,21 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)" />
<PackageReference Include="FluentValidation" Version="$(FluentValidation_Version)"/>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.Domain.Abstractions\Dotnet5.GraphQL3.Domain.Abstractions.csproj"/>
</ItemGroup>

<ItemGroup>
<EmbeddedResource Update="Resource.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resource.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
<Compile Update="Resource.Designer.cs">
<DesignTime>True</DesignTime>
<AutoGen>True</AutoGen>
<DependentUpon>DomainResource.resx</DependentUpon>
</Compile>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.Domain.Abstractions\Dotnet5.GraphQL3.Domain.Abstractions.csproj" />
</ItemGroup>

</Project>
14 changes: 8 additions & 6 deletions src/Dotnet5.GraphQL3.Store.Domain/Entities/Products/Product.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ namespace Dotnet5.GraphQL3.Store.Domain.Entities.Products
{
public abstract class Product : Entity<Guid>, IProduct
{
protected Product(Guid id, string description, DateTimeOffset introduceAt, string name, string photoUrl, decimal price,
ProductType productType, int rating, int stock, Option option)
private readonly HashSet<Review> _reviews = new();

protected Product(Guid id, string description, DateTimeOffset introduceAt, string name, string photoUrl, decimal price, ProductType productType, int rating, int stock, Option option)
{
Id = id;
Description = description;
Expand All @@ -22,11 +23,13 @@ protected Product(Guid id, string description, DateTimeOffset introduceAt, strin
Rating = rating;
Stock = stock;
Option = option;
Reviews = new List<Review>();
}

protected Product() { }

public IReadOnlyCollection<Review> Reviews
=> _reviews;

public string Description { get; }
public DateTimeOffset IntroduceAt { get; }
public string Name { get; }
Expand All @@ -36,7 +39,6 @@ protected Product() { }
public ProductType ProductType { get; }
public int Rating { get; }
public int Stock { get; }
public ICollection<Review> Reviews { get; }

public void AddReview(Review review)
{
Expand All @@ -46,8 +48,8 @@ public void AddReview(Review review)
return;
}

if (Reviews.Contains(review)) return;
Reviews.Add(review);
if (_reviews.Contains(review)) return;
_reviews.Add(review);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace Dotnet5.GraphQL3.Store.Repositories.Contexts
{
public class StoreDbContext : DbContext
{
private const string SqlLatin1GeneralCp1CsAs = "SQL_Latin1_General_CP1_CS_AS";

public StoreDbContext(DbContextOptions options)
: base(options) { }

Expand All @@ -16,7 +18,7 @@ public StoreDbContext(DbContextOptions options)

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.UseCollation("SQL_Latin1_General_CP1_CS_AS");
modelBuilder.UseCollation(SqlLatin1GeneralCp1CsAs);
modelBuilder.ApplyConfigurationsFromAssembly(typeof(StoreDbContext).Assembly);
modelBuilder.Seed();
base.OnModelCreating(modelBuilder);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk">

<ItemGroup>
<PackageReference Include="Bogus" Version="33.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(Microsoft_EntityFrameworkCore_Version)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="$(Microsoft_EntityFrameworkCore_Version)" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(Microsoft_EntityFrameworkCore_Version)" />
<PackageReference Include="Bogus" Version="33.0.2"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="$(Microsoft_EntityFrameworkCore_Version)"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="$(Microsoft_EntityFrameworkCore_Version)"/>
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="$(Microsoft_EntityFrameworkCore_Version)"/>
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\Dotnet5.GraphQL3.Repositories.Abstractions\Dotnet5.GraphQL3.Repositories.Abstractions.csproj" />
<ProjectReference Include="..\Dotnet5.GraphQL3.Repositories.Abstractions\Dotnet5.GraphQL3.Repositories.Abstractions.csproj"/>
</ItemGroup>

</Project>
Loading

0 comments on commit 7f3d917

Please sign in to comment.