feat:add InstitutionContractWorkshopGroup add migrations

This commit is contained in:
2025-09-20 17:02:03 +03:30
parent e6e81cd1c9
commit 90ee299b87
14 changed files with 11662 additions and 146 deletions

View File

@@ -15,7 +15,8 @@ public class InstitutionContract : EntityBase
string address, DateTime contractStartGr, string contractStartFa, DateTime contractEndGr,
string contractEndFa, double contractAmount, double dailyCompenseation, double obligation,
double totalAmount, int extensionNo, string workshopManualCount, string employeeManualCount, string description,
string officialCompany, string typeOfcontract, string hasValueAddedTax, double valueAddedTax)
string officialCompany, string typeOfcontract, string hasValueAddedTax, double valueAddedTax,
List<InstitutionContractWorkshopDetail> workshopDetails)
{
ContractNo = contractNo;
RepresentativeId = representativeId;
@@ -49,27 +50,37 @@ public class InstitutionContract : EntityBase
ValueAddedTax = valueAddedTax;
VerificationStatus = InstitutionContractVerificationStatus.PendingForVerify;
ContactInfoList = [];
WorkshopDetails = [];
Installments = [];
WorkshopGroup = new InstitutionContractWorkshopGroup(0, workshopDetails);
}
public string ContractNo { get; private set; }
public long RepresentativeId { get; private set; }
public string RepresentativeName { get; private set; }
public long ContractingPartyId { get; private set; }
public string ContractingPartyName { get; private set; }
public DateTime ContractDateGr { get; private set; }
public string ContractDateFa { get; private set; }
public string State { get; private set; }
public string City { get; private set; }
public string Address { get; private set; }
//public long ContactInfoId { get; private set; }
public DateTime ContractStartGr { get; private set; }
public string ContractStartFa { get; private set; }
public DateTime ContractEndGr { get; private set; }
public string ContractEndFa { get; private set; }
// مبلغ قرارداد
@@ -83,30 +94,40 @@ public class InstitutionContract : EntityBase
// مبلغ کل قرارداد
public double TotalAmount { get; private set; }
public string WorkshopManualCount { get; private set; }
public string EmployeeManualCount { get; private set; }
public string IsActiveString { get; private set; }
public int ExtensionNo { get; private set; }
public string Description { get; private set; }
public string Signature { get; private set; }
public string OfficialCompany { get; private set; }
public string TypeOfContract { get; private set; }
public string HasValueAddedTax { get; set; }
public double ValueAddedTax { get; set; }
public InstitutionContractVerificationStatus VerificationStatus { get; private set; }
public List<InstitutionContractWorkshopDetail> WorkshopDetails { get; set; }
public InstitutionContractWorkshopGroup WorkshopGroup { get; private set; }
public List<InstitutionContractContactInfo> ContactInfoList { get; set; }
public List<InstitutionContractInstallment> Installments { get; set; }
public List<InstitutionContractAmendment> Amendments{ get; private set; }
public List<InstitutionContractAmendment> Amendments { get; private set; }
public InstitutionContract()
{
ContactInfoList = [];
WorkshopDetails = [];
Installments = [];
}
@@ -169,19 +190,14 @@ public class InstitutionContract : EntityBase
{
VerificationStatus = InstitutionContractVerificationStatus.Verified;
}
public void SetWorkshopDetails(List<InstitutionContractWorkshopDetail> commandWorkshops)
{
WorkshopDetails = commandWorkshops;
}
public void SetInstallments(List<InstitutionContractInstallment> installments)
{
Installments = installments;
}
}
public class InstitutionContractAmendment: EntityBase
public class InstitutionContractAmendment : EntityBase
{
public long InstitutionContractId { get; set; }
public List<InstitutionContractInstallment> Installments { get; set; }
@@ -190,13 +206,13 @@ public class InstitutionContractAmendment: EntityBase
public List<InstitutionContractAmendmentChange> AmendmentChanges { get; set; }
}
public class InstitutionContractAmendmentChange: EntityBase
public class InstitutionContractAmendmentChange : EntityBase
{
public long InstitutionContractAmendmentId { get; private set; }
public InstitutionContractAmendment InstitutionContractAmendment { get; private set; }
public InstitutionContractAmendmentChangeType ChangeType { get; private set; }
public DateTime ChangeDateGr { get; private set; }
/// <summary>
/// پلن حضور و غیاب
/// </summary>
@@ -211,17 +227,17 @@ public class InstitutionContractAmendmentChange: EntityBase
/// پلن قرارداد و تصفیه
/// </summary>
public bool? HasContractPlan { get; private set; }
/// <summary>
/// پلن قرارداد و تصفیه حضوری
/// </summary>
public bool? HasContractPlanInPerson { get; private set; }
/// <summary>
/// پلن بیمه
/// </summary>
public bool? HasInsurancePlan { get; private set; }
/// <summary>
/// پلن بیمه حضوری
/// </summary>
@@ -251,7 +267,7 @@ public enum InstitutionContractVerificationStatus
/// در انتظار تایید
/// </summary>
PendingForVerify = 0,
/// <summary>
/// تایید شده
/// </summary>

View File

@@ -22,7 +22,7 @@ public class InstitutionContractInstallment
public long InstitutionContractId { get; private set; }
public long? InstitutionContractAmendmentId { get; private set; }
public InstitutionContractAmendment InstitutionContractAmendment { get; set; }
public InstitutionContract InstitutionContract { get; private set; }
}
public InstitutionContractAmendment InstitutionContractAmendment { get; set; }
}

View File

@@ -69,11 +69,8 @@ public class InstitutionContractWorkshopDetail:EntityBase
/// شناسه قرارداد نهاد مرتبط
/// </summary>
public long InstitutionContractId { get; private set; }
/// <summary>
/// Navigation property to InstitutionContract
/// </summary>
public InstitutionContract InstitutionContract { get; private set; }
public long InstitutionContractWorkshopGroupId { get; set; }
public double Price { get; private set; }

View File

@@ -0,0 +1,36 @@
using System;
using System.Collections.Generic;
using System.Linq;
using _0_Framework_b.Domain;
namespace Company.Domain.InstitutionContractAgg;
public class InstitutionContractWorkshopGroup : EntityBase
{
private InstitutionContractWorkshopGroup()
{
}
public long InstitutionContractId { get; private set; }
public InstitutionContract InstitutionContract { get; set; }
public List<InstitutionContractWorkshopDetail> InitialWorkshopDetails { get; private set; }
public List<InstitutionContractWorkshopDetail> CurrentWorkshopDetails { get; private set; }
public DateTime LastModifiedDate { get; private set; }
public bool HasChanges => !InitialWorkshopDetails.SequenceEqual(CurrentWorkshopDetails);
public InstitutionContractWorkshopGroup(long institutionContractId,
List<InstitutionContractWorkshopDetail> initialDetails)
{
InstitutionContractId = institutionContractId;
InitialWorkshopDetails = initialDetails;
CurrentWorkshopDetails = new List<InstitutionContractWorkshopDetail>(initialDetails);
InitialWorkshopDetails = new List<InstitutionContractWorkshopDetail>(initialDetails);
LastModifiedDate = DateTime.Now;
}
public void UpdateCurrentWorkshops(List<InstitutionContractWorkshopDetail> updatedDetails)
{
CurrentWorkshopDetails = updatedDetails;
LastModifiedDate = DateTime.Now;
}
}

View File

@@ -201,7 +201,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
command.ContractStartFa, contractEndGr, command.ContractEndFa, command.ContractAmount,
command.DailyCompenseation, command.Obligation,
command.TotalAmount, 0, command.WorkshopManualCount, command.EmployeeManualCount, command.Description,
command.OfficialCompany, command.TypeOfContract, command.HasValueAddedTax, command.ValueAddedTax);
command.OfficialCompany, command.TypeOfContract, command.HasValueAddedTax, command.ValueAddedTax,[]);
_institutionContractRepository.Create(createContract);
_institutionContractRepository.SaveChanges();
@@ -310,7 +310,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
command.DailyCompenseation, command.Obligation,
command.TotalAmount, command.ExtensionNo, command.WorkshopManualCount, command.EmployeeManualCount,
command.Description, command.OfficialCompany, command.TypeOfContract, command.HasValueAddedTax,
command.ValueAddedTax);
command.ValueAddedTax,[]);
_institutionContractRepository.Create(createContract);
_institutionContractRepository.SaveChanges();
@@ -966,6 +966,11 @@ public class InstitutionContractApplication : IInstitutionContractApplication
var contractingPartyFullName = contractingParty.FName + " " + contractingParty.LName;
var workshopDetails = command.Workshops.Select(x =>
new InstitutionContractWorkshopDetail(x.WorkshopName, x.HasRollCallPlan, x.HasCustomizeCheckoutPlan,
x.HasContractPlan, x.HasContractPlanInPerson,x.HasInsurancePlan,x.HasInsurancePlanInPerson,x.PersonnelCount, x.Price)).ToList();
var entity = new InstitutionContract(contractNo, command.RepresentativeId, representative.FullName,
contractingParty.id,
contractingPartyFullName, contractDateGr, contractDateFa, command.Province, command.City, command.Address,
@@ -974,14 +979,9 @@ public class InstitutionContractApplication : IInstitutionContractApplication
command.Obligation, command.TotalAmount, 0,
command.Workshops.Count.ToString(),
command.Workshops.Sum(x => x.PersonnelCount).ToString(), command.Description,
"NotOfficial", "JobRelation", hasValueAddedTax
, command.TaxAmount);
var workshopDetails = command.Workshops.Select(x =>
new InstitutionContractWorkshopDetail(x.WorkshopName, x.HasRollCallPlan, x.HasCustomizeCheckoutPlan,
x.HasContractPlan, x.HasContractPlanInPerson,x.HasInsurancePlan,x.HasInsurancePlanInPerson,x.PersonnelCount, x.Price)).ToList();
"NotOfficial", "JobRelation", hasValueAddedTax,
command.TaxAmount,workshopDetails);
var financialStatement = new FinancialStatment(contractingParty.id, contractingPartyFullName);
if (command.IsInstallment)
@@ -1015,8 +1015,7 @@ public class InstitutionContractApplication : IInstitutionContractApplication
"پرداخت کل سرویس", "debt", "بابت خدمات", command.TotalAmount, 0, 0);
financialStatement.AddFinancialTransaction(financialTransaction);
}
entity.SetWorkshopDetails(workshopDetails);
await _financialStatmentRepository.CreateAsync(financialStatement);
await _institutionContractRepository.CreateAsync(entity);
await _institutionContractRepository.SaveChangesAsync();

View File

@@ -1112,7 +1112,8 @@ public class WorkshopAppliction : IWorkshopApplication
accountIds.Add(command.SeniorInsuranceAccountId);
accountIds.Add(command.JuniorInsuranceAccountId);
var op = _workshopRepository.CreateAccountLeftWorkAndWorkshopAccounts(accountIds.Distinct().ToList(),
var op = _workshopRepository
.CreateAccountLeftWorkAndWorkshopAccounts(accountIds.Distinct().ToList(),
workshop.id);
_institutionContractRepository.UpdateStatusIfNeeded(institutionContract.id);

View File

@@ -274,7 +274,7 @@ public class CompanyContext : DbContext
public DbSet<InsuranceJobAndJobs> InsuranceJobAndJobsSet { get; set; }
public DbSet<InstitutionContractContactInfo> InstitutionContractContactInfos { get; set; }
public DbSet<InstitutionContract> InstitutionContractSet { get; set; }
public DbSet<InstitutionContractWorkshopDetail> InstitutionContractWorkshopDetails { get; set; }
public DbSet<InstitutionContractWorkshopGroup> InstitutionContractWorkshopGroups { get; set; }
public DbSet<FileEmployer> FileEmployerSet { get; set; }
public DbSet<FileEmployee> FileEmployeeSet { get; set; }
public DbSet<Representative> RepresentativeSet { get; set; }

View File

@@ -31,11 +31,6 @@ public class InstitutionContractMapping : IEntityTypeConfiguration<InstitutionCo
builder.Property(x => x.VerificationStatus).HasConversion<string>().HasMaxLength(122);
// Configure simple relationship with WorkshopDetails for Include() support
builder.HasMany(x => x.WorkshopDetails)
.WithOne(x => x.InstitutionContract)
.HasForeignKey(x => x.InstitutionContractId);
builder.HasMany(x => x.Installments)
.WithOne(x => x.InstitutionContract)
.HasForeignKey(x => x.InstitutionContractId);

View File

@@ -1,33 +0,0 @@
using Company.Domain.InstitutionContractAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class InstitutionContractWorkshopDetailMapping : IEntityTypeConfiguration<InstitutionContractWorkshopDetail>
{
public void Configure(EntityTypeBuilder<InstitutionContractWorkshopDetail> builder)
{
builder.ToTable("InstitutionContractWorkshopDetail");
builder.HasKey(x => x.id);
builder.Property(x => x.WorkshopName).HasMaxLength(100);
builder.Property(x => x.WorkshopId).IsRequired(false);
// Configure relationship with InstitutionContract
builder.HasOne(x => x.InstitutionContract)
.WithMany(x => x.WorkshopDetails)
.HasForeignKey(x => x.InstitutionContractId);
// Configure OwnsMany relationship with Employers
builder.OwnsMany(x => x.Employers, employer =>
{
employer.ToTable("InstitutionContractWorkshopDetailEmployers");
employer.HasKey(x => x.id);
employer.WithOwner().HasForeignKey(x => x.InstitutionContractWorkshopDetailId);
employer.Property(x => x.EmployerId).IsRequired();
employer.HasIndex(x => new { x.InstitutionContractWorkshopDetailId, x.EmployerId })
.IsUnique();
});
}
}

View File

@@ -0,0 +1,58 @@
using Company.Domain.InstitutionContractAgg;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
namespace CompanyManagment.EFCore.Mapping;
public class InstitutionContractWorkshopGroupDetailMapping : IEntityTypeConfiguration<InstitutionContractWorkshopGroup>
{
public void Configure(EntityTypeBuilder<InstitutionContractWorkshopGroup> builder)
{
builder.HasKey(x => x.id);
builder.Property(x => x.LastModifiedDate)
.IsRequired();
// Configure relationship with InstitutionContract
builder.HasOne(x=>x.InstitutionContract)
.WithOne(x => x.WorkshopGroup)
.HasForeignKey<InstitutionContractWorkshopGroup>(x=>x.InstitutionContractId);
// Configure owned collections for workshop details
builder.OwnsMany(x => x.InitialWorkshopDetails, initialDetails =>
{
initialDetails.HasKey(x => x.id);
initialDetails.ToTable("InstitutionContractInitialWorkshopDetails");
initialDetails.WithOwner().HasForeignKey(x => x.InstitutionContractWorkshopGroupId);
initialDetails.Property(x => x.WorkshopName).HasMaxLength(100);
initialDetails.Property(x => x.WorkshopId).IsRequired(false);
initialDetails.OwnsMany(x => x.Employers, employer =>
{
employer.ToTable("InstitutionContractInitialWorkshopDetailEmployers");
employer.HasKey(x => x.id);
employer.WithOwner().HasForeignKey(x => x.InstitutionContractWorkshopDetailId);
employer.Property(x => x.EmployerId).IsRequired();
employer.HasIndex(x => new { x.InstitutionContractWorkshopDetailId, x.EmployerId })
.IsUnique();
});
});
builder.OwnsMany(x => x.CurrentWorkshopDetails, currentDetails =>
{
currentDetails.HasKey(x => x.id);
currentDetails.ToTable("InstitutionContractCurrentWorkshopDetails"); // Changed table name
currentDetails.WithOwner().HasForeignKey(x => x.InstitutionContractWorkshopGroupId);
currentDetails.Property(x => x.WorkshopName).HasMaxLength(100);
currentDetails.Property(x => x.WorkshopId).IsRequired(false);
currentDetails.OwnsMany(x => x.Employers, employer =>
{
employer.ToTable("InstitutionContractCurrentWorkshopDetailEmployers"); // Changed table name
employer.HasKey(x => x.id);
employer.WithOwner().HasForeignKey(x => x.InstitutionContractWorkshopDetailId);
employer.Property(x => x.EmployerId).IsRequired();
employer.HasIndex(x => new { x.InstitutionContractWorkshopDetailId, x.EmployerId })
.IsUnique();
});
});
}
}

View File

@@ -0,0 +1,366 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace CompanyManagment.EFCore.Migrations
{
/// <inheritdoc />
public partial class Addnewinstitutioncontractproperties : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "InstitutionContractWorkshopDetailEmployers");
migrationBuilder.DropTable(
name: "InstitutionContractWorkshopDetail");
migrationBuilder.RenameColumn(
name: "Status",
table: "InstitutionContracts",
newName: "VerificationStatus");
migrationBuilder.AddColumn<long>(
name: "InstitutionContractAmendmentId",
table: "InstitutionContractInstallments",
type: "bigint",
nullable: true);
migrationBuilder.CreateTable(
name: "InstitutionContractAmendment",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractId = table.Column<long>(type: "bigint", nullable: false),
Amount = table.Column<double>(type: "float", nullable: false),
HasInstallment = table.Column<bool>(type: "bit", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractAmendment", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractAmendment_InstitutionContracts_InstitutionContractId",
column: x => x.InstitutionContractId,
principalTable: "InstitutionContracts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractWorkshopGroup",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractId = table.Column<long>(type: "bigint", nullable: false),
LastModifiedDate = table.Column<DateTime>(type: "datetime2", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractWorkshopGroup", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractWorkshopGroup_InstitutionContracts_InstitutionContractId",
column: x => x.InstitutionContractId,
principalTable: "InstitutionContracts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractAmendmentChange",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractAmendmentId = table.Column<long>(type: "bigint", nullable: false),
ChangeType = table.Column<int>(type: "int", nullable: false),
ChangeDateGr = table.Column<DateTime>(type: "datetime2", nullable: false),
HasRollCallPlan = table.Column<bool>(type: "bit", nullable: true),
HasCustomizeCheckoutPlan = table.Column<bool>(type: "bit", nullable: true),
HasContractPlan = table.Column<bool>(type: "bit", nullable: true),
HasContractPlanInPerson = table.Column<bool>(type: "bit", nullable: true),
HasInsurancePlan = table.Column<bool>(type: "bit", nullable: true),
HasInsurancePlanInPerson = table.Column<bool>(type: "bit", nullable: true),
PersonnelCount = table.Column<int>(type: "int", nullable: true),
WorkshopDetailsId = table.Column<long>(type: "bigint", nullable: true),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractAmendmentChange", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractAmendmentChange_InstitutionContractAmendment_InstitutionContractAmendmentId",
column: x => x.InstitutionContractAmendmentId,
principalTable: "InstitutionContractAmendment",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractCurrentWorkshopDetails",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkshopId = table.Column<long>(type: "bigint", nullable: true),
WorkshopName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
HasRollCallPlan = table.Column<bool>(type: "bit", nullable: false),
HasCustomizeCheckoutPlan = table.Column<bool>(type: "bit", nullable: false),
HasContractPlan = table.Column<bool>(type: "bit", nullable: false),
HasContractPlanInPerson = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlan = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlanInPerson = table.Column<bool>(type: "bit", nullable: false),
PersonnelCount = table.Column<int>(type: "int", nullable: false),
WorkshopCreated = table.Column<bool>(type: "bit", nullable: false),
InstitutionContractId = table.Column<long>(type: "bigint", nullable: false),
InstitutionContractWorkshopGroupId = table.Column<long>(type: "bigint", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractCurrentWorkshopDetails", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractCurrentWorkshopDetails_InstitutionContractWorkshopGroup_InstitutionContractWorkshopGroupId",
column: x => x.InstitutionContractWorkshopGroupId,
principalTable: "InstitutionContractWorkshopGroup",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractInitialWorkshopDetails",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
WorkshopId = table.Column<long>(type: "bigint", nullable: true),
WorkshopName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true),
HasRollCallPlan = table.Column<bool>(type: "bit", nullable: false),
HasCustomizeCheckoutPlan = table.Column<bool>(type: "bit", nullable: false),
HasContractPlan = table.Column<bool>(type: "bit", nullable: false),
HasContractPlanInPerson = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlan = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlanInPerson = table.Column<bool>(type: "bit", nullable: false),
PersonnelCount = table.Column<int>(type: "int", nullable: false),
WorkshopCreated = table.Column<bool>(type: "bit", nullable: false),
InstitutionContractId = table.Column<long>(type: "bigint", nullable: false),
InstitutionContractWorkshopGroupId = table.Column<long>(type: "bigint", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractInitialWorkshopDetails", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractInitialWorkshopDetails_InstitutionContractWorkshopGroup_InstitutionContractWorkshopGroupId",
column: x => x.InstitutionContractWorkshopGroupId,
principalTable: "InstitutionContractWorkshopGroup",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractCurrentWorkshopDetailEmployers",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractWorkshopDetailId = table.Column<long>(type: "bigint", nullable: false),
EmployerId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractCurrentWorkshopDetailEmployers", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractCurrentWorkshopDetailEmployers_InstitutionContractCurrentWorkshopDetails_InstitutionContractWorkshopDetai~",
column: x => x.InstitutionContractWorkshopDetailId,
principalTable: "InstitutionContractCurrentWorkshopDetails",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractInitialWorkshopDetailEmployers",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractWorkshopDetailId = table.Column<long>(type: "bigint", nullable: false),
EmployerId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractInitialWorkshopDetailEmployers", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractInitialWorkshopDetailEmployers_InstitutionContractInitialWorkshopDetails_InstitutionContractWorkshopDetai~",
column: x => x.InstitutionContractWorkshopDetailId,
principalTable: "InstitutionContractInitialWorkshopDetails",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractInstallments_InstitutionContractAmendmentId",
table: "InstitutionContractInstallments",
column: "InstitutionContractAmendmentId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractAmendment_InstitutionContractId",
table: "InstitutionContractAmendment",
column: "InstitutionContractId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractAmendmentChange_InstitutionContractAmendmentId",
table: "InstitutionContractAmendmentChange",
column: "InstitutionContractAmendmentId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractCurrentWorkshopDetailEmployers_InstitutionContractWorkshopDetailId_EmployerId",
table: "InstitutionContractCurrentWorkshopDetailEmployers",
columns: new[] { "InstitutionContractWorkshopDetailId", "EmployerId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractCurrentWorkshopDetails_InstitutionContractWorkshopGroupId",
table: "InstitutionContractCurrentWorkshopDetails",
column: "InstitutionContractWorkshopGroupId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractInitialWorkshopDetailEmployers_InstitutionContractWorkshopDetailId_EmployerId",
table: "InstitutionContractInitialWorkshopDetailEmployers",
columns: new[] { "InstitutionContractWorkshopDetailId", "EmployerId" },
unique: true);
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractInitialWorkshopDetails_InstitutionContractWorkshopGroupId",
table: "InstitutionContractInitialWorkshopDetails",
column: "InstitutionContractWorkshopGroupId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractWorkshopGroup_InstitutionContractId",
table: "InstitutionContractWorkshopGroup",
column: "InstitutionContractId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_InstitutionContractInstallments_InstitutionContractAmendment_InstitutionContractAmendmentId",
table: "InstitutionContractInstallments",
column: "InstitutionContractAmendmentId",
principalTable: "InstitutionContractAmendment",
principalColumn: "id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_InstitutionContractInstallments_InstitutionContractAmendment_InstitutionContractAmendmentId",
table: "InstitutionContractInstallments");
migrationBuilder.DropTable(
name: "InstitutionContractAmendmentChange");
migrationBuilder.DropTable(
name: "InstitutionContractCurrentWorkshopDetailEmployers");
migrationBuilder.DropTable(
name: "InstitutionContractInitialWorkshopDetailEmployers");
migrationBuilder.DropTable(
name: "InstitutionContractAmendment");
migrationBuilder.DropTable(
name: "InstitutionContractCurrentWorkshopDetails");
migrationBuilder.DropTable(
name: "InstitutionContractInitialWorkshopDetails");
migrationBuilder.DropTable(
name: "InstitutionContractWorkshopGroup");
migrationBuilder.DropIndex(
name: "IX_InstitutionContractInstallments_InstitutionContractAmendmentId",
table: "InstitutionContractInstallments");
migrationBuilder.DropColumn(
name: "InstitutionContractAmendmentId",
table: "InstitutionContractInstallments");
migrationBuilder.RenameColumn(
name: "VerificationStatus",
table: "InstitutionContracts",
newName: "Status");
migrationBuilder.CreateTable(
name: "InstitutionContractWorkshopDetail",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
InstitutionContractId = table.Column<long>(type: "bigint", nullable: false),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false),
HasContractPlan = table.Column<bool>(type: "bit", nullable: false),
HasContractPlanInPerson = table.Column<bool>(type: "bit", nullable: false),
HasCustomizeCheckoutPlan = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlan = table.Column<bool>(type: "bit", nullable: false),
HasInsurancePlanInPerson = table.Column<bool>(type: "bit", nullable: false),
HasRollCallPlan = table.Column<bool>(type: "bit", nullable: false),
PersonnelCount = table.Column<int>(type: "int", nullable: false),
Price = table.Column<double>(type: "float", nullable: false),
WorkshopCreated = table.Column<bool>(type: "bit", nullable: false),
WorkshopId = table.Column<long>(type: "bigint", nullable: true),
WorkshopName = table.Column<string>(type: "nvarchar(100)", maxLength: 100, nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractWorkshopDetail", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractWorkshopDetail_InstitutionContracts_InstitutionContractId",
column: x => x.InstitutionContractId,
principalTable: "InstitutionContracts",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "InstitutionContractWorkshopDetailEmployers",
columns: table => new
{
id = table.Column<long>(type: "bigint", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
CreationDate = table.Column<DateTime>(type: "datetime2", nullable: false),
EmployerId = table.Column<long>(type: "bigint", nullable: false),
InstitutionContractWorkshopDetailId = table.Column<long>(type: "bigint", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_InstitutionContractWorkshopDetailEmployers", x => x.id);
table.ForeignKey(
name: "FK_InstitutionContractWorkshopDetailEmployers_InstitutionContractWorkshopDetail_InstitutionContractWorkshopDetailId",
column: x => x.InstitutionContractWorkshopDetailId,
principalTable: "InstitutionContractWorkshopDetail",
principalColumn: "id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractWorkshopDetail_InstitutionContractId",
table: "InstitutionContractWorkshopDetail",
column: "InstitutionContractId");
migrationBuilder.CreateIndex(
name: "IX_InstitutionContractWorkshopDetailEmployers_InstitutionContractWorkshopDetailId_EmployerId",
table: "InstitutionContractWorkshopDetailEmployers",
columns: new[] { "InstitutionContractWorkshopDetailId", "EmployerId" },
unique: true);
}
}
}

View File

@@ -3124,11 +3124,6 @@ namespace CompanyManagment.EFCore.Migrations
.HasMaxLength(20)
.HasColumnType("nvarchar(20)");
b.Property<string>("Status")
.IsRequired()
.HasMaxLength(122)
.HasColumnType("nvarchar(122)");
b.Property<double>("TotalAmount")
.HasColumnType("float");
@@ -3139,6 +3134,11 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<double>("ValueAddedTax")
.HasColumnType("float");
b.Property<string>("VerificationStatus")
.IsRequired()
.HasMaxLength(122)
.HasColumnType("nvarchar(122)");
b.Property<string>("WorkshopManualCount")
.HasMaxLength(5)
.HasColumnType("nvarchar(5)");
@@ -3148,6 +3148,84 @@ namespace CompanyManagment.EFCore.Migrations
b.ToTable("InstitutionContracts", (string)null);
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<double>("Amount")
.HasColumnType("float");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<bool>("HasInstallment")
.HasColumnType("bit");
b.Property<long>("InstitutionContractId")
.HasColumnType("bigint");
b.HasKey("id");
b.HasIndex("InstitutionContractId");
b.ToTable("InstitutionContractAmendment");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendmentChange", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property<long>("id"));
b.Property<DateTime>("ChangeDateGr")
.HasColumnType("datetime2");
b.Property<int>("ChangeType")
.HasColumnType("int");
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<bool?>("HasContractPlan")
.HasColumnType("bit");
b.Property<bool?>("HasContractPlanInPerson")
.HasColumnType("bit");
b.Property<bool?>("HasCustomizeCheckoutPlan")
.HasColumnType("bit");
b.Property<bool?>("HasInsurancePlan")
.HasColumnType("bit");
b.Property<bool?>("HasInsurancePlanInPerson")
.HasColumnType("bit");
b.Property<bool?>("HasRollCallPlan")
.HasColumnType("bit");
b.Property<long>("InstitutionContractAmendmentId")
.HasColumnType("bigint");
b.Property<int?>("PersonnelCount")
.HasColumnType("int");
b.Property<long?>("WorkshopDetailsId")
.HasColumnType("bigint");
b.HasKey("id");
b.HasIndex("InstitutionContractAmendmentId");
b.ToTable("InstitutionContractAmendmentChange");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractInstallment", b =>
{
b.Property<long>("Id")
@@ -3171,17 +3249,22 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("InstallmentDateGr")
.HasColumnType("datetime2");
b.Property<long?>("InstitutionContractAmendmentId")
.HasColumnType("bigint");
b.Property<long>("InstitutionContractId")
.HasColumnType("bigint");
b.HasKey("Id");
b.HasIndex("InstitutionContractAmendmentId");
b.HasIndex("InstitutionContractId");
b.ToTable("InstitutionContractInstallments", (string)null);
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetail", b =>
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopGroup", b =>
{
b.Property<long>("id")
.ValueGeneratedOnAdd()
@@ -3192,48 +3275,18 @@ namespace CompanyManagment.EFCore.Migrations
b.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b.Property<bool>("HasContractPlan")
.HasColumnType("bit");
b.Property<bool>("HasContractPlanInPerson")
.HasColumnType("bit");
b.Property<bool>("HasCustomizeCheckoutPlan")
.HasColumnType("bit");
b.Property<bool>("HasInsurancePlan")
.HasColumnType("bit");
b.Property<bool>("HasInsurancePlanInPerson")
.HasColumnType("bit");
b.Property<bool>("HasRollCallPlan")
.HasColumnType("bit");
b.Property<long>("InstitutionContractId")
.HasColumnType("bigint");
b.Property<int>("PersonnelCount")
.HasColumnType("int");
b.Property<double>("Price")
.HasColumnType("float");
b.Property<bool>("WorkshopCreated")
.HasColumnType("bit");
b.Property<long?>("WorkshopId")
.HasColumnType("bigint");
b.Property<string>("WorkshopName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b.Property<DateTime>("LastModifiedDate")
.HasColumnType("datetime2");
b.HasKey("id");
b.HasIndex("InstitutionContractId");
b.HasIndex("InstitutionContractId")
.IsUnique();
b.ToTable("InstitutionContractWorkshopDetail", (string)null);
b.ToTable("InstitutionContractWorkshopGroup");
});
modelBuilder.Entity("Company.Domain.InstitutionContractContactInfoAgg.InstitutionContractContactInfo", b =>
@@ -9638,8 +9691,32 @@ namespace CompanyManagment.EFCore.Migrations
b.Navigation("Holidayss");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", b =>
{
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContract", null)
.WithMany("Amendments")
.HasForeignKey("InstitutionContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendmentChange", b =>
{
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", "InstitutionContractAmendment")
.WithMany("AmendmentChanges")
.HasForeignKey("InstitutionContractAmendmentId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("InstitutionContractAmendment");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractInstallment", b =>
{
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", "InstitutionContractAmendment")
.WithMany("Installments")
.HasForeignKey("InstitutionContractAmendmentId");
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContract", "InstitutionContract")
.WithMany("Installments")
.HasForeignKey("InstitutionContractId")
@@ -9647,17 +9724,19 @@ namespace CompanyManagment.EFCore.Migrations
.IsRequired();
b.Navigation("InstitutionContract");
b.Navigation("InstitutionContractAmendment");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetail", b =>
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopGroup", b =>
{
b.HasOne("Company.Domain.InstitutionContractAgg.InstitutionContract", "InstitutionContract")
.WithMany("WorkshopDetails")
.HasForeignKey("InstitutionContractId")
.WithOne("WorkshopGroup")
.HasForeignKey("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopGroup", "InstitutionContractId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsMany("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetailEmployer", "Employers", b1 =>
b.OwnsMany("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetail", "CurrentWorkshopDetails", b1 =>
{
b1.Property<long>("id")
.ValueGeneratedOnAdd()
@@ -9668,24 +9747,180 @@ namespace CompanyManagment.EFCore.Migrations
b1.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b1.Property<long>("EmployerId")
b1.Property<bool>("HasContractPlan")
.HasColumnType("bit");
b1.Property<bool>("HasContractPlanInPerson")
.HasColumnType("bit");
b1.Property<bool>("HasCustomizeCheckoutPlan")
.HasColumnType("bit");
b1.Property<bool>("HasInsurancePlan")
.HasColumnType("bit");
b1.Property<bool>("HasInsurancePlanInPerson")
.HasColumnType("bit");
b1.Property<bool>("HasRollCallPlan")
.HasColumnType("bit");
b1.Property<long>("InstitutionContractId")
.HasColumnType("bigint");
b1.Property<long>("InstitutionContractWorkshopDetailId")
b1.Property<long>("InstitutionContractWorkshopGroupId")
.HasColumnType("bigint");
b1.Property<int>("PersonnelCount")
.HasColumnType("int");
b1.Property<double>("Price")
.HasColumnType("float");
b1.Property<bool>("WorkshopCreated")
.HasColumnType("bit");
b1.Property<long?>("WorkshopId")
.HasColumnType("bigint");
b1.Property<string>("WorkshopName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b1.HasKey("id");
b1.HasIndex("InstitutionContractWorkshopDetailId", "EmployerId")
.IsUnique();
b1.HasIndex("InstitutionContractWorkshopGroupId");
b1.ToTable("InstitutionContractWorkshopDetailEmployers", (string)null);
b1.ToTable("InstitutionContractCurrentWorkshopDetails", (string)null);
b1.WithOwner()
.HasForeignKey("InstitutionContractWorkshopDetailId");
.HasForeignKey("InstitutionContractWorkshopGroupId");
b1.OwnsMany("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetailEmployer", "Employers", b2 =>
{
b2.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b2.Property<long>("id"));
b2.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b2.Property<long>("EmployerId")
.HasColumnType("bigint");
b2.Property<long>("InstitutionContractWorkshopDetailId")
.HasColumnType("bigint");
b2.HasKey("id");
b2.HasIndex("InstitutionContractWorkshopDetailId", "EmployerId")
.IsUnique();
b2.ToTable("InstitutionContractCurrentWorkshopDetailEmployers", (string)null);
b2.WithOwner()
.HasForeignKey("InstitutionContractWorkshopDetailId");
});
b1.Navigation("Employers");
});
b.Navigation("Employers");
b.OwnsMany("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetail", "InitialWorkshopDetails", b1 =>
{
b1.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b1.Property<long>("id"));
b1.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b1.Property<bool>("HasContractPlan")
.HasColumnType("bit");
b1.Property<bool>("HasContractPlanInPerson")
.HasColumnType("bit");
b1.Property<bool>("HasCustomizeCheckoutPlan")
.HasColumnType("bit");
b1.Property<bool>("HasInsurancePlan")
.HasColumnType("bit");
b1.Property<bool>("HasInsurancePlanInPerson")
.HasColumnType("bit");
b1.Property<bool>("HasRollCallPlan")
.HasColumnType("bit");
b1.Property<long>("InstitutionContractId")
.HasColumnType("bigint");
b1.Property<long>("InstitutionContractWorkshopGroupId")
.HasColumnType("bigint");
b1.Property<int>("PersonnelCount")
.HasColumnType("int");
b1.Property<double>("Price")
.HasColumnType("float");
b1.Property<bool>("WorkshopCreated")
.HasColumnType("bit");
b1.Property<long?>("WorkshopId")
.HasColumnType("bigint");
b1.Property<string>("WorkshopName")
.HasMaxLength(100)
.HasColumnType("nvarchar(100)");
b1.HasKey("id");
b1.HasIndex("InstitutionContractWorkshopGroupId");
b1.ToTable("InstitutionContractInitialWorkshopDetails", (string)null);
b1.WithOwner()
.HasForeignKey("InstitutionContractWorkshopGroupId");
b1.OwnsMany("Company.Domain.InstitutionContractAgg.InstitutionContractWorkshopDetailEmployer", "Employers", b2 =>
{
b2.Property<long>("id")
.ValueGeneratedOnAdd()
.HasColumnType("bigint");
SqlServerPropertyBuilderExtensions.UseIdentityColumn(b2.Property<long>("id"));
b2.Property<DateTime>("CreationDate")
.HasColumnType("datetime2");
b2.Property<long>("EmployerId")
.HasColumnType("bigint");
b2.Property<long>("InstitutionContractWorkshopDetailId")
.HasColumnType("bigint");
b2.HasKey("id");
b2.HasIndex("InstitutionContractWorkshopDetailId", "EmployerId")
.IsUnique();
b2.ToTable("InstitutionContractInitialWorkshopDetailEmployers", (string)null);
b2.WithOwner()
.HasForeignKey("InstitutionContractWorkshopDetailId");
});
b1.Navigation("Employers");
});
b.Navigation("CurrentWorkshopDetails");
b.Navigation("InitialWorkshopDetails");
b.Navigation("InstitutionContract");
});
@@ -10401,11 +10636,20 @@ namespace CompanyManagment.EFCore.Migrations
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContract", b =>
{
b.Navigation("Amendments");
b.Navigation("ContactInfoList");
b.Navigation("Installments");
b.Navigation("WorkshopDetails");
b.Navigation("WorkshopGroup");
});
modelBuilder.Entity("Company.Domain.InstitutionContractAgg.InstitutionContractAmendment", b =>
{
b.Navigation("AmendmentChanges");
b.Navigation("Installments");
});
modelBuilder.Entity("Company.Domain.InsurancJobAgg.InsuranceJob", b =>

View File

@@ -1443,8 +1443,8 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
public async Task<List<RegistrationWorkflowMainListViewModel>> RegistrationWorkflowMainList()
{
return await _context.InstitutionContractSet.Where(x => x.VerificationStatus == InstitutionContractVerificationStatus.PendingForVerify)
.Include(x => x.WorkshopDetails)
return await _context.InstitutionContractSet.Where(x => x.VerificationStatus == InstitutionContractVerificationStatus.Verified)
.Include(x => x.WorkshopGroup)
.Join(_context.PersonalContractingParties,
institutionContract => institutionContract.ContractingPartyId,
contractingParty => contractingParty.id,
@@ -1455,9 +1455,9 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
ContractingPartyFullName = $"{x.contractingParty.FName} {x.contractingParty.LName}",
Phone = x.contractingParty.Phone,
Amount = x.institutionContract.TotalAmount,
DoneWorkshops = x.institutionContract.WorkshopDetails.Count(w => w.WorkshopCreated),
TotalWorkshops = x.institutionContract.WorkshopDetails.Count(),
UnDoneWorkshops = x.institutionContract.WorkshopDetails.Count(w => !w.WorkshopCreated),
DoneWorkshops = x.institutionContract.WorkshopGroup.InitialWorkshopDetails.Count(w => w.WorkshopCreated),
TotalWorkshops = x.institutionContract.WorkshopGroup.InitialWorkshopDetails.Count(),
UnDoneWorkshops = x.institutionContract.WorkshopGroup.InitialWorkshopDetails.Count(w => !w.WorkshopCreated),
ContractingPartyId = x.contractingParty.id
}).ToListAsync();
}
@@ -1471,14 +1471,14 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
{
// دریافت قرارداد نهاد همراه با جزئیات کارگاه‌ها
var institutionContract = await _context.InstitutionContractSet
.Include(x => x.WorkshopDetails)
.Include(x => x.WorkshopGroup)
.FirstOrDefaultAsync(x => x.id == institutionContractId);
if (institutionContract == null)
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
// استخراج شناسه‌های کارگاه‌هایی که ایجاد شده‌اند
var workshopIds = institutionContract.WorkshopDetails
var workshopIds = institutionContract.WorkshopGroup.InitialWorkshopDetails
.Where(x => x.WorkshopId != null)
.Select(x => x.WorkshopId.Value)
.ToList();
@@ -1489,7 +1489,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
.ToListAsync();
// استخراج تمامی شناسه‌های کارفرمایان از جزئیات کارگاه‌ها
var allEmployerIds = institutionContract.WorkshopDetails
var allEmployerIds = institutionContract.WorkshopGroup.InitialWorkshopDetails
.SelectMany(x => x.Employers.Select(e => e.EmployerId))
.Distinct()
.ToList();
@@ -1502,7 +1502,7 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
.ToDictionary(e => e.id, e => e);
// ساخت نتیجه نهایی با استفاده از داده‌های از پیش بارگذاری شده
var items = institutionContract.WorkshopDetails.Select(workshopDetail =>
var items = institutionContract.WorkshopGroup.InitialWorkshopDetails.Select(workshopDetail =>
{
// پیدا کردن کارگاه مرتبط
var workshop = workshops.FirstOrDefault(w => w.id == workshopDetail.WorkshopId);
@@ -1590,28 +1590,30 @@ public class InstitutionContractRepository : RepositoryBase<long, InstitutionCon
public async Task<InstitutionContractWorkshopDetail> GetInstitutionWorkshopDetails(
long institutionWorkshopDetailsId)
{
return await _context.InstitutionContractWorkshopDetails.FirstOrDefaultAsync(x =>
x.id == institutionWorkshopDetailsId);
var group= await _context.InstitutionContractWorkshopGroups
.FirstOrDefaultAsync(x => x.CurrentWorkshopDetails.Any(a=>a.id == institutionWorkshopDetailsId));
return group.CurrentWorkshopDetails.FirstOrDefault(x => x.id == institutionWorkshopDetailsId);
}
public async Task<InstitutionContract> GetIncludeWorkshopDetailsAsync(long institutionContractId)
{
return await _context.InstitutionContractSet
.Include(x => x.WorkshopDetails)
.Include(x => x.WorkshopGroup)
.FirstOrDefaultAsync(x => x.id == institutionContractId);
}
public void UpdateStatusIfNeeded(long institutionContractId)
{
var institutionContract = _context.InstitutionContractSet
.Include(x => x.WorkshopDetails)
.Include(x => x.WorkshopGroup)
.FirstOrDefault(x => x.id == institutionContractId);
if (institutionContract == null)
throw new NotFoundException("قرارداد مؤسسه یافت نشد");
if (institutionContract.VerificationStatus == InstitutionContractVerificationStatus.Verified)
return;
if (institutionContract.WorkshopDetails.All(x => x.WorkshopCreated))
if (institutionContract.WorkshopGroup.InitialWorkshopDetails.All(x => x.WorkshopCreated))
institutionContract.Verified();
_context.SaveChanges();