Explorar el Código

SubscriptionConfig

zinab_elgendy hace 2 meses
padre
commit
cbb50da618

+ 66 - 0
MTWorkHR.API/Controllers/SubscriptionController.cs

@@ -0,0 +1,66 @@
+using Microsoft.AspNetCore.Authorization;
+
+using Microsoft.AspNetCore.Http;
+using Microsoft.AspNetCore.Mvc;
+using MTWorkHR.Application.Filters;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Identity.Services;
+
+namespace MTWorkHR.API.Controllers
+{
+    [Route("api/[controller]")]
+    [ApiController]
+    [AppAuthorize]
+    public class SubscriptionController : ControllerBase
+    {
+        private readonly ISubscriptionService _SubscriptionConfigurationService;
+        public SubscriptionController(ISubscriptionService UserSubscriptionConfigurationService)
+        {
+            this._SubscriptionConfigurationService = UserSubscriptionConfigurationService;
+        }
+        [HttpGet("GetAll")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<List<SubscriptionConfigurationDto>>> GetAll([FromQuery] PagingInputDto pagingInput)
+        {
+            return Ok(await _SubscriptionConfigurationService.GetAll(pagingInput));
+        }
+        [HttpGet("Get")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+
+        public async Task<ActionResult<SubscriptionConfigurationDto>> Get(long SubscriptionConfigurationId)
+        {
+            return Ok(await _SubscriptionConfigurationService.GetById(SubscriptionConfigurationId));
+        }
+
+
+        [HttpPost("Create")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [Authorize(Policy = "SuperAdminOnly")]
+        public async Task<ActionResult<SubscriptionConfigurationDto>> Create([FromBody] SubscriptionConfigurationDto input)
+        {
+            return await _SubscriptionConfigurationService.Create(input);
+        }
+
+        [HttpPost("Update")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [Authorize(Policy = "SuperAdminOnly")]
+        public async Task<ActionResult<SubscriptionConfigurationDto>> Update([FromBody] SubscriptionConfigurationDto input)
+        {
+            return await _SubscriptionConfigurationService.Update(input);
+        }
+
+        [HttpDelete("Delete")]
+        [ProducesResponseType(StatusCodes.Status200OK)]
+        [Authorize(Policy = "SuperAdminOnly")]
+        public async Task Delete([FromQuery]long id)
+        {
+            await _SubscriptionConfigurationService.Delete(id);
+        }
+
+
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/ApplicationServiceRegistration.cs

@@ -41,6 +41,7 @@ namespace MTWorkHR.Application
             services.AddScoped<IProjectStageAttachmentService, ProjectStageAttachmentService>();
             services.AddScoped<IOTPService, OTPService>();
             services.AddScoped<ILogService<UserLog>, LogService<UserLog>>();
+            services.AddScoped<ISubscriptionService, SubscriptionService>();
             services.AddScoped<IMatchMoveService, MatchMoveService>();
 
             return services;

+ 28 - 0
MTWorkHR.Application/Dtos/Payment/SubscriptionConfigurationDto.cs

@@ -0,0 +1,28 @@
+using System;
+using MTWorkHR.Core.Entities.Base;
+
+namespace MTWorkHR.Application.Models
+{
+    public class SubscriptionConfigurationDto : EntityDto
+    {
+        public decimal? FirstRegisterationCompanyFees { get; set; }
+        public decimal? MonthlyCompanyFees { get; set; }
+        public decimal? YearlyCompanyFees { get; set; }
+        public decimal? MonthlyEmployeeServicesCompanyFees { get; set; }
+        public decimal? DistinguishedEmployeeCompanyFeesPerc { get; set; }
+
+
+
+
+        //--------------------------forms for Employee------------------
+        public decimal? OrdinaryEmployeePerc { get; set; }
+        public decimal? DistinguishedEmployeePerc { get; set; }
+        public decimal? DeductedFirstSearchAmount { get; set; }
+        public decimal? ContractDocumentationFees { get; set; }
+        public decimal? ExperienceCertificateFees { get; set; }
+        public decimal? RequestDisputeResolutionFees { get; set; }
+
+
+
+    }
+}

+ 1 - 0
MTWorkHR.Application/Mapper/MappingProfile.cs

@@ -148,6 +148,7 @@ namespace MTWorkHR.Application.Mapper
             CreateMap<ContractTaskAttachment, ContractTaskAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ProjectStage, ProjectStageDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ProjectStageAttachment, ProjectStageAttachmentDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<SubscriptionConfiguration, SubscriptionConfigurationDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
 
 
         }

+ 1 - 1
MTWorkHR.Application/Middlewares/LoggingMiddleware.cs

@@ -107,7 +107,7 @@ namespace MTWorkHR.Application.Middlewares
                             await context.Response.WriteAsJsonAsync(
                              new BadRequestResult
                              {
-                                 ErrorMsg = "" + ((AppException)error).ErrorMessage + "",
+                                 ErrorMsg = errorNum ==0 ? "Internal Server Error" :  "" + ((AppException)error).ErrorMessage + "",
                                  ErrorNo = (int)errorNum
                              });
                             return;

+ 12 - 0
MTWorkHR.Application/Services/Interfaces/Payment/ISubscriptionService.cs

@@ -0,0 +1,12 @@
+
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Application.Services.Interfaces
+{
+    public interface ISubscriptionService : IService<SubscriptionConfiguration, SubscriptionConfigurationDto, SubscriptionConfigurationDto>
+    {
+
+    }
+}

+ 41 - 0
MTWorkHR.Application/Services/Payment/SubscriptionService.cs

@@ -0,0 +1,41 @@
+using Microsoft.AspNetCore.Identity;
+using Microsoft.AspNetCore.WebUtilities;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.Extensions.Configuration;
+using MTWorkHR.Application.Identity;
+using MTWorkHR.Application.Mapper;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Global;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Core.UnitOfWork;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Application.Services.Interfaces;
+using MTWorkHR.Core.Email;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Infrastructure.UnitOfWorks;
+using System.Linq.Dynamic.Core;
+
+namespace MTWorkHR.Application.Services
+{
+    public class SubscriptionService : BaseService<SubscriptionConfiguration, SubscriptionConfigurationDto, SubscriptionConfigurationDto>, ISubscriptionService
+    {
+        private readonly IUnitOfWork _unitOfWork;
+        //private readonly AppSettingsConfiguration _configuration;
+        //private readonly GlobalInfo _globalInfo;
+
+        public SubscriptionService(IUnitOfWork unitOfWork) : base(unitOfWork)
+        {
+            _unitOfWork = unitOfWork;
+        }
+
+        public override async Task<SubscriptionConfigurationDto> GetById(long id)
+        {
+            var entity = await _unitOfWork.SubscriptionConfiguration.GetByIdAsync(id);
+            var response = MapperObject.Mapper.Map<SubscriptionConfigurationDto>(entity);
+            return response;
+        }
+      
+      
+
+    }
+}

+ 37 - 0
MTWorkHR.Core/Entities/Payment/SubscriptionConfigurationDto.cs

@@ -0,0 +1,37 @@
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class SubscriptionConfiguration : FullAuditEntity
+    {
+
+
+        //--------------------------forms for Companies------------------
+        public decimal? FirstRegisterationCompanyFees { get; set; }
+        public decimal? MonthlyCompanyFees { get; set; }
+        public decimal? YearlyCompanyFees { get; set; }
+        public decimal? MonthlyEmployeeServicesCompanyFees { get; set; }
+        public decimal? DistinguishedEmployeeCompanyFeesPerc { get; set; }
+
+
+
+
+        //--------------------------forms for Employee------------------
+        public decimal? OrdinaryEmployeePerc { get; set; }
+        public decimal? DistinguishedEmployeePerc { get; set; }
+        public decimal? DeductedFirstSearchAmount { get; set; }
+        public decimal? ContractDocumentationFees { get; set; }
+        public decimal? ExperienceCertificateFees { get; set; }
+        public decimal? RequestDisputeResolutionFees { get; set; }
+      
+
+    }
+}

+ 15 - 0
MTWorkHR.Core/IRepositories/Payment/ISubscriptionConfigurationRepository.cs

@@ -0,0 +1,15 @@
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IRepositories.Base;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace MTWorkHR.Core.IRepositories
+{
+    public interface ISubscriptionConfigurationRepository : IRepository<SubscriptionConfiguration>
+    {
+       
+    }
+}

+ 1 - 1
MTWorkHR.Core/IUnitOfWork/IUnitOfWork.cs

@@ -41,7 +41,7 @@ namespace MTWorkHR.Core.UnitOfWork
         IProjectStageAttachmentRepository ProjectStageAttachment { get; }
 
         IHubConnectionRepository HubConnection { get; }
-
+        ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
         Task<int> CompleteAsync();
 
         void BeginTran();

+ 1 - 0
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -54,6 +54,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         //-----------
         public DbSet<Contract> Contracts { get; set; }
         public DbSet<Nationality> Nationalities{ get; set; }
+        public DbSet<SubscriptionConfiguration> SubscriptionConfiguration { get; set; }
 
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }

+ 1 - 2
MTWorkHR.Infrastructure/InfrastructureServiceRegistration.cs

@@ -106,11 +106,11 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped(typeof(IContractRepository), typeof(ContractRepository));
             services.AddScoped(typeof(IContractTaskAttachmentRepository), typeof(ContractTaskAttachmentRepository));
             services.AddScoped(typeof(IProjectStageAttachmentRepository), typeof(ProjectStageAttachmentRepository));
+            services.AddScoped(typeof(ISubscriptionConfigurationRepository), typeof(SubscriptionConfigurationRepository));
 
             services.AddScoped(typeof(IHubConnectionRepository), typeof(HubConnectionRepository));
             
 
-
             services.AddScoped(typeof(IPermissionRepository), typeof(PermissionRepository));
             services.AddScoped(typeof(IRolePermissionRepository<RolePermission>), typeof(RolePermissionRepository));
             services.AddScoped(typeof(IUserRoleRepository<IdentityUserRole<string>>), typeof(UserRoleRepository));
@@ -118,7 +118,6 @@ namespace MTWorkHR.Infrastructure
             services.AddScoped<IUnitOfWork, UnitOfWork>();
             services.AddScoped<IUnitOfWorkLog, UnitOfWorkLog>();
             services.AddTransient<IMailSender, MailSender>();
-
             services.AddScoped<ApplicationUserManager>();
             services.AddScoped<GlobalInfo>();
 

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 5826 - 0
MTWorkHR.Infrastructure/Migrations/20250106114622_addSubscription.Designer.cs


+ 51 - 0
MTWorkHR.Infrastructure/Migrations/20250106114622_addSubscription.cs

@@ -0,0 +1,51 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class addSubscription : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.CreateTable(
+                name: "SubscriptionConfiguration",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    CreateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    UpdateUser = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    CreateDate = table.Column<DateTime>(type: "datetime2", nullable: false),
+                    UpdateDate = table.Column<DateTime>(type: "datetime2", nullable: true),
+                    IsDeleted = table.Column<bool>(type: "bit", nullable: false),
+                    DeleteUserId = table.Column<string>(type: "nvarchar(450)", maxLength: 450, nullable: true),
+                    FirstRegisterationCompanyFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    MonthlyCompanyFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    YearlyCompanyFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    MonthlyEmployeeServicesCompanyFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    DistinguishedEmployeeCompanyFeesPerc = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    OrdinaryEmployeePerc = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    DistinguishedEmployeePerc = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    DeductedFirstSearchAmount = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    ContractDocumentationFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    ExperienceCertificateFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true),
+                    RequestDisputeResolutionFees = table.Column<decimal>(type: "decimal(18,2)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_SubscriptionConfiguration", x => x.Id);
+                });
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "SubscriptionConfiguration");
+        }
+    }
+}

+ 74 - 0
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -4011,6 +4011,80 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("SettingLogs");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.SubscriptionConfiguration", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<decimal?>("ContractDocumentationFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<decimal?>("DeductedFirstSearchAmount")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<string>("DeleteUserId")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(8);
+
+                    b.Property<decimal?>("DistinguishedEmployeeCompanyFeesPerc")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("DistinguishedEmployeePerc")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("ExperienceCertificateFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("FirstRegisterationCompanyFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<bool>("IsDeleted")
+                        .HasColumnType("bit")
+                        .HasColumnOrder(7);
+
+                    b.Property<decimal?>("MonthlyCompanyFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("MonthlyEmployeeServicesCompanyFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("OrdinaryEmployeePerc")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<decimal?>("RequestDisputeResolutionFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.Property<decimal?>("YearlyCompanyFees")
+                        .HasColumnType("decimal(18,2)");
+
+                    b.HasKey("Id");
+
+                    b.ToTable("SubscriptionConfiguration");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.TaskUser", b =>
                 {
                     b.Property<long>("Id")

+ 17 - 0
MTWorkHR.Infrastructure/Repositories/Payment/SubscriptionConfigurationRepository.cs

@@ -0,0 +1,17 @@
+using Microsoft.EntityFrameworkCore;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.IDto;
+using MTWorkHR.Core.IRepositories;
+using MTWorkHR.Infrastructure.Entities;
+using MTWorkHR.Infrastructure.DBContext;
+
+namespace MTWorkHR.Infrastructure.Repositories
+{
+    public class SubscriptionConfigurationRepository : Repository<SubscriptionConfiguration>, ISubscriptionConfigurationRepository
+    {
+        public SubscriptionConfigurationRepository(HRDataContext context) : base(context)
+        {
+        }
+      
+    }
+}

+ 4 - 0
MTWorkHR.Infrastructure/UnitOfWork/UnitOfWork.cs

@@ -43,6 +43,8 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
         public IContractRepository Contract{ get; }
         public IContractTaskAttachmentRepository ContractTaskAttachment { get; }
         public IProjectStageAttachmentRepository ProjectStageAttachment { get; }
+        public ISubscriptionConfigurationRepository SubscriptionConfiguration { get; }
+
         public UnitOfWork(HRDataContext _context
             , IPermissionRepository permission
             , ICompanyRepository company
@@ -73,6 +75,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             , IContractTaskAttachmentRepository contractTaskAttachment
             , IProjectStageAttachmentRepository projectStageAttachment
             , IHubConnectionRepository connection
+            , ISubscriptionConfigurationRepository subscriptionConfiguration
 
             )
         {
@@ -106,6 +109,7 @@ namespace MTWorkHR.Infrastructure.UnitOfWorks
             HubConnection = connection;
             ContractTaskAttachment = contractTaskAttachment;
             ProjectStageAttachment = projectStageAttachment;
+            SubscriptionConfiguration = subscriptionConfiguration;
         }
 
         public async Task<int> CompleteAsync()