Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion .runsettings
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
<CodeCoverage>
<ModulePaths>
<Exclude>
<ModulePath>*.Tests.*</ModulePath>
<ModulePath>Hikkaba.Tools.*</ModulePath>
<ModulePath>Hikkaba.Tests.*</ModulePath>
<ModulePath>Hikkaba.Paging.Tests.*</ModulePath>
</Exclude>
</ModulePaths>

Expand Down
2 changes: 1 addition & 1 deletion Hikkaba.Application/Contracts/IUserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface IUserService
Task<UserDetailsModel?> GetUserAsync(int userId, CancellationToken cancellationToken);
Task<UserCreateResultModel> CreateUserAsync(UserCreateRequestModel requestModel, CancellationToken cancellationToken);
Task<UserEditResultModel> EditUserAsync(UserEditRequestModel requestModel, CancellationToken cancellationToken);
Task SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken);
Task<UserDeleteResultModel> SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken);
}
4 changes: 2 additions & 2 deletions Hikkaba.Application/Implementations/UserService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ public async Task<UserEditResultModel> EditUserAsync(UserEditRequestModel reques
return await _userRepository.EditUserAsync(requestModel, cancellationToken);
}

public async Task SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken)
public async Task<UserDeleteResultModel> SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken)
{
await _userRepository.SetUserDeletedAsync(userId, isDeleted, cancellationToken);
return await _userRepository.SetUserDeletedAsync(userId, isDeleted, cancellationToken);
}
}
11 changes: 11 additions & 0 deletions Hikkaba.Infrastructure.Models/User/UserDeleteResultModel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using Hikkaba.Infrastructure.Models.Error;
using OneOf;
using OneOf.Types;

namespace Hikkaba.Infrastructure.Models.User;

[GenerateOneOf]
public sealed partial class UserDeleteResultModel
: OneOfBase<Success, DomainError>
{
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ public interface IUserRepository
Task<UserDetailsModel?> GetUserAsync(int userId, CancellationToken cancellationToken);
Task<UserCreateResultModel> CreateUserAsync(UserCreateRequestModel requestModel, CancellationToken cancellationToken);
Task<UserEditResultModel> EditUserAsync(UserEditRequestModel requestModel, CancellationToken cancellationToken);
Task SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken);
Task<UserDeleteResultModel> SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken);
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,17 +233,36 @@ public async Task<UserEditResultModel> EditUserAsync(UserEditRequestModel reques
return default(Success);
}

public async Task SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken)
public async Task<UserDeleteResultModel> SetUserDeletedAsync(int userId, bool isDeleted, CancellationToken cancellationToken)
{
await _applicationDbContext.Users
.TagWithCallSite()
.Where(user => user.Id == userId)
.ExecuteUpdateAsync(setProp =>
setProp.SetProperty(user => user.IsDeleted, isDeleted),
cancellationToken);
_logger.LogInformation(
LogEventIds.UserDeleted,
"User with ID {UserId} marked as deleted",
userId);
var user = await _userMgr.FindByIdAsync(userId.ToString(CultureInfo.InvariantCulture));

if (user is null)
{
_logger.LogWarning(
LogEventIds.UserDeleteError,
"User with ID {UserId} not found",
userId);

return new DomainError
{
StatusCode = (int)HttpStatusCode.NotFound,
ErrorMessage = $"User with ID {userId} not found.",
};
}
else
{
user.IsDeleted = isDeleted;

await _userMgr.UpdateAsync(user);
await _applicationDbContext.SaveChangesAsync(cancellationToken);

_logger.LogInformation(
LogEventIds.UserDeleted,
"User with ID {UserId} marked as deleted",
userId);

return default(Success);
}
}
}
1 change: 0 additions & 1 deletion Hikkaba.Paging.Tests.Unit/Hikkaba.Paging.Tests.Unit.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
<TargetFramework>net10.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>
Expand Down
1 change: 1 addition & 0 deletions Hikkaba.Tests.Integration/Hikkaba.Tests.Integration.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
Expand Down
171 changes: 86 additions & 85 deletions Hikkaba.Tests.Unit/Hikkaba.Tests.Unit.csproj
Original file line number Diff line number Diff line change
@@ -1,95 +1,96 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
</PropertyGroup>
<PropertyGroup>
<TargetFramework>net10.0</TargetFramework>
<Nullable>enable</Nullable>
<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="HttpContextMoq" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="Moq" />
<PackageReference Include="NetArchTest.Rules" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="coverlet.collector">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="coverlet.msbuild">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="HttpContextMoq" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Testing" />
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" />
<PackageReference Include="Microsoft.Extensions.TimeProvider.Testing" />
<PackageReference Include="Moq" />
<PackageReference Include="NetArchTest.Rules" />
<PackageReference Include="NUnit" />
<PackageReference Include="NUnit.Analyzers">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="NUnit3TestAdapter" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
</ItemGroup>

<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>
<ItemGroup>
<Using Include="NUnit.Framework" />
</ItemGroup>

<PropertyGroup>
<CodeAnalysisRuleSet>NUnit.Analyzers.Suppressions.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>
<PropertyGroup>
<CodeAnalysisRuleSet>NUnit.Analyzers.Suppressions.ruleset</CodeAnalysisRuleSet>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Hikkaba.Web\Hikkaba.Web.csproj" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Hikkaba.Web\Hikkaba.Web.csproj" />
</ItemGroup>

<ItemGroup>
<None Remove="nlog.config" />
<Content Include="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Update="Files\gif_animated.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_xyb.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_animated.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_static.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\webp_animated.webp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\webp_static.webp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_very_small.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_very_large.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_corrupted_1.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_corrupted_2.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\GeoLite2-ASN.mmdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\GeoLite2-Country.mmdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<None Remove="nlog.config" />
<Content Include="nlog.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
<None Update="Files\gif_animated.gif">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_xyb.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_animated.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_static.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\webp_animated.webp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\webp_static.webp">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_very_small.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\png_very_large.png">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_corrupted_1.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\jpg_corrupted_2.jpg">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\GeoLite2-ASN.mmdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="Files\GeoLite2-Country.mmdb">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>

<ItemGroup>
<Folder Include="Files\" />
</ItemGroup>
<ItemGroup>
<Folder Include="Files\" />
</ItemGroup>

</Project>
Loading