Commit 4ac73670 authored by hasan khaddour's avatar hasan khaddour

fix s .

parent c1f5afe1
......@@ -5,7 +5,7 @@ namespace PSManagement.Application.Customers.Common
{
public class ContactInfoDTO
{
public String ConatctValue { get; set; }
public String ContactValue { get; set; }
public String ContactType { get; set; }
}
......
using PSManagement.Domain.Identity.Entities;
using PSManagement.Domain.Projects.Aggregate;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Tracking;
using PSManagement.Domain.Tracking.Entities;
using PSManagement.SharedKernel.Aggregate;
using PSManagement.SharedKernel.Entities;
......@@ -17,9 +19,12 @@ namespace PSManagement.Domain.Employees.Entities
public int UserId { get; set; }
public User User { get; set; }
public PersonalInfo PersonalInfo { get; set; }
//public ICollection<Project> Projects { get; set; }
public ICollection<Project> Projects { get; set; }
public ICollection<EmployeeTrack> EmployeeTracks { get; set; }
public Availability Availability { get; set; }
public ICollection<EmployeeWork> EmployeeWorks { get; set; }
public ICollection<EmployeeParticipate> EmployeeParticipates { get; set; }
public Employee()
{
......
......@@ -5,6 +5,7 @@ using PSManagement.Domain.ProjectTypes.Entities;
using PSManagement.Domain.Steps.Entities;
using PSManagement.Domain.Tracking;
using PSManagement.SharedKernel.Aggregate;
using PSManagement.SharedKernel.ValueObjects;
using System.Collections.Generic;
using System.Linq;
using System.Text;
......@@ -14,23 +15,43 @@ namespace PSManagement.Domain.Projects.Aggregate
{
public class Project : IAggregateRoot
{
// information about the project itself
public ProposalInfo ProposalInfo { get; set; }
public ProjectInfo ProjectInfo { get; set; }
public ProjectType ProjectType { get; set; }
//public ProjectType ProjectType { get; set; }
public ProjectStatus ProjectStatus { get; set; }
public Aggreement ProjectAggreement { get; set; }
// information about who lead and execute the project
public int TeamLeaderId { get; set; }
public Employee TeamLeader { get; set; }
public int ProjectManagerId { get; set; }
public Employee ProjectManager { get; set; }
public Department Executer { get; set; }
// the proposer of the project
public Customer Proposer { get; set; }
public ICollection<Employee> Participants { get; set; }
//
public ICollection<Step> Steps { get; set; }
public ICollection<Track> Tracks { get; set; }
public ICollection<Employee> Participants { get; set; }
public ICollection<Attachment> Attachments { get; set; }
// finincial plan
public FinincialFund FinincialFund { get; set; }
public ICollection<EmployeeParticipate> EmployeeParticipates { get; set; }
public ICollection<Track> Tracks { get; set; }
public Project()
{
}
}
public record FinincialFund (
string FinicialStatus,
string Source
);
}
using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Projects.Aggregate;
using PSManagement.SharedKernel.Entities;
using System;
namespace PSManagement.Domain.Projects.Entities
{
public class EmployeeParticipate : BaseEntity
{
public int EmployeeId { get; set; }
public int ProjectId { get; set; }
public Employee Employee { get; set; }
public Project Project { get; set; }
public int PartialTimeRatio { get; set; }
public string Role { get; set; }
}
}
......@@ -17,14 +17,16 @@ namespace PSManagement.Domain.Steps.Entities
public string StepName { get; set; }
public string Description { get; set; }
public int Duration { get; set; }
public int CurrentCompletionRatio { get; set; }
public int Weight { get; set; }
public DateTime StartDate { get; set; }
public int ProjectId { get; set; }
public Project Project { get; set; }
public ICollection<Item> Purchases { get; set; }
public ICollection<Employee> Participants { get; set; }
public ICollection<StepTrack> StepTracks { get; set; }
//public ICollection<Item> Purchases { get; set; }
//public ICollection<Employee> Participants { get; set; }
public Step()
{
......
using PSManagement.Domain.Employees.Entities;
using PSManagement.SharedKernel.Entities;
using System;
namespace PSManagement.Domain.Tracking
{
public class EmployeeTrack :BaseEntity
{
public int EmloyeeId { get; set; }
public int TrackId { get; set; }
public Employee Employee { get; set; }
public Track Track { get; set; }
public int WorkingHours { get; set; }
public String PerformedWork { get; set; }
public String AssignedWork { get; set; }
//public ICollection<EmployeeWork> EmployeeWorks { get; set; }
}
}
......@@ -10,7 +10,8 @@ namespace PSManagement.Domain.Tracking.Entities
public Step Step { get; set; }
public int TrackId { get; set; }
public Track Track { get; set; }
public ICollection<EmployeeWork> EmployeeWorks { get; set; }
public int ExecutionRatio { get; set; }
//public ICollection<EmployeeWork> EmployeeWorks { get; set; }
public StepTrack()
{
......
using PSManagement.Domain.Projects.Aggregate;
using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Projects.Aggregate;
using PSManagement.Domain.Steps.Entities;
using PSManagement.Domain.Tracking.Entities;
using PSManagement.SharedKernel.Aggregate;
......@@ -18,7 +19,8 @@ namespace PSManagement.Domain.Tracking
public int ProjectId { get; set; }
public Project Project { get; set; }
public ICollection<StepTrack> StepTracks { get; set; }
public ICollection<Employee> TrackedEmployees { get; set; }
public ICollection<EmployeeTrack> EmployeeTracks { get; set; }
public Track()
{
......
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.Projects.Aggregate;
using PSManagement.Domain.Projects.Entities;
namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
......@@ -8,6 +10,16 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public void Configure(EntityTypeBuilder<Project> builder)
{
builder.HasMany(e => e.Participants)
.WithMany(e => e.Projects)
.UsingEntity<EmployeeParticipate>(
l => l.HasOne<Employee>(e => e.Employee)
.WithMany(e => e.EmployeeParticipates)
.HasForeignKey(e => e.EmployeeId),
r => r.HasOne<Project>(e => e.Project)
.WithMany(e => e.EmployeeParticipates)
.HasForeignKey(e => e.ProjectId)
);
builder.OwnsOne(c => c.ProjectAggreement,
p => {
......@@ -24,16 +36,34 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
);
builder.Property(e => e.Participants);
builder.HasOne(e => e.TeamLeader)
.WithMany()
.HasForeignKey(e => e.TeamLeaderId)
.OnDelete(DeleteBehavior.Restrict)
.IsRequired(false);
builder.HasOne(e => e.ProjectManager)
.WithMany()
.HasForeignKey(e => e.ProjectManagerId)
.OnDelete(DeleteBehavior.Restrict)
.IsRequired(false);
builder.OwnsOne(c => c.ProposalInfo,
p => {
p.Property(e => e.ProposingBookDate).HasColumnName("ProposingBookDate");
p.Property(e => e.ProposingBookNumber).HasColumnName("ProposingBookNumber");
}
);
builder.OwnsOne(c => c.FinincialFund,
p => {
p.Property(e => e.FinicialStatus).HasColumnName("FinicialStatus");
p.Property(e => e.Source).HasColumnName("FinicialSource");
}
);
builder.HasMany(e => e.Tracks).WithOne(e => e.Project).HasForeignKey(e => e.ProjectId);
builder.HasOne(e => e.ProjectType).WithMany(r => r.Projects);
builder.Ignore(e => e.Participants);
}
}
}
......@@ -7,8 +7,10 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public class TrackEntityConfiguration :
IEntityTypeConfiguration<Track> ,
IEntityTypeConfiguration<StepTrack>,
IEntityTypeConfiguration<EmployeeWork>
IEntityTypeConfiguration<StepTrack>,
IEntityTypeConfiguration<EmployeeTrack>
//,
//IEntityTypeConfiguration<EmployeeWork>
{
......@@ -19,7 +21,16 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
.WithMany(p => p.Tracks)
.HasForeignKey(t => t.ProjectId)
.OnDelete(DeleteBehavior.Restrict);
//builder.HasMany(e => e.TrackedEmployees)
// .WithMany(e => e.trac)
// .UsingEntity<EmployeeParticipate>(
// l => l.HasOne<Employee>(e => e.Employee)
// .WithMany(e => e.EmployeeParticipates)
// .HasForeignKey(e => e.EmployeeId),
// r => r.HasOne<Project>(e => e.Project)
// .WithMany(e => e.EmployeeParticipates)
// .HasForeignKey(e => e.ProjectId)
// );
}
public void Configure(EntityTypeBuilder<StepTrack> builder)
{
......@@ -36,20 +47,30 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
public void Configure(EntityTypeBuilder<EmployeeWork> builder)
public void Configure(EntityTypeBuilder<EmployeeTrack> builder)
{
builder.HasOne(ew => ew.StepTrack)
.WithMany(st => st.EmployeeWorks)
.HasForeignKey(ew => ew.StepTrackId)
.OnDelete(DeleteBehavior.Restrict); ;
builder.HasOne(st => st.Employee)
.WithMany(s => s.EmployeeTracks)
.HasForeignKey(st => st.EmloyeeId)
;
}
//public void Configure(EntityTypeBuilder<EmployeeWork> builder)
//{
// //builder.HasOne(ew => ew.StepTrack)
// //.WithMany(st => st.EmployeeWorks)
// //.HasForeignKey(ew => ew.StepTrackId)
// // .OnDelete(DeleteBehavior.Restrict); ;
builder.HasOne(ew => ew.Employee)
.WithMany(e => e.EmployeeWorks)
.HasForeignKey(ew => ew.EmployeeId)
.OnDelete(DeleteBehavior.Restrict); ;
// builder.HasOne(ew => ew.Employee)
// .WithMany(e => e.EmployeeWorks)
// .HasForeignKey(ew => ew.EmployeeId)
// .OnDelete(DeleteBehavior.Restrict); ;
}
//}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddDomainUpdate : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Employees_Steps_StepId",
table: "Employees");
migrationBuilder.DropForeignKey(
name: "FK_EmployeeWorks_Employees_EmployeeId",
table: "EmployeeWorks");
migrationBuilder.DropForeignKey(
name: "FK_EmployeeWorks_StepTracks_StepTrackId",
table: "EmployeeWorks");
migrationBuilder.DropForeignKey(
name: "FK_Items_Steps_StepId",
table: "Items");
migrationBuilder.DropIndex(
name: "IX_Items_StepId",
table: "Items");
migrationBuilder.DropColumn(
name: "StepId",
table: "Items");
migrationBuilder.RenameColumn(
name: "StepId",
table: "Employees",
newName: "TrackId");
migrationBuilder.RenameIndex(
name: "IX_Employees_StepId",
table: "Employees",
newName: "IX_Employees_TrackId");
migrationBuilder.AddColumn<int>(
name: "ExecutionRatio",
table: "StepTracks",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "CurrentCompletionRatio",
table: "Steps",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<int>(
name: "Weight",
table: "Steps",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateTable(
name: "EmployeeParticipate",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmployeeId = table.Column<int>(type: "int", nullable: false),
ProjectId = table.Column<int>(type: "int", nullable: false),
PartialTimeRatio = table.Column<int>(type: "int", nullable: false),
Role = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeParticipate", x => x.Id);
table.ForeignKey(
name: "FK_EmployeeParticipate_Employees_EmployeeId",
column: x => x.EmployeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EmployeeParticipate_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "EmployeeTrack",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
EmloyeeId = table.Column<int>(type: "int", nullable: false),
TrackId = table.Column<int>(type: "int", nullable: false),
WorkingHours = table.Column<int>(type: "int", nullable: false),
PerformedWork = table.Column<string>(type: "nvarchar(max)", nullable: true),
AssignedWork = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_EmployeeTrack", x => x.Id);
table.ForeignKey(
name: "FK_EmployeeTrack_Employees_EmloyeeId",
column: x => x.EmloyeeId,
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_EmployeeTrack_Tracks_TrackId",
column: x => x.TrackId,
principalTable: "Tracks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_EmployeeParticipate_EmployeeId",
table: "EmployeeParticipate",
column: "EmployeeId");
migrationBuilder.CreateIndex(
name: "IX_EmployeeParticipate_ProjectId",
table: "EmployeeParticipate",
column: "ProjectId");
migrationBuilder.CreateIndex(
name: "IX_EmployeeTrack_EmloyeeId",
table: "EmployeeTrack",
column: "EmloyeeId");
migrationBuilder.CreateIndex(
name: "IX_EmployeeTrack_TrackId",
table: "EmployeeTrack",
column: "TrackId");
migrationBuilder.AddForeignKey(
name: "FK_Employees_Tracks_TrackId",
table: "Employees",
column: "TrackId",
principalTable: "Tracks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_EmployeeWorks_Employees_EmployeeId",
table: "EmployeeWorks",
column: "EmployeeId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_EmployeeWorks_StepTracks_StepTrackId",
table: "EmployeeWorks",
column: "StepTrackId",
principalTable: "StepTracks",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Employees_Tracks_TrackId",
table: "Employees");
migrationBuilder.DropForeignKey(
name: "FK_EmployeeWorks_Employees_EmployeeId",
table: "EmployeeWorks");
migrationBuilder.DropForeignKey(
name: "FK_EmployeeWorks_StepTracks_StepTrackId",
table: "EmployeeWorks");
migrationBuilder.DropTable(
name: "EmployeeParticipate");
migrationBuilder.DropTable(
name: "EmployeeTrack");
migrationBuilder.DropColumn(
name: "ExecutionRatio",
table: "StepTracks");
migrationBuilder.DropColumn(
name: "CurrentCompletionRatio",
table: "Steps");
migrationBuilder.DropColumn(
name: "Weight",
table: "Steps");
migrationBuilder.RenameColumn(
name: "TrackId",
table: "Employees",
newName: "StepId");
migrationBuilder.RenameIndex(
name: "IX_Employees_TrackId",
table: "Employees",
newName: "IX_Employees_StepId");
migrationBuilder.AddColumn<int>(
name: "StepId",
table: "Items",
type: "int",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_Items_StepId",
table: "Items",
column: "StepId");
migrationBuilder.AddForeignKey(
name: "FK_Employees_Steps_StepId",
table: "Employees",
column: "StepId",
principalTable: "Steps",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_EmployeeWorks_Employees_EmployeeId",
table: "EmployeeWorks",
column: "EmployeeId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_EmployeeWorks_StepTracks_StepTrackId",
table: "EmployeeWorks",
column: "StepTrackId",
principalTable: "StepTracks",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Items_Steps_StepId",
table: "Items",
column: "StepId",
principalTable: "Steps",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddDomainUpdate2 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects");
migrationBuilder.DropForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId",
table: "Projects");
migrationBuilder.DropTable(
name: "ProjectType");
migrationBuilder.DropIndex(
name: "IX_Projects_ProjectTypeId",
table: "Projects");
migrationBuilder.DropColumn(
name: "ProjectTypeId",
table: "Projects");
migrationBuilder.AlterColumn<int>(
name: "TeamLeaderId",
table: "Projects",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddColumn<string>(
name: "FinicialSource",
table: "Projects",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<string>(
name: "FinicialStatus",
table: "Projects",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ProjectManagerId",
table: "Projects",
type: "int",
nullable: false,
defaultValue: 0);
migrationBuilder.CreateIndex(
name: "IX_Projects_ProjectManagerId",
table: "Projects",
column: "ProjectManagerId");
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects",
column: "ProjectManagerId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects",
column: "TeamLeaderId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects");
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects");
migrationBuilder.DropIndex(
name: "IX_Projects_ProjectManagerId",
table: "Projects");
migrationBuilder.DropColumn(
name: "FinicialSource",
table: "Projects");
migrationBuilder.DropColumn(
name: "FinicialStatus",
table: "Projects");
migrationBuilder.DropColumn(
name: "ProjectManagerId",
table: "Projects");
migrationBuilder.AlterColumn<int>(
name: "TeamLeaderId",
table: "Projects",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddColumn<int>(
name: "ProjectTypeId",
table: "Projects",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "ProjectType",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
TypeName = table.Column<string>(type: "nvarchar(max)", nullable: true),
WorkerCount = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProjectType", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Projects_ProjectTypeId",
table: "Projects",
column: "ProjectTypeId");
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects",
column: "TeamLeaderId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId",
table: "Projects",
column: "ProjectTypeId",
principalTable: "ProjectType",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddDomainUpdate3 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects");
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects");
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects",
column: "ProjectManagerId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects",
column: "TeamLeaderId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects");
migrationBuilder.DropForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects");
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_ProjectManagerId",
table: "Projects",
column: "ProjectManagerId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
migrationBuilder.AddForeignKey(
name: "FK_Projects_Employees_TeamLeaderId",
table: "Projects",
column: "TeamLeaderId",
principalTable: "Employees",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
}
}
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddDomainUpdate4 : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
}
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment