Browse Source

ContractWorkingDays

zinab_elgendy 1 week ago
parent
commit
db30a47da7

+ 11 - 7
MTWorkHR.Application/Dtos/Contract/ContractDto.cs

@@ -40,19 +40,23 @@ namespace MTWorkHR.Application.Models
         public DateTime? StartDate { get; set; }
         [JsonProperty(Required = Required.AllowNull)]
         public DateTime? EndDate { get; set; }
-        public ContractDurationEnum ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
-        public TypeOfWork TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
-        public int VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
-        public int TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
+
+        [JsonProperty(Required = Required.AllowNull)]
+        public ContractDurationEnum? ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public TypeOfWork? TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
+        [JsonProperty(Required = Required.AllowNull)]
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int? TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
         public TerminateContractEnum WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
         public TerminateContractEnum WhoCanTerminateContract { get; set; }
         public int NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
 
 
         //------Working time---------------
-        public string WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        [JsonProperty(Required = Required.AllowNull)]
+        public List<ContractWorkingDayDto>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
         public WorkingHours WorkingHours { get; set; } //	يومي/ اسبوعي  
-        public int WorkingHoursNum { get; set; } // عدد الساعات
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
         public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
         public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
 
@@ -60,7 +64,7 @@ namespace MTWorkHR.Application.Models
         [MaxLength(50)]
         public string? Currency { get; set; }
         public decimal? Salary{ get; set; }
-        public BillingCycle BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
         //------------------------Fixed Pay----------------
         public DateTime? FirstPatchDateFrom { get; set; } 
         public DateTime? FirstPatchDateTo { get; set; } //

+ 17 - 0
MTWorkHR.Application/Dtos/Contract/ContractWorkingDayDto.cs

@@ -0,0 +1,17 @@
+using Microsoft.AspNetCore.Http;
+using MTWorkHR.Core.Entities;
+using MTWorkHR.Core.Entities.Base;
+using System.ComponentModel.DataAnnotations;
+using System.ComponentModel.DataAnnotations.Schema;
+
+namespace MTWorkHR.Application.Models
+{
+    public class ContractWorkingDayDto: EntityDto
+    {
+        public long ContractId { get; set; }
+        [Required]
+        [MaxLength(50)]
+        public string WorkingDay { get; set; }
+
+    }
+}

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

@@ -142,6 +142,7 @@ namespace MTWorkHR.Application.Mapper
                 .ForMember(d => d.CreateUser, o => o.Ignore());
             CreateMap<ContractAllowance, ContractAllowanceDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             CreateMap<ContractTask, ContractTaskDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
+            CreateMap<ContractWorkingDay, ContractWorkingDayDto>().ReverseMap().ForMember(d => d.CreateDate, o => o.Ignore()).ForMember(d => d.CreateUser, o => o.Ignore()); ;
             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()); ;

+ 12 - 12
MTWorkHR.Core/Entities/Contract/Contract.cs

@@ -23,9 +23,9 @@ namespace MTWorkHR.Core.Entities
         public int? JobId { get; set; }
         public int? AcademicQualificationId { get; set; }
         public int? SpecializationId { get; set; }
-        public int WorkCountryId { get; set; }
-        public int WorkStateId { get; set; }
-        public int ContractorTaxResidencyId { get; set; }
+        public int? WorkCountryId { get; set; }
+        public int? WorkStateId { get; set; }
+        public int? ContractorTaxResidencyId { get; set; }
         
         //-------------------Scope of work-----------
         public string? JobTitleName { get; set; }
@@ -35,19 +35,19 @@ namespace MTWorkHR.Core.Entities
         //----------------Contract data -------------------------
         public DateTime? StartDate { get; set; }
         public DateTime? EndDate { get; set; }
-        public int ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
+        public int? ContractDurationId { get; set; } //:  اختيار: شهري – ربعي – نصف سنوي – 3 ارباع – سنوي
         public TypeOfWork TypeOfWork { get; set; } //: :   اختيار: عقد بدوام كامل -  عقد دوام جزئي   
-        public int VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
+        public int? VacationDays { get; set; } //اختيار: بدون – سنويا (رقم)
         public int TrialPeriod { get; set; } // تجربة (ادخال: تلقائياً كل ربع سنوي أسبوع تلقائياً) آخر: تعديل
-        public int WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
-        public int WhoCanTerminateContract { get; set; }
-        public int NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
+        public int? WhoCanTerminateContractInTrial { get; set; } //اختيار   الجميع – صاحب العمل – الموظف
+        public int? WhoCanTerminateContract { get; set; }
+        public int? NoticePeriodBeforeTermination { get; set; } //اختيار: بدون – تحديد (ادخال: تلقائياً مدة 10 أيام قبل انتهاء الاستحقاق) آخر: تعديل
 
 
         //------Working time---------------
