Skip to content

Commit

Permalink
Update Review Types (stphnwlsh#24)
Browse files Browse the repository at this point in the history
* Update Review Types to only include required fields

* Cleanup a few messy lines
  • Loading branch information
stphnwlsh committed Nov 6, 2023
1 parent beeaa74 commit 9d6534c
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
8 changes: 4 additions & 4 deletions global.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"sdk": {
"version": "8.0.100-rc.1.23463.5",
"allowPrerelease": false,
"rollForward": "latestMinor"
"version": "8.0.100-rc.2",
"allowPrerelease": true,
"rollForward": "latestPatch"
}
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
namespace CleanMinimalApi.Infrastructure.Databases.MoviesReviews;

using System;
using Application.Authors;
using Application.Common.Enums;
using Application.Common.Exceptions;
Expand All @@ -9,21 +10,20 @@ namespace CleanMinimalApi.Infrastructure.Databases.MoviesReviews;
using Extensions;
using Microsoft.EntityFrameworkCore;
using Models;
using SimpleDateTimeProvider;
using ApplicationAuthor = Application.Authors.Entities.Author;
using ApplicationMovie = Application.Movies.Entities.Movie;
using ApplicationReview = Application.Reviews.Entities.Review;

internal class EntityFrameworkMovieReviewsRepository : IAuthorsRepository, IMoviesRepository, IReviewsRepository
{
private readonly MovieReviewsDbContext context;
private readonly IDateTimeProvider dateTimeProvider;
private readonly TimeProvider timeProvider;
private readonly IMapper mapper;

public EntityFrameworkMovieReviewsRepository(MovieReviewsDbContext context, IDateTimeProvider dateTimeProvider, IMapper mapper)
public EntityFrameworkMovieReviewsRepository(MovieReviewsDbContext context, TimeProvider timeProvider, IMapper mapper)
{
this.context = context;
this.dateTimeProvider = dateTimeProvider;
this.timeProvider = timeProvider;
this.mapper = mapper;

if (this.context != null)
Expand Down Expand Up @@ -90,8 +90,8 @@ public async Task<ApplicationReview> CreateReview(Guid authorId, Guid movieId, i
ReviewAuthorId = authorId,
ReviewedMovieId = movieId,
Stars = stars,
DateCreated = this.dateTimeProvider.UtcNow,
DateModified = this.dateTimeProvider.UtcNow
DateCreated = this.TimeProvider.GetUtcNow(),
DateModified = this.TimeProvider.GetUtcNow()
};

var id = this.context.Add(review).Entity.Id;
Expand Down Expand Up @@ -148,7 +148,7 @@ public async Task<bool> UpdateReview(Guid id, Guid authorId, Guid movieId, int s
review.Stars = stars;
review.ReviewAuthorId = authorId;
review.ReviewedMovieId = movieId;
review.DateModified = this.dateTimeProvider.UtcNow;
review.DateModified = this.TimeProvider.GetUtcNow();

_ = this.context.Update(review);
_ = await this.context.SaveChangesAsync(cancellationToken);
Expand Down
4 changes: 2 additions & 2 deletions src/Infrastructure/DependencyInjection.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace CleanMinimalApi.Infrastructure;

using System;
using Application.Authors;
using Application.Movies;
using Application.Reviews;
using Databases.MoviesReviews;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using SimpleDateTimeProvider;

public static class DependencyInjection
{
Expand All @@ -22,7 +22,7 @@ public static IServiceCollection AddInfrastructure(this IServiceCollection servi
_ = services.AddSingleton<IMoviesRepository>(x => x.GetRequiredService<EntityFrameworkMovieReviewsRepository>());
_ = services.AddSingleton<IReviewsRepository>(x => x.GetRequiredService<EntityFrameworkMovieReviewsRepository>());

_ = services.AddSingleton<IDateTimeProvider, SystemDateTimeProvider>();
_ = services.AddSingleton<TimeProvider, TimeProvider.System>();

return services;
}
Expand Down
3 changes: 1 addition & 2 deletions src/Infrastructure/Infrastructure.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="12.0.1" />
<PackageReference Include="Bogus" Version="34.0.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0-rc.1.23419.6" />
<PackageReference Include="SimpleDateTimeProvider" Version="2022.11.13.46" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="8.0.0-rc.2.23480.1" />
</ItemGroup>

<ItemGroup>
Expand Down
8 changes: 4 additions & 4 deletions src/Presentation/Presentation.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,14 @@
<PropertyGroup Condition=" '$(RunConfiguration)' == 'CleanMinimalApi' " />

<ItemGroup>
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.7.1" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="FluentValidation.DependencyInjectionExtensions" Version="11.8.0" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Serilog.AspNetCore" Version="7.0.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.2.0" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.3.0" />
<PackageReference Include="Serilog.Enrichers.Thread" Version="3.1.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="7.0.0" />
<PackageReference Include="Serilog.Sinks.Console" Version="4.1.0" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.2" />
<PackageReference Include="Serilog.Sinks.Seq" Version="5.2.3" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down
6 changes: 3 additions & 3 deletions tests/Application.Tests.Unit/Application.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" Version="8.0.0-rc.2.23510.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.1.23421.29" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.0-rc.2.23480.2" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions tests/Presentation.Tests.Unit/Presentation.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.8.0-preview-23424-02" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0-preview-23503-02" />
<PackageReference Include="NSubstitute" Version="5.1.0" />
<PackageReference Include="Shouldly" Version="4.2.1" />
<PackageReference Include="xunit" Version="2.5.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.1">
<PackageReference Include="xunit" Version="2.6.1" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.5.3">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down

0 comments on commit 9d6534c

Please sign in to comment.