TekH 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

41 lines
1.7 KiB
C#

using DigitalData.Core.Infrastructure;
using DigitalData.UserManager.Application.Contracts.Repositories;
using DigitalData.UserManager.Domain.Entities;
using DigitalData.UserManager.Infrastructure.Contracts;
using Microsoft.EntityFrameworkCore;
namespace DigitalData.UserManager.Infrastructure.Repositories
{
[Obsolete("Use Repository")]
public class GroupRepository<TDbContext> : CRUDRepository<Group, int, TDbContext>, IGroupRepository
where TDbContext : DbContext, IUserManagerDbContext
{
private readonly IGroupOfUserRepository _gouRepo;
private readonly IUserRepRepository _uRepRepo;
public GroupRepository(TDbContext dbContext, IGroupOfUserRepository gouRepo, IUserRepRepository userRepRepository) : base(dbContext, dbContext.Groups)
{
_gouRepo = gouRepo;
_uRepRepo = userRepRepository;
}
//TODO: instead of this implmenet .OnDelete(DeleteBehavior.ClientCascade) in DbContext
public override async Task<bool> DeleteAsync(Group group)
{
var gou_list = await _gouRepo.ReadAsync(readOnly: false, groupId: group.Id);
if (gou_list.Any())
_dbContext.RemoveRange(gou_list);
var uRep_list = await _uRepRepo.ReadAllAsync(readOnly: false, groupId: group.Id);
if (uRep_list.Any())
_dbContext.RemoveRange(uRep_list);
uRep_list = await _uRepRepo.ReadAllAsync(readOnly: false, repGroupId: group.Id);
if (uRep_list.Any())
_dbContext.RemoveRange(uRep_list);
return await base.DeleteAsync(group);
}
}
}