Compare commits

...

5 Commits

Author SHA1 Message Date
53bfc4a413 Suppress warnings for obsolete members and update repo
Added warning suppression in `Program.cs` for obsolete user manager configuration. Marked `ClientUserRepository` as obsolete to encourage transition to the new `Repository` class.
2025-06-26 13:56:42 +02:00
3de7e64f85 Deprecate services and update mapping profiles
- Added obsolete attributes to `AuthController`, `ModuleController`, and various mapping profiles, recommending the use of MediatR and DigitalData.Core.Exceptions.
- Updated `User` class to use `required` keyword for `DateFormat` in .NET 7.0 or greater.
- Marked methods in `Extensions` and `AddUserManagerInfrastructure` as obsolete, suggesting the use of IRepository.
- Adjusted import statements in `DependencyInjection.cs` and marked `GroupOfUserRepository` and `ModuleRepository` as obsolete, recommending a Repository pattern.
2025-06-26 13:53:54 +02:00
39a9181257 Deprecate methods and classes in UserManager.Application
Introduce `[Obsolete]` attributes to various methods and classes, suggesting alternatives such as MediatR and IRepository. Mark multiple DTOs and repository classes as obsolete, recommending the use of DigitalData.Core.Exceptions and .Middleware or Repository. This change aims to enhance maintainability and clarity in the codebase.
2025-06-26 13:37:59 +02:00
5d3f73bb13 Refactor entity properties for nullability and requirements
Removed nullable indicators from string properties in
BaseEntity.cs, ClientUser.cs, Group.cs, and User.cs.
The Username property in User.cs is now marked as
required for .NET 7 or greater, improving data integrity
and reducing null reference risks.
2025-06-26 13:20:54 +02:00
bc44de63ee Update project for multi-targeting and nullable types
Updated `DigitalData.UserManager.Domain.csproj` to support .NET 4.6.2, 7.0, 8.0, and 9.0. Adjusted implicit usings and nullable reference types settings based on the target framework, disabling nullable types for `net462` and enabling them for others.

Refactored entity classes (`BaseEntity`, `ClientUser`, `Group`, `GroupOfUser`, `Module`, `ModuleOfUser`, `User`, and `UserRep`) to conditionally include nullable reference types. Added `?` operator for string properties in .NET 7.0 and above, enhancing code safety and reducing null reference exceptions.
2025-06-26 13:15:36 +02:00
28 changed files with 70 additions and 45 deletions

View File

@ -13,6 +13,7 @@ namespace DigitalData.UserManager.API.Controllers;
[ApiController]
public class AuthController : ControllerBase
{
[Obsolete("Use MediatR")]
private readonly ILogger<UserController> _logger;
[Obsolete("Use MediatR")]
private readonly IUserService _userService;

View File

@ -7,8 +7,10 @@ using Microsoft.AspNetCore.Authorization;
namespace DigitalData.UserManager.API.Controllers;
[Authorize]
[Obsolete("Use MediatR")]
public class ModuleController : ReadControllerBaseWithErrorHandling<IModuleService, ModuleDto, Module, int>
{
[Obsolete("Use MediatR")]
public ModuleController(ILogger<ModuleController> logger, IModuleService service) : base(logger, service)
{
}

View File

@ -70,7 +70,9 @@ try {
// Once the app is built, the password will be decrypted with Encryptor. lazy loading also acts as a call back method.
Lazy<string>? cnn_str = null;
#pragma warning disable CS0618 // Type or member is obsolete
builder.Services.AddUserManager(options => options.UseSqlServer(cnn_str!.Value).EnableSensitiveDataLogging());
#pragma warning restore CS0618 // Type or member is obsolete
var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get<string[]>() ?? throw new InvalidOperationException("In appsettings there is no allowed origin.");

View File

@ -16,6 +16,7 @@ namespace DigitalData.UserManager.Application
/// <typeparam name="TDbContext">The type of the DbContext to use for the repositories.</typeparam>
/// <param name="services">The IServiceCollection to which the services will be added.</param>
/// <returns>The updated IServiceCollection.</returns>
[Obsolete("Use MediatR")]
public static IServiceCollection AddUserManagerApplication(this IServiceCollection services)
=> services
.AddAutoMapper(typeof(UserMappingProfile).Assembly)

View File

@ -2,6 +2,7 @@
namespace DigitalData.UserManager.Application.DTOs.Group
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public record GroupReadDto
(
int Id,

View File

@ -4,6 +4,7 @@ using DigitalData.UserManager.Application.DTOs.User;
namespace DigitalData.UserManager.Application.DTOs.GroupOfUser
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public record GroupOfUserReadDto(
int Id,
int UserId,

View File

@ -4,6 +4,7 @@ using DigitalData.UserManager.Application.DTOs.User;
namespace DigitalData.UserManager.Application.DTOs.UserRep
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public record UserRepReadDto(
int Id,
int? UserId,

View File

@ -6,6 +6,7 @@ namespace DigitalData.UserManager.Application.MappingProfiles
{
public class GroupMappingProfile : Profile
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public GroupMappingProfile()
{
CreateMap<Group, GroupCreateDto>();

View File

@ -6,6 +6,7 @@ namespace DigitalData.UserManager.Application.MappingProfiles
{
public class GroupOfUserMappingProfile : Profile
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public GroupOfUserMappingProfile()
{
CreateMap<GroupOfUser, GroupOfUserCreateDto>();
@ -17,4 +18,4 @@ namespace DigitalData.UserManager.Application.MappingProfiles
CreateMap<GroupOfUserUpdateDto, GroupOfUser>();
}
}
}
}

View File

@ -6,6 +6,7 @@ namespace DigitalData.UserManager.Application.MappingProfiles
{
public class UserRepMappingProfile : Profile
{
[Obsolete("Use DigitalData.Core.Exceptions and .Middleware")]
public UserRepMappingProfile()
{
CreateMap<UserRep, UserRepCreateDto>();

View File

@ -8,6 +8,7 @@ namespace DigitalData.UserManager.DependencyInjection;
public static class Extensions
{
[Obsolete("Use IRepository")]
public static IServiceCollection AddUserManager<TDbContext>(this IServiceCollection services)
where TDbContext : DbContext, IUserManagerDbContext
{
@ -16,10 +17,11 @@ public static class Extensions
return services;
}
[Obsolete("Use MediatR")]
public static IServiceCollection AddUserManager(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction)
{
services.AddUserManagerInfrastructure(optionsAction);
services.AddUserManagerApplication();
return services;
}
}
}

View File

@ -2,8 +2,6 @@
<PropertyGroup>
<TargetFrameworks>net462;net7.0;net8.0;net9.0</TargetFrameworks>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<PackageId>UserManager.Domain</PackageId>
<Version>3.1.0</Version>
<Authors>Digital Data GmbH</Authors>
@ -19,11 +17,13 @@
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' == 'net462'">
<Nullable>disable</Nullable>
<ImplicitUsings>disable</ImplicitUsings>
<LangVersion>7.3</LangVersion>
</PropertyGroup>
<PropertyGroup Condition="'$(TargetFramework)' != 'net462'">
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<LangVersion>latest</LangVersion>
</PropertyGroup>

View File

@ -17,20 +17,18 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
[Column("ADDED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho
{ get; set; }
AddedWho { get; set; }
[StringLength(50)]
[Column("CHANGED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ChangedWho
{ get; set; }
ChangedWho { get; set; }
//TODO: assign it to default value in create dto, not here!
[Column("ADDED_WHEN", TypeName = "datetime")]

View File

@ -25,20 +25,18 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment
{ get; set; }
Comment { get; set; }
[StringLength(50)]
[Column("ADDED_WHO")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho
{ get; set; }
AddedWho { get; set; }
[Column("ADDED_WHEN", TypeName = "datetime")]
[DefaultValue("GETDATE()")]

View File

@ -9,7 +9,7 @@ namespace DigitalData.UserManager.Domain.Entities
{
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -29,11 +29,10 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment
{ get; set; }
Comment { get; set; }
// TODO: this column should be assigned by triggers. despite this it is not null and this is problem for creation. talk with others
[Required]

View File

@ -16,21 +16,21 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("GroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Group { get; set; }

View File

@ -13,7 +13,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -21,7 +21,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(20)]
[Column("SHORT_NAME")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ShortName { get; set; }

View File

@ -22,7 +22,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
[StringLength(200)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }
@ -30,7 +30,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("ADDED_WHO")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
AddedWho { get; set; } = "DEFAULT";
@ -38,21 +38,21 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("CHANGED_WHO")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
ChangedWho { get; set; }
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("ModuleId")]
public virtual Module
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Module { get; set; }

View File

@ -10,7 +10,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("PRENAME")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Prename { get; set; }
@ -18,7 +18,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("NAME")]
[StringLength(50)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Name { get; set; }
@ -26,12 +26,16 @@ namespace DigitalData.UserManager.Domain.Entities
[Required]
[Column("USERNAME")]
[StringLength(50)]
public string Username { get; set; }
public
#if NET7_0_OR_GREATER
required
#endif
string Username { get; set; }
[Column("SHORTNAME")]
[StringLength(30)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Shortname
@ -40,7 +44,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("EMAIL")]
[StringLength(100)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Email { get; set; }
@ -50,7 +54,7 @@ namespace DigitalData.UserManager.Domain.Entities
[StringLength(5)]
[DefaultValue("de-DE")]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Language { get; set; }
@ -58,7 +62,7 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("COMMENT")]
[StringLength(500)]
public string
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Comment { get; set; }
@ -70,7 +74,11 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("DATE_FORMAT")]
[StringLength(10)]
[DefaultValue("dd.MM.yyyy")]
public string DateFormat { get; set; }
public
#if NET7_0_OR_GREATER
required
#endif
string DateFormat { get; set; }
[Required]
[Column("ACTIVE")]

View File

@ -28,28 +28,28 @@ namespace DigitalData.UserManager.Domain.Entities
[ForeignKey("UserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
User { get; set; }
[ForeignKey("RepGroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
RepGroup { get; set; }
[ForeignKey("GroupId")]
public virtual Group
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
Group { get; set; }
[ForeignKey("RepUserId")]
public virtual User
#if NET6_0_OR_GREATER
#if NET7_0_OR_GREATER
?
#endif
RepUser { get; set; }

View File

@ -1,5 +1,4 @@
using DigitalData.UserManager.Application;
using DigitalData.UserManager.Application.Contracts.Repositories;
using DigitalData.UserManager.Application.Contracts.Repositories;
using DigitalData.UserManager.Infrastructure.Contracts;
using DigitalData.UserManager.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore;
@ -16,6 +15,7 @@ public static class DependencyInjection
/// <typeparam name="TDbContext">The type of the DbContext to use for the repositories.</typeparam>
/// <param name="services">The IServiceCollection to which the services will be added.</param>
/// <returns>The updated IServiceCollection.</returns>
[Obsolete("Use IRepository")]
public static IServiceCollection AddUserManagerInfrastructure<TDbContext>(this IServiceCollection services)
where TDbContext : DbContext, IUserManagerDbContext
{
@ -36,7 +36,8 @@ public static class DependencyInjection
/// <param name="services">The <see cref="IServiceCollection"/> to which the services will be added.</param>
/// <param name="optionsAction">An <see cref="Action{T}"/> to configure the <see cref="DbContextOptionsBuilder"/>.</param>
/// <returns>The updated <see cref="IServiceCollection"/>.</returns>
[Obsolete("Use IRepository")]
public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction) => services
.AddDbContext<UserManagerDbContext>(optionsAction)
.AddUserManagerInfrastructure<UserManagerDbContext>();
}
}

View File

@ -6,6 +6,7 @@ using DigitalData.UserManager.Infrastructure.Contracts;
namespace DigitalData.UserManager.Infrastructure.Repositories
{
[Obsolete("Use Repository")]
public class ClientUserRepository<TDbContext> : CRUDRepository<ClientUser, int, TDbContext>, IClientUserRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using DigitalData.UserManager.Application.Contracts.Repositories;
namespace DigitalData.UserManager.Infrastructure.Repositories
{
[Obsolete("Use Repository")]
public class GroupOfUserRepository<TDbContext> : CRUDRepository<GroupOfUser, int, TDbContext>, IGroupOfUserRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories
{
[Obsolete("Use Repository")]
public class GroupRepository<TDbContext> : CRUDRepository<Group, int, TDbContext>, IGroupRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class ModuleOfUserRepository<TDbContext> : CRUDRepository<ModuleOfUser, int, TDbContext>, IModuleOfUserRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class ModuleRepository<TDbContext> : CRUDRepository<Module, int, TDbContext>, IModuleRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories;
[Obsolete("Use Repository")]
public class UserRepRepository<TDbContext> : CRUDRepository<UserRep, int, TDbContext>, IUserRepRepository
where TDbContext : DbContext, IUserManagerDbContext
{

View File

@ -6,6 +6,7 @@ using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories
{
[Obsolete("Use Repository")]
public class UserRepository<TDbContext> : CRUDRepository<User, int, TDbContext>, IUserRepository
where TDbContext : DbContext, IUserManagerDbContext
{