diff --git a/AccountManagement.Configuration/PmDbBootstrapper.cs b/AccountManagement.Configuration/PmDbBootstrapper.cs deleted file mode 100644 index 84d93fa8..00000000 --- a/AccountManagement.Configuration/PmDbBootstrapper.cs +++ /dev/null @@ -1,18 +0,0 @@ -using AccountManagement.Domain.PmDomains.PmRoleAgg; -using AccountManagement.Domain.PmDomains.PmUserAgg; -using AccountMangement.Infrastructure.EFCore.PmDbConetxt; -using AccountMangement.Infrastructure.EFCore.Repository.PmRepositories; -using Microsoft.EntityFrameworkCore; -using Microsoft.Extensions.DependencyInjection; - -namespace AccountManagement.Configuration; - -public class PmDbBootstrapper -{ - public static void Configure(IServiceCollection services, string connectionString) - { - services.AddTransient(); - services.AddTransient(); - services.AddDbContext(x => x.UseSqlServer(connectionString)); - } -} \ No newline at end of file diff --git a/AccountManagement.Domain/PmDomains/PmPermissionAgg/PmPermission.cs b/AccountManagement.Domain/PmDomains/PmPermissionAgg/PmPermission.cs deleted file mode 100644 index 691a9954..00000000 --- a/AccountManagement.Domain/PmDomains/PmPermissionAgg/PmPermission.cs +++ /dev/null @@ -1,20 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using AccountManagement.Domain.PmDomains.PmRoleAgg; - -namespace AccountManagement.Domain.PmDomains.PmPermissionAgg; - -public class PmPermission -{ - public long Id { get; private set; } - public int Code { get; private set; } - public PmRole Role { get; private set; } - - public PmPermission(int code) - { - Code = code; - } -} \ No newline at end of file diff --git a/AccountManagement.Domain/PmDomains/PmRoleAgg/IPmRoleRepository.cs b/AccountManagement.Domain/PmDomains/PmRoleAgg/IPmRoleRepository.cs deleted file mode 100644 index 49cb7f4e..00000000 --- a/AccountManagement.Domain/PmDomains/PmRoleAgg/IPmRoleRepository.cs +++ /dev/null @@ -1,15 +0,0 @@ -using _0_Framework.Domain; -using System.Collections.Generic; -using System.Threading.Tasks; -using AccountManagement.Application.Contracts.ProgramManager; - -namespace AccountManagement.Domain.PmDomains.PmRoleAgg; - -public interface IPmRoleRepository :IRepository -{ - Task> GetPmRoleList(long? gozareshgirRoleId); - - Task GetPmRoleToEdit(long gozareshgirRoleId); - -} - diff --git a/AccountManagement.Domain/PmDomains/PmRoleAgg/PmRole.cs b/AccountManagement.Domain/PmDomains/PmRoleAgg/PmRole.cs deleted file mode 100644 index ddb305ea..00000000 --- a/AccountManagement.Domain/PmDomains/PmRoleAgg/PmRole.cs +++ /dev/null @@ -1,46 +0,0 @@ -using System.Collections.Generic; -using _0_Framework.Domain; -using AccountManagement.Domain.PmDomains.PmPermissionAgg; - -namespace AccountManagement.Domain.PmDomains.PmRoleAgg; - -public class PmRole : EntityBase -{ - /// - /// نام نقش - /// - public string RoleName { get; private set; } - - - /// - /// لیست پرمیشن کد ها - /// - public List PmPermission { get; private set; } - - /// - /// ای دی نقش در گزارشگیر - /// - public long? GozareshgirRoleId { get; private set; } - - - protected PmRole() - { - } - - public PmRole(string roleName,long? gozareshgirRolId, List permissions) - { - RoleName = roleName; - PmPermission = permissions; - GozareshgirRoleId = gozareshgirRolId; - - } - - - public void Edit(string roleName, List permissions) - { - RoleName = roleName; - PmPermission = permissions; - } - - -} \ No newline at end of file diff --git a/AccountManagement.Domain/PmDomains/PmRoleUserAgg/PmRoleUser.cs b/AccountManagement.Domain/PmDomains/PmRoleUserAgg/PmRoleUser.cs deleted file mode 100644 index a7cf6355..00000000 --- a/AccountManagement.Domain/PmDomains/PmRoleUserAgg/PmRoleUser.cs +++ /dev/null @@ -1,19 +0,0 @@ -using AccountManagement.Domain.PmDomains.PmUserAgg; - -namespace AccountManagement.Domain.PmDomains.PmRoleUserAgg; - -public class PmRoleUser -{ - public PmRoleUser(long roleId) - { - RoleId = roleId; - } - - public long Id { get; private set; } - public long RoleId { get; private set; } - - - public PmUser User { get; set; } - - -} \ No newline at end of file diff --git a/AccountManagement.Domain/PmDomains/PmUserAgg/IPmUserRepository.cs b/AccountManagement.Domain/PmDomains/PmUserAgg/IPmUserRepository.cs deleted file mode 100644 index 52c28fc1..00000000 --- a/AccountManagement.Domain/PmDomains/PmUserAgg/IPmUserRepository.cs +++ /dev/null @@ -1,22 +0,0 @@ -using _0_Framework.Domain; -using AccountManagement.Application.Contracts.ProgramManager; -using System.Threading.Tasks; -using Shared.Contracts.PmUser.Queries; - -namespace AccountManagement.Domain.PmDomains.PmUserAgg; - -public interface IPmUserRepository : IRepository -{ - /// - /// دریافت کاربر پروگرام منیجر جهتد ویرایش - /// - /// - /// - Task GetByPmUsertoEditbyAccountId(long accountId); - /// - /// دریافت کرابر پروگرام منیجر با اکانت آی دی در گزارشگیر - /// - /// - /// - Task GetPmUserByAccountId(long accountId); -} \ No newline at end of file diff --git a/AccountManagement.Domain/PmDomains/PmUserAgg/PmUser.cs b/AccountManagement.Domain/PmDomains/PmUserAgg/PmUser.cs deleted file mode 100644 index 6b0c531a..00000000 --- a/AccountManagement.Domain/PmDomains/PmUserAgg/PmUser.cs +++ /dev/null @@ -1,127 +0,0 @@ -using System; -using System.Collections.Generic; -using _0_Framework.Domain; -using AccountManagement.Domain.PmDomains.PmRoleUserAgg; - - -namespace AccountManagement.Domain.PmDomains.PmUserAgg; - -/// -/// کاربر -/// -public class PmUser : EntityBase -{ - /// - /// ایجاد - /// - /// - /// - /// - /// - /// - /// - /// - public PmUser(string fullName, string userName, string password, string mobile, string email, long? accountId, List roles) - { - FullName = fullName; - UserName = userName; - Password = password; - Mobile = mobile; - Email = email; - IsActive = true; - AccountId = accountId; - RoleUser = roles; - } - - protected PmUser() - { - - } - /// - /// نام و نام خانوادگی - /// - public string FullName { get; private set; } - - /// - /// نام کاربری - /// - public string UserName { get; private set; } - - /// - /// گذرواژه - /// - public string Password { get; private set; } - - /// - /// مسیر عکس پروفایل - /// - public string ProfilePhotoPath { get; private set; } - - /// - /// شماره موبایل - /// - public string Mobile { get; set; } - - /// - /// ایمیل - /// - public string Email { get; private set; } - - /// - /// فعال/غیر فعال بودن یوزر - /// - public bool IsActive { get; private set; } - - - /// - /// کد یکبارمصرف ورود - /// - public string VerifyCode { get; private set; } - - /// - /// آی دی کاربر در گزارشگیر - /// - public long? AccountId { get; private set; } - - - /// - /// لیست پرمیشن کد ها - /// - public List RoleUser { get; private set; } - - - /// - /// آپدیت کاربر - /// - /// - /// - /// - /// - /// - public void Edit(string fullName, string userName, string mobile, List roles, bool isActive) - { - FullName = fullName; - UserName = userName; - Mobile = mobile; - RoleUser = roles; - IsActive = isActive; - } - - /// - /// غیرفعال سازی - /// - public void DeActive() - { - IsActive = false; - } - - /// - /// فعال سازی - /// - public void ReActive() - { - IsActive = true; - } - - -} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmRoleMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmRoleMapping.cs deleted file mode 100644 index 00324b3d..00000000 --- a/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmRoleMapping.cs +++ /dev/null @@ -1,24 +0,0 @@ -using AccountManagement.Domain.PmDomains.PmRoleAgg; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings; - -public class PmRoleMapping : IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("PmRoles", t => t.ExcludeFromMigrations()); - builder.HasKey(x => x.id); - - builder.Property(x => x.RoleName).HasMaxLength(100).IsRequired(); - - builder.OwnsMany(x => x.PmPermission, navigationBuilder => - { - navigationBuilder.HasKey(x => x.Id); - navigationBuilder.ToTable("PmRolePermissions", t => t.ExcludeFromMigrations()); - - navigationBuilder.WithOwner(x => x.Role); - }); - } -} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmUserMapping.cs b/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmUserMapping.cs deleted file mode 100644 index 9ee5e126..00000000 --- a/AccountMangement.Infrastructure.EFCore/Mappings/PmMappings/PmUserMapping.cs +++ /dev/null @@ -1,30 +0,0 @@ -using AccountManagement.Domain.PmDomains.PmUserAgg; -using Microsoft.EntityFrameworkCore; -using Microsoft.EntityFrameworkCore.Metadata.Builders; - -namespace AccountMangement.Infrastructure.EFCore.Mappings.PmMappings; - -public class PmUserMapping :IEntityTypeConfiguration -{ - public void Configure(EntityTypeBuilder builder) - { - builder.ToTable("Users"); - builder.HasKey(x => x.id); - - builder.Property(x => x.FullName).HasMaxLength(100).IsRequired(); - builder.Property(x => x.UserName).HasMaxLength(100).IsRequired(); - builder.Property(x => x.Password).HasMaxLength(1000).IsRequired(); - builder.Property(x => x.ProfilePhotoPath).HasMaxLength(500).IsRequired(false); - builder.Property(x => x.Mobile).HasMaxLength(20).IsRequired(); - builder.Property(x => x.Email).HasMaxLength(150).IsRequired(false); ; - builder.Property(x => x.VerifyCode).HasMaxLength(10).IsRequired(false); - builder.OwnsMany(x => x.RoleUser, navigationBuilder => - { - navigationBuilder.HasKey(x => x.Id); - navigationBuilder.ToTable("RoleUsers"); - navigationBuilder.WithOwner(x => x.User); - }); - - - } -} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/PmDbConetxt/PmDbContext.cs b/AccountMangement.Infrastructure.EFCore/PmDbConetxt/PmDbContext.cs deleted file mode 100644 index a668490e..00000000 --- a/AccountMangement.Infrastructure.EFCore/PmDbConetxt/PmDbContext.cs +++ /dev/null @@ -1,32 +0,0 @@ -using AccountManagement.Domain.PmDomains.PmRoleAgg; -using AccountManagement.Domain.PmDomains.PmUserAgg; -using AccountMangement.Infrastructure.EFCore.Mappings; -using AccountMangement.Infrastructure.EFCore.Mappings.PmMappings; -using Microsoft.EntityFrameworkCore; - -namespace AccountMangement.Infrastructure.EFCore.PmDbConetxt; - -public class PmDbContext : DbContext -{ - public PmDbContext(DbContextOptions options) : base(options) - { - - } - public DbSet Users { get; set; } = null!; - public DbSet PmRoles { get; set; } = null!; - - - public PmDbContext() - { - - } - - - protected override void OnModelCreating(ModelBuilder modelBuilder) - { - var assembly = typeof(PmUserMapping).Assembly; - modelBuilder.ApplyConfigurationsFromAssembly(assembly); - //SubAccountPermissionSeeder.Seed(modelBuilder); - base.OnModelCreating(modelBuilder); - } -} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmRoleRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmRoleRepository.cs deleted file mode 100644 index e3f93e53..00000000 --- a/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmRoleRepository.cs +++ /dev/null @@ -1,49 +0,0 @@ -using _0_Framework.InfraStructure; -using AccountManagement.Application.Contracts.ProgramManager; -using AccountManagement.Domain.PmDomains.PmRoleAgg; -using AccountMangement.Infrastructure.EFCore.PmDbConetxt; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; -using System.Threading; -using System.Threading.Tasks; -using static Microsoft.EntityFrameworkCore.DbLoggerCategory; - -namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories; - -public class PmRoleRepository : RepositoryBase, IPmRoleRepository -{ - private readonly PmDbContext _pmDbContext; - public PmRoleRepository(PmDbContext context) : base(context) - { - _pmDbContext = context; - } - - public async Task> GetPmRoleList(long? gozareshgirRoleId) - { - var query = _pmDbContext.PmRoles.AsQueryable(); - if (gozareshgirRoleId != null && gozareshgirRoleId > 0) - query = query.Where(x => x.GozareshgirRoleId == gozareshgirRoleId); - var res = await query - .Select(p => new GetPmRolesDto() - { - Id = p.id, - RoleName = p.RoleName, - GozareshgirRoleId = p.GozareshgirRoleId, - Permissions = p.PmPermission.Select(x => x.Code).ToList() - - }) - .ToListAsync(); - - return res; - } - - - - public async Task GetPmRoleToEdit(long gozareshgirRoleId) - { - return await _pmDbContext.PmRoles.FirstOrDefaultAsync(x => x.GozareshgirRoleId == gozareshgirRoleId); - - } - -} \ No newline at end of file diff --git a/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmUserRepository.cs b/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmUserRepository.cs deleted file mode 100644 index e4915a65..00000000 --- a/AccountMangement.Infrastructure.EFCore/Repository/PmRepositories/PmUserRepository.cs +++ /dev/null @@ -1,48 +0,0 @@ -using _0_Framework.InfraStructure; -using AccountManagement.Application.Contracts.ProgramManager; -using AccountManagement.Domain.PmDomains.PmUserAgg; -using AccountMangement.Infrastructure.EFCore.PmDbConetxt; -using Microsoft.EntityFrameworkCore; -using System.Collections.Generic; -using System.Linq; -using System.Threading.Tasks; -using Shared.Contracts.PmUser.Queries; - -namespace AccountMangement.Infrastructure.EFCore.Repository.PmRepositories; - -public class PmUserRepository :RepositoryBase, IPmUserRepository -{ - private readonly PmDbContext _pmDbContext; - public PmUserRepository(PmDbContext context, PmDbContext pmDbContext) : base(context) - { - _pmDbContext = pmDbContext; - } - public async Task GetByPmUsertoEditbyAccountId(long accountId) - { - return await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId); - } - - public async Task GetPmUserByAccountId(long accountId) - { - var query = await _pmDbContext.Users.FirstOrDefaultAsync(x => x.AccountId == accountId); - if (query == null) - return new GetPmUserDto(); - List roles = query.RoleUser.Select(x => x.RoleId).ToList(); - return new GetPmUserDto() - { - FullName = query.FullName, - UserName = query.UserName, - ProfilePhotoPath = query.ProfilePhotoPath, - Mobile = query.Mobile, - IsActive = query.IsActive, - AccountId = query.AccountId, - Roles = roles, - RoleListDto = await _pmDbContext.PmRoles.Where(x => roles.Contains(x.id)).Select(x => new RoleListDto() - { - RoleName = x.RoleName, - RoleId = x.id, - Permissions = x.PmPermission.Select(x => x.Code).ToList() - }).ToListAsync(), - }; - } -} \ No newline at end of file