-        public string WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
-        public int WorkingHours { get; set; } //	يومي/ اسبوعي  
-        public int WorkingHoursNum { get; set; } // عدد الساعات
+        public List<ContractWorkingDay>? WorkingDays { get; set; } //:   اختيار متعدد الأيام سبت أحد اثنين..... (بحيث الأيام الأخرى تكون إجازة) 1,2,3,4,5
+        public int? WorkingHours { get; set; } //	يومي/ اسبوعي  
+        public int? WorkingHoursNum { get; set; } // عدد الساعات
         public DateTime? StartDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
         public DateTime? EndDailyWorkingHours { get; set; } // تحديد ساعات الدوام قائمة الساعات << التوقيت بحسب دولة صاحب العمل
 
@@ -55,7 +55,7 @@ namespace MTWorkHR.Core.Entities
         [MaxLength(50)]
         public string? Currency { get; set; }
         public decimal? Salary{ get; set; }
-        public int BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
+        public string? BillingCycle { get; set; }// 2 fortnightly, 4 Monthly
 
 
         //---------Allowances----------------------

+ 24 - 0
MTWorkHR.Core/Entities/Contract/ContractWorkingDay.cs

@@ -0,0 +1,24 @@
+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;
+using MTWorkHR.Core.Entities.Base;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class ContractWorkingDay : AuditEntity
+    {
+
+        public long ContractId{ get; set; }
+        [ForeignKey("ContractId")]
+        public Contract? Contract { get; set; }
+        [Required]
+        [MaxLength(50)]
+        public string WorkingDay { get; set; }
+       
+
+    }
+}

File diff suppressed because it is too large
+ 5770 - 0
MTWorkHR.Infrastructure/Migrations/20241216201032_altrContractWorkingDay.Designer.cs


+ 260 - 0
MTWorkHR.Infrastructure/Migrations/20241216201032_altrContractWorkingDay.cs

@@ -0,0 +1,260 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrContractWorkingDay : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropColumn(
+                name: "WorkingDays",
+                table: "Contracts");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkingHoursNum",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkingHours",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkStateId",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkCountryId",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WhoCanTerminateContractInTrial",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WhoCanTerminateContract",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "VacationDays",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "NoticePeriodBeforeTermination",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "ContractDurationId",
+                table: "Contracts",
+                type: "int",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.AlterColumn<string>(
+                name: "BillingCycle",
+                table: "Contracts",
+                type: "nvarchar(max)",
+                nullable: true,
+                oldClrType: typeof(int),
+                oldType: "int");
+
+            migrationBuilder.CreateTable(
+                name: "ContractWorkingDay",
+                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),
+                    ContractId = table.Column<long>(type: "bigint", nullable: false),
+                    WorkingDay = table.Column<string>(type: "nvarchar(50)", maxLength: 50, nullable: false)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_ContractWorkingDay", x => x.Id);
+                    table.ForeignKey(
+                        name: "FK_ContractWorkingDay_Contracts_ContractId",
+                        column: x => x.ContractId,
+                        principalTable: "Contracts",
+                        principalColumn: "Id",
+                        onDelete: ReferentialAction.Cascade);
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_ContractWorkingDay_ContractId",
+                table: "ContractWorkingDay",
+                column: "ContractId");
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropTable(
+                name: "ContractWorkingDay");
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkingHoursNum",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkingHours",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkStateId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WorkCountryId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WhoCanTerminateContractInTrial",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "WhoCanTerminateContract",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "VacationDays",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "NoticePeriodBeforeTermination",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "ContractDurationId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(int),
+                oldType: "int",
+                oldNullable: true);
+
+            migrationBuilder.AlterColumn<int>(
+                name: "BillingCycle",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0,
+                oldClrType: typeof(string),
+                oldType: "nvarchar(max)",
+                oldNullable: true);
+
+            migrationBuilder.AddColumn<string>(
+                name: "WorkingDays",
+                table: "Contracts",
+                type: "nvarchar(max)",
+                nullable: false,
+                defaultValue: "");
+        }
+    }
+}

+ 67 - 16
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs

@@ -548,8 +548,8 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<int?>("AcademicQualificationId")
                         .HasColumnType("int");
 
-                    b.Property<int>("BillingCycle")
-                        .HasColumnType("int");
+                    b.Property<string>("BillingCycle")
+                        .HasColumnType("nvarchar(max)");
 
                     b.Property<long>("CompanyId")
                         .HasColumnType("bigint");
@@ -558,7 +558,7 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .IsRequired()
                         .HasColumnType("nvarchar(max)");
 
-                    b.Property<int>("ContractDurationId")
+                    b.Property<int?>("ContractDurationId")
                         .HasColumnType("int");
 
                     b.Property<int>("ContractStatusId")
@@ -567,7 +567,7 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<int>("ContractTypeId")
                         .HasColumnType("int");
 
-                    b.Property<int>("ContractorTaxResidencyId")
+                    b.Property<int?>("ContractorTaxResidencyId")
                         .HasColumnType("int");
 
                     b.Property<DateTime>("CreateDate")
@@ -632,7 +632,7 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Property<DateTime?>("LastPatchDateTo")
                         .HasColumnType("datetime2");
 
-                    b.Property<int>("NoticePeriodBeforeTermination")
+                    b.Property<int?>("NoticePeriodBeforeTermination")
                         .HasColumnType("int");
 
                     b.Property<decimal?>("Salary")
@@ -666,29 +666,25 @@ namespace MTWorkHR.Infrastructure.Migrations
                         .IsRequired()
                         .HasColumnType("nvarchar(max)");
 
-                    b.Property<int>("VacationDays")
+                    b.Property<int?>("VacationDays")
                         .HasColumnType("int");
 
-                    b.Property<int>("WhoCanTerminateContract")
+                    b.Property<int?>("WhoCanTerminateContract")
                         .HasColumnType("int");
 
-                    b.Property<int>("WhoCanTerminateContractInTrial")
+                    b.Property<int?>("WhoCanTerminateContractInTrial")
                         .HasColumnType("int");
 
-                    b.Property<int>("WorkCountryId")
+                    b.Property<int?>("WorkCountryId")
                         .HasColumnType("int");
 
-                    b.Property<int>("WorkStateId")
+                    b.Property<int?>("WorkStateId")
                         .HasColumnType("int");
 
-                    b.Property<string>("WorkingDays")
-                        .IsRequired()
-                        .HasColumnType("nvarchar(max)");
-
-                    b.Property<int>("WorkingHours")
+                    b.Property<int?>("WorkingHours")
                         .HasColumnType("int");
 
-                    b.Property<int>("WorkingHoursNum")
+                    b.Property<int?>("WorkingHoursNum")
                         .HasColumnType("int");
 
                     b.HasKey("Id");
@@ -861,6 +857,48 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.ToTable("ContractTaskAttachment");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractWorkingDay", b =>
+                {
+                    b.Property<long>("Id")
+                        .ValueGeneratedOnAdd()
+                        .HasColumnType("bigint")
+                        .HasColumnOrder(0);
+
+                    SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("Id"));
+
+                    b.Property<long>("ContractId")
+                        .HasColumnType("bigint");
+
+                    b.Property<DateTime>("CreateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(3);
+
+                    b.Property<string>("CreateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(1);
+
+                    b.Property<DateTime?>("UpdateDate")
+                        .HasColumnType("datetime2")
+                        .HasColumnOrder(4);
+
+                    b.Property<string>("UpdateUser")
+                        .HasMaxLength(450)
+                        .HasColumnType("nvarchar(450)")
+                        .HasColumnOrder(2);
+
+                    b.Property<string>("WorkingDay")
+                        .IsRequired()
+                        .HasMaxLength(50)
+                        .HasColumnType("nvarchar(50)");
+
+                    b.HasKey("Id");
+
+                    b.HasIndex("ContractId");
+
+                    b.ToTable("ContractWorkingDay");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.CountryLookup", b =>
                 {
                     b.Property<long>("Id")
@@ -5332,6 +5370,17 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("ContractTask");
                 });
 
+            modelBuilder.Entity("MTWorkHR.Core.Entities.ContractWorkingDay", b =>
+                {
+                    b.HasOne("MTWorkHR.Core.Entities.Contract", "Contract")
+                        .WithMany("WorkingDays")
+                        .HasForeignKey("ContractId")
+                        .OnDelete(DeleteBehavior.Cascade)
+                        .IsRequired();
+
+                    b.Navigation("Contract");
+                });
+
             modelBuilder.Entity("MTWorkHR.Core.Entities.MeetingUser", b =>
                 {
                     b.HasOne("MTWorkHR.Core.Entities.Meeting", "Meeting")
@@ -5662,6 +5711,8 @@ namespace MTWorkHR.Infrastructure.Migrations
                     b.Navigation("FixedAllowances");
 
                     b.Navigation("ProjectStages");
+
+                    b.Navigation("WorkingDays");
                 });
 
             modelBuilder.Entity("MTWorkHR.Core.Entities.ContractTask", b =>

+ 1 - 0
MTWorkHR.Infrastructure/Repositories/Contract/ContractRepository.cs

@@ -21,6 +21,7 @@ namespace MTWorkHR.Infrastructure.Repositories
                 .Include(x => x.ContractTasks)
                 .Include(x => x.FixedAllowances)
                 .Include(x => x.ProjectStages)
+                .Include(x => x.WorkingDays)
                 .FirstOrDefaultAsync(x => x.Id == id);
         }