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.
This commit is contained in:
tekh 2025-06-26 13:53:54 +02:00
parent 39a9181257
commit 3de7e64f85
10 changed files with 20 additions and 6 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -74,7 +74,11 @@ namespace DigitalData.UserManager.Domain.Entities
[Column("DATE_FORMAT")] [Column("DATE_FORMAT")]
[StringLength(10)] [StringLength(10)]
[DefaultValue("dd.MM.yyyy")] [DefaultValue("dd.MM.yyyy")]
public string DateFormat { get; set; } public
#if NET7_0_OR_GREATER
required
#endif
string DateFormat { get; set; }
[Required] [Required]
[Column("ACTIVE")] [Column("ACTIVE")]

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.Contracts;
using DigitalData.UserManager.Infrastructure.Repositories; using DigitalData.UserManager.Infrastructure.Repositories;
using Microsoft.EntityFrameworkCore; using Microsoft.EntityFrameworkCore;
@ -37,7 +36,8 @@ public static class DependencyInjection
/// <param name="services">The <see cref="IServiceCollection"/> to which the services will be added.</param> /// <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> /// <param name="optionsAction">An <see cref="Action{T}"/> to configure the <see cref="DbContextOptionsBuilder"/>.</param>
/// <returns>The updated <see cref="IServiceCollection"/>.</returns> /// <returns>The updated <see cref="IServiceCollection"/>.</returns>
[Obsolete("Use IRepository")]
public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction) => services public static IServiceCollection AddUserManagerInfrastructure(this IServiceCollection services, Action<DbContextOptionsBuilder> optionsAction) => services
.AddDbContext<UserManagerDbContext>(optionsAction) .AddDbContext<UserManagerDbContext>(optionsAction)
.AddUserManagerInfrastructure<UserManagerDbContext>(); .AddUserManagerInfrastructure<UserManagerDbContext>();
} }

View File

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

View File

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