-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added entities' configuration for domain model
- Loading branch information
1 parent
093a401
commit 75ffe04
Showing
22 changed files
with
221 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
9 changes: 9 additions & 0 deletions
9
Animelib.Backend/Application/Animelib.Application/Abstractions/IIdentityService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
using Animelib.Core.Users; | ||
using Animelib.Dto.Identity; | ||
|
||
namespace Animelib.Services.Abstractions; | ||
|
||
public interface IIdentityService | ||
{ | ||
Task<User> CreateUserAsync(CreateUserDto dto); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
Animelib.Backend/Application/Animelib.Application/Services/IdentityService.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using Animelib.Core.Animes; | ||
using Animelib.Core.Users; | ||
using Animelib.DataAccess.Abstractions; | ||
using Animelib.Dto.Identity; | ||
using Animelib.Services.Abstractions; | ||
|
||
namespace Animelib.Services.Services; | ||
|
||
public class IdentityService : IIdentityService | ||
{ | ||
private readonly IDatabaseContext _context; | ||
|
||
public IdentityService(IDatabaseContext context) | ||
{ | ||
_context = context; | ||
} | ||
|
||
public Task<User> CreateUserAsync(CreateUserDto dto) | ||
{ | ||
var user = new User(dto.Username, dto.Email, dto.Password); | ||
|
||
user.AddWatchList(new WatchList("Completed", user, new List<Anime>())); | ||
user.AddWatchList(new WatchList("Watching", user, new List<Anime>())); | ||
user.AddWatchList(new WatchList("On Hold", user, new List<Anime>())); | ||
user.AddWatchList(new WatchList("Dropped", user, new List<Anime>())); | ||
user.AddWatchList(new WatchList("Plan to Watch", user, new List<Anime>())); | ||
throw new NotImplementedException(); | ||
} | ||
} |
5 changes: 4 additions & 1 deletion
5
Animelib.Backend/Application/Animelib.DataAccess.Abstractions/IDatabaseContext.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,13 @@ | ||
using Animelib.Core.Animes; | ||
using Animelib.Core.Users; | ||
using Microsoft.EntityFrameworkCore; | ||
|
||
namespace Animelib.DataAccess.Abstractions; | ||
|
||
public interface IDatabaseContext | ||
{ | ||
DbSet<Anime> Animes { get; } | ||
DbSet<User> Users { get; } | ||
DbSet<WatchList> WatchLists { get; } | ||
Task<int> SaveChangesAsync(CancellationToken cancellationToken); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,5 +3,5 @@ namespace Animelib.Dto.Animes; | |
public record AnimeListDto | ||
( | ||
IEnumerable<AnimeDto> Data, | ||
int total | ||
int Total | ||
); |
3 changes: 3 additions & 0 deletions
3
Animelib.Backend/Application/Animelib.Dto/Identity/CreateUserDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Animelib.Dto.Identity; | ||
|
||
public record CreateUserDto(string Username, string Email, string Password); |
3 changes: 3 additions & 0 deletions
3
Animelib.Backend/Application/Animelib.Dto/Identity/LoginUserDto.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
namespace Animelib.Dto.Identity; | ||
|
||
public record LoginUserDto(string Email, string Password); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Animelib.Backend/Domain/Animelib.Common/Validators/UserValidator.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using Animelib.Core.Users; | ||
using FluentValidation; | ||
|
||
namespace Animelib.Common.Validators; | ||
|
||
public class UserValidator : AbstractValidator<User> | ||
{ | ||
public UserValidator() | ||
{ | ||
RuleFor(user => user.Email) | ||
.NotEmpty() | ||
.NotNull() | ||
.EmailAddress() | ||
.WithMessage("Email can't be null or empty"); | ||
|
||
RuleFor(user => user.Username) | ||
.NotEmpty() | ||
.NotNull() | ||
.WithMessage("Email can't be null or empty"); | ||
|
||
RuleFor(user => user.Password) | ||
.Length(6, 20) | ||
.NotEmpty() | ||
.NotNull() | ||
.WithMessage("Password can't be null or empty"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using Animelib.Core.Animes; | ||
using RichEntity.Annotations; | ||
|
||
namespace Animelib.Core.Users; | ||
|
||
public partial class WatchList : IEntity<int> | ||
{ | ||
public WatchList(string name, User owner, IReadOnlyList<Anime> animes) | ||
{ | ||
Name = name; | ||
Owner = owner; | ||
Animes = animes; | ||
} | ||
|
||
public string Name { get; init; } | ||
public User Owner { get; init; } | ||
public IReadOnlyList<Anime> Animes { get; init; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,4 +19,4 @@ public static AnimeDto ToDto(this Anime anime) | |
anime.Subtype | ||
); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,4 +59,4 @@ public void Dispose() | |
{ | ||
_httpClient.Dispose(); | ||
} | ||
} | ||
} |
30 changes: 30 additions & 0 deletions
30
Animelib.Backend/Presentation/Animelib.Controllers/IdentityController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
using Animelib.Dto.Identity; | ||
using Animelib.Services.Abstractions; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace Animelib.Controllers; | ||
|
||
[Route("api/auth")] | ||
[ApiController] | ||
public class IdentityController : ControllerBase | ||
{ | ||
private readonly IIdentityService _service; | ||
|
||
public IdentityController(IIdentityService service) | ||
{ | ||
_service = service; | ||
} | ||
|
||
[HttpPost("signin")] | ||
public Task<ActionResult> Login([FromBody] LoginUserDto user) | ||
{ | ||
return Task.FromResult<ActionResult>(Ok()); | ||
} | ||
|
||
[HttpPost("signup")] | ||
public async Task<ActionResult> Register([FromBody] CreateUserDto user) | ||
{ | ||
await _service.CreateUserAsync(user); | ||
return Ok(); | ||
} | ||
} |
14 changes: 8 additions & 6 deletions
14
Animelib.Backend/Presentation/Animelib.WebApi/Animelib.WebApi.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net7.0</TargetFramework> | ||
<Nullable>enable</Nullable> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<RootNamespace>Animelib.Controllers</RootNamespace> | ||
<TreatWarningsAsErrors>true</TreatWarningsAsErrors> | ||
<UserSecretsId>3c297dff-8f10-408c-9b93-3833133940db</UserSecretsId> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="FluentValidation.AspNetCore" Version="11.3.0" /> | ||
<PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="7.0.5" /> | ||
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.5" /> | ||
<PackageReference Include="ronimizy.FluentSerialization.Extensions.NewtonsoftJson" Version="1.2.0" /> | ||
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.4.0" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\..\Application\Animelib.Dto\Animelib.Dto.csproj" /> | ||
<ProjectReference Include="..\..\Domain\Animelib.Common\Animelib.Common.csproj" /> | ||
<ProjectReference Include="..\..\Infrastructure\Animelib.DataAccess\Animelib.DataAccess.csproj" /> | ||
<ProjectReference Include="..\..\Infrastructure\Animelib.Seeding\Animelib.Seeding.csproj" /> | ||
<ProjectReference Include="..\Animelib.Controllers\Animelib.Controllers.csproj" /> | ||
<ProjectReference Include="..\..\Application\Animelib.Dto\Animelib.Dto.csproj" /> | ||
<ProjectReference Include="..\..\Domain\Animelib.Common\Animelib.Common.csproj" /> | ||
<ProjectReference Include="..\..\Infrastructure\Animelib.DataAccess\Animelib.DataAccess.csproj" /> | ||
<ProjectReference Include="..\..\Infrastructure\Animelib.Seeding\Animelib.Seeding.csproj" /> | ||
<ProjectReference Include="..\Animelib.Controllers\Animelib.Controllers.csproj" /> | ||
</ItemGroup> | ||
|
||
</Project> |
Oops, something went wrong.