Commit 9c6c50b6 authored by hasan khaddour's avatar hasan khaddour

CQRS and migration for the project type and completion info

parent fcb517f9
......@@ -6,7 +6,6 @@
<ItemGroup>
<Folder Include="Identity\ValueObjects\" />
<Folder Include="XReports\Repositories\" />
</ItemGroup>
<ItemGroup>
......
......@@ -17,7 +17,7 @@ namespace PSManagement.Domain.Projects.Builders
private ProjectInfo _projectInfo;
private FinancialFund _financialFund;
private Aggreement _projectAggreement;
private ProjectType _projectType;
// information about who lead and execute the project
private int _teamLeaderId;
private int _projectManagerId;
......@@ -30,6 +30,13 @@ namespace PSManagement.Domain.Projects.Builders
private ICollection<Attachment> _attachments;
private ICollection<FinancialSpending> _financialSpending;
public ProjectBuilder WithClassification(ICollection<FinancialSpending> financialSpendings)
{
_financialSpending = financialSpendings;
return this;
}
public ProjectBuilder WithClassification(ProjectClassification projectClassification)
{
_projectClassification = projectClassification;
......@@ -40,8 +47,13 @@ namespace PSManagement.Domain.Projects.Builders
_participants = participates;
return this;
}
public ProjectBuilder WithType(ProjectType projectType)
{
_projectType = projectType;
return this;
}
public ProjectBuilder WithFinancialSpending(ICollection<FinancialSpending> financialSpending)
public ProjectBuilder WithFinancialSpending(ICollection<FinancialSpending> financialSpending)
{
_financialSpending = financialSpending;
return this;
......@@ -120,7 +132,8 @@ namespace PSManagement.Domain.Projects.Builders
_projectManagerId ,
_executerId,
_stateName,
_projectClassification);
_projectClassification,
_projectType);
project.FinancialFund = _financialFund;
if (_attachments is not null) {
......
using Ardalis.Result;
using PSManagement.SharedKernel.DomainErrors;
namespace PSManagement.Domain.Projects.DomainErrors
{
public class PrjectTypesErrors
{
public static DomainError InvalidEntryError { get; } = new("ProjectErrors.InvalidEntry.", "Invalid Step Data");
public static DomainError InvalidName { get; } = new("ProjectErrors.InvalidEntry.", "the name is already exist");
}
}
......@@ -25,6 +25,8 @@ namespace PSManagement.Domain.Projects.Entities
public ProposalInfo ProposalInfo { get; set; }
public ProjectInfo ProjectInfo { get; set; }
public Aggreement ProjectAggreement { get; set; }
public ProjectType ProjectType { get; set; }
public ProjectCompletion ProjectCompletion { get; set; }
public ProjectClassification ProjectClassification { get; set; }
#endregion Project informations
......@@ -119,9 +121,9 @@ namespace PSManagement.Domain.Projects.Entities
#region State Transitions
public Result Complete()
public Result Complete(ProjectCompletion projectCompletion)
{
return State.Complete(this);
return State.Complete(this, projectCompletion );
}
public Result Plan()
......@@ -175,9 +177,11 @@ namespace PSManagement.Domain.Projects.Entities
int projectManagerId,
int executerId,
string stateName,
ProjectClassification projectClassification
ProjectClassification projectClassification,
ProjectType projectType
)
{
ProjectType = projectType;
ProjectClassification = projectClassification;
SetStateFromString(stateName);
ProposalInfo = proposalInfo;
......
using PSManagement.SharedKernel.Entities;
using System;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Domain.Projects.Entities
{
public class ProjectCompletion :BaseEntity
{
public int ProjectId { get; set; }
public Project Project { get; set; }
public DateTime CompletionDate { get; set; }
public String CustomerNotes { get; set; }
public int CustomerRate { get; set; }
}
}
using PSManagement.SharedKernel.Entities;
using System.Collections.Generic;
namespace PSManagement.Domain.Projects.Entities
{
public class ProjectType : BaseEntity
{
public string TypeName { get; set; }
public string Description { get; set; }
public int ExpectedEffort { get; set; }
public ICollection<Project> Projects { get; set; }
}
}
using PSManagement.Domain.Projects.Entities;
using PSManagement.SharedKernel.Interfaces;
using PSManagement.SharedKernel.Repositories;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace PSManagement.Domain.Projects.Repositories
{
public interface IProjectTypesRepository : IRepository<ProjectType>
{
public Task<IEnumerable<Project>> GetProjectsByTypeName(string typeName, ISpecification<ProjectType> specification=null);
public Task<IEnumerable<ProjectType>> GetByTypeName(string typeName, ISpecification<ProjectType> specification=null);
}
}
using PSManagement.Domain.Projects.Entities;
using PSManagement.SharedKernel.Specification;
using System;
using System.Linq.Expressions;
namespace PSManagement.Domain.Projects
{
public class ProjectTypeSpecification : BaseSpecification<ProjectType>
{
public ProjectTypeSpecification(Expression<Func<ProjectType, bool>> criteria = null) : base(criteria)
{
AddInclude(u => u.Projects);
}
}
}
......@@ -19,7 +19,7 @@ namespace PSManagement.Domain.Projects.Entities
return Result.Invalid(ProjectsErrors.StateTracnsitionError("Cancelled", "Cancelled"));
}
public Result Complete(Project project)
public Result Complete(Project project, ProjectCompletion projectCompletion)
{
return Result.Invalid(ProjectsErrors.StateTracnsitionError("Cancelled", "Completed"));
}
......
......@@ -19,7 +19,7 @@ namespace PSManagement.Domain.Projects.Entities
return Result.Invalid(ProjectsErrors.StateTracnsitionError("Completed", "Cancelled"));
}
public Result Complete(Project project)
public Result Complete(Project project , ProjectCompletion ProjectCompletion)
{
return Result.Invalid(ProjectsErrors.StateTracnsitionError("Completed", "Completed"));
}
......
......@@ -6,7 +6,7 @@ namespace PSManagement.Domain.Projects.Entities
{
public interface IProjectState
{
Result Complete(Project project);
Result Complete(Project project, ProjectCompletion projectCompletion);
Result Plan(Project project);
Result Approve(Project project);
Result Cancel(Project project, DateTime canellationTime);
......
......@@ -27,8 +27,9 @@ namespace PSManagement.Domain.Projects.Entities
}
public Result Complete(Project project)
public Result Complete(Project project , ProjectCompletion projectCompletion)
{
project.ProjectCompletion = projectCompletion;
project.AddDomainEvent(new ProjectCompletedEvent(project.Id));
project.SetState(new CompletedState());
return Result.Success();
......
......@@ -24,8 +24,9 @@ namespace PSManagement.Domain.Projects.Entities
return Result.Success();
}
public Result Complete(Project project)
public Result Complete(Project project, ProjectCompletion projectCompletion)
{
project.ProjectCompletion = projectCompletion;
project.AddDomainEvent(new ProjectCompletedEvent(project.Id));
project.SetState(new CompletedState());
return Result.Success();
......
......@@ -22,7 +22,7 @@ namespace PSManagement.Domain.Projects.Entities
}
public Result Complete(Project project)
public Result Complete(Project project, ProjectCompletion projectCompletion)
{
return Result.Invalid(ProjectsErrors.StateTracnsitionError("Proposed", "Completed"));
......
......@@ -2,8 +2,7 @@
{
public record ProjectClassification(
string ProjectNature,
string ProjectStatus,
string ProjectType
string ProjectStatus
);
}
using PSManagement.SharedKernel.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Domain.Reports.Entities
{
public class Report :BaseEntity
{
public String ReportName { get; set; }
public ICollection<Section> Sections { get; set; }
}
public class Section : BaseEntity
{
public String SectionName { get; set; }
public Report Report { get; set; }
public ICollection<Question> Questions { get; set; }
}
public class Question : BaseEntity
{
public String QuestionName { get; set; }
public ICollection<Section> Sections { get; set; }
}
public class Answer : BaseEntity
{
public Question Question { get; set; }
public String AnswerValue { get; set; }
}
public class ReportResult : BaseEntity
{
public Report Report { get; set; }
public ICollection<Answer> Answers { get; set; }
}
}
......@@ -4,7 +4,6 @@ using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.Domain.Identity.Entities;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Reports.Entities;
using PSManagement.Domain.Tracking;
using PSManagement.Domain.Tracking.Entities;
using PSManagement.Infrastructure.Persistence.SeedDataContext;
......@@ -19,8 +18,7 @@ namespace PSManagement.Infrastructure.Persistence
{
}
public DbSet<Report> Reports { get; set; }
public DbSet<ReportResult> ReportResults { get; set; }
public DbSet<User> Users { get; set; }
public DbSet<Role> Roles { get; set; }
public DbSet<Permission> Permission { get; set; }
......
......@@ -5,7 +5,7 @@ using PSManagement.Domain.Projects.Entities;
namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
{
public class ProjectEntityConfiguration : IEntityTypeConfiguration<Project>
public class ProjectEntityConfiguration : IEntityTypeConfiguration<Project> ,IEntityTypeConfiguration<ProjectCompletion>
{
public void Configure(EntityTypeBuilder<Project> builder)
{
......@@ -30,10 +30,14 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
p => {
p.Property(e => e.ProjectNature).HasColumnName("ProjectNature");
p.Property(e => e.ProjectStatus).HasColumnName("ProjectStatus");
p.Property(e => e.ProjectType).HasColumnName("ProjectType");
}
);
builder.HasOne(e => e.ProjectType)
.WithMany();
builder.OwnsOne(c => c.ProjectInfo,
p => {
p.Property(e => e.Description).HasColumnName("Description");
......@@ -85,7 +89,12 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
}
public void Configure(EntityTypeBuilder<ProjectCompletion> builder)
{
builder.HasOne(e => e.Project)
.WithOne(e => e.ProjectCompletion)
;
}
}
}
// <auto-generated />
using System;
using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Infrastructure;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
using PSManagement.Infrastructure.Persistence;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
[DbContext(typeof(AppDbContext))]
[Migration("20240825063804_AddProjectType")]
partial class AddProjectType
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
{
#pragma warning disable 612, 618
modelBuilder
.HasAnnotation("Relational:Collation", "Arabic_CI_AS")
.HasAnnotation("Relational:MaxIdentifierLength", 128)
.HasAnnotation("ProductVersion", "5.0.17")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
modelBuilder.Entity("PSManagement.Domain.Customers.Entities.ContactInfo", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ContactType")
.HasColumnType("nvarchar(max)");
b.Property<string>("ContactValue")
.HasColumnType("nvarchar(max)");
b.Property<int?>("CustomerId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.ToTable("ContactInfo");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Entities.Customer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CustomerName")
.HasColumnType("nvarchar(max)");
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Customers");
});
modelBuilder.Entity("PSManagement.Domain.Employees.Entities.Department", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Departments");
b.HasData(
new
{
Id = 1,
Name = "قسم المعلوميات"
},
new
{
Id = 2,
Name = "قسم النظم الإلكترونية"
},
new
{
Id = 3,
Name = "قسم الميكاترونيكس"
},
new
{
Id = 4,
Name = "قسم الفيزياء"
},
new
{
Id = 5,
Name = "مديرية التطوير والخدمات البرمجية"
},
new
{
Id = 6,
Name = "شؤون الطلاب"
});
});
modelBuilder.Entity("PSManagement.Domain.Employees.Entities.Employee", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("DepartmentId")
.HasColumnType("int");
b.Property<int>("HIASTId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("DepartmentId");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("Employees");
});
modelBuilder.Entity("PSManagement.Domain.FinancialSpends.Entities.FinancialSpending", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CostType")
.HasColumnType("nvarchar(max)");
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<DateTime>("ExpectedSpendingDate")
.HasColumnType("datetime2");
b.Property<int>("LocalPurchase")
.HasColumnType("int");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("FinancialSpendings");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Entities.Permission", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Permission");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Entities.Role", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Name")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Roles");
b.HasData(
new
{
Id = 1,
Name = "Admin"
},
new
{
Id = 2,
Name = "Employee"
},
new
{
Id = 4,
Name = "Scientific-Deputy"
});
});
modelBuilder.Entity("PSManagement.Domain.Identity.Entities.User", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Email")
.HasColumnType("nvarchar(max)");
b.Property<string>("HashedPassword")
.HasColumnType("nvarchar(max)");
b.Property<string>("UserName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Users");
b.HasData(
new
{
Id = 2,
Email = "Admin@Admin",
HashedPassword = "1234",
UserName = "Admin"
});
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Attachment", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("AttachmentDescription")
.HasColumnType("nvarchar(max)");
b.Property<string>("AttachmentName")
.HasColumnType("nvarchar(max)");
b.Property<string>("AttachmentUrl")
.HasColumnType("nvarchar(max)");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Attachment");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.EmployeeParticipate", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("EmployeeId")
.HasColumnType("int");
b.Property<int>("PartialTimeRatio")
.HasColumnType("int");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.Property<string>("Role")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.HasIndex("ProjectId");
b.ToTable("EmployeeParticipate");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Project", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("CurrentState")
.ValueGeneratedOnAdd()
.HasColumnType("nvarchar(max)")
.HasDefaultValueSql("Proposed");
b.Property<int?>("CustomerId")
.HasColumnType("int");
b.Property<int>("ExecuterId")
.HasColumnType("int");
b.Property<int>("ProjectManagerId")
.HasColumnType("int");
b.Property<int?>("ProjectTypeId")
.HasColumnType("int");
b.Property<int?>("ProjectTypeId1")
.HasColumnType("int");
b.Property<int>("ProposerId")
.HasColumnType("int");
b.Property<int>("TeamLeaderId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("CustomerId");
b.HasIndex("ExecuterId");
b.HasIndex("ProjectManagerId");
b.HasIndex("ProjectTypeId");
b.HasIndex("ProjectTypeId1");
b.HasIndex("ProposerId");
b.HasIndex("TeamLeaderId");
b.ToTable("Projects");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectCompletion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("CompletionDate")
.HasColumnType("datetime2");
b.Property<string>("CustomerNotes")
.HasColumnType("nvarchar(max)");
b.Property<int>("CustomerRate")
.HasColumnType("int");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId")
.IsUnique();
b.ToTable("ProjectCompletion");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.Property<int>("ExpectedEffort")
.HasColumnType("int");
b.Property<string>("TypeName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("ProjectType");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("CurrentCompletionRatio")
.HasColumnType("int");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.Property<int>("Weight")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Steps");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.EmployeeTrack", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("EmployeeId")
.HasColumnType("int");
b.Property<string>("Notes")
.HasColumnType("nvarchar(max)");
b.Property<int>("TrackId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("EmployeeId");
b.HasIndex("TrackId");
b.ToTable("EmployeeTrack");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Entities.StepTrack", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("ExecutionState")
.HasColumnType("nvarchar(max)");
b.Property<int>("OldExecutionRatio")
.HasColumnType("int");
b.Property<int>("StepId")
.HasColumnType("int");
b.Property<int>("TrackExecutionRatio")
.HasColumnType("int");
b.Property<int>("TrackId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("StepId");
b.HasIndex("TrackId");
b.ToTable("StepTracks");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Track", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("Notes")
.HasColumnType("nvarchar(max)");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Tracks");
});
modelBuilder.Entity("PermissionRole", b =>
{
b.Property<int>("PermissionsId")
.HasColumnType("int");
b.Property<int>("RolesId")
.HasColumnType("int");
b.HasKey("PermissionsId", "RolesId");
b.HasIndex("RolesId");
b.ToTable("PermissionRole");
});
modelBuilder.Entity("UserRole", b =>
{
b.Property<int>("RoleId")
.HasColumnType("int");
b.Property<int>("UserId")
.HasColumnType("int");
b.HasKey("RoleId", "UserId");
b.HasIndex("UserId");
b.ToTable("UserRole");
b.HasData(
new
{
RoleId = 1,
UserId = 1
});
});
modelBuilder.Entity("PSManagement.Domain.Customers.Entities.ContactInfo", b =>
{
b.HasOne("PSManagement.Domain.Customers.Entities.Customer", null)
.WithMany("ContactInfo")
.HasForeignKey("CustomerId");
});
modelBuilder.Entity("PSManagement.Domain.Customers.Entities.Customer", b =>
{
b.OwnsOne("PSManagement.Domain.Customers.ValueObjects.Address", "Address", b1 =>
{
b1.Property<int>("CustomerId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("City")
.HasColumnType("nvarchar(max)")
.HasColumnName("City");
b1.Property<string>("StreetName")
.HasColumnType("nvarchar(max)")
.HasColumnName("StreetName");
b1.Property<int>("StreetNumber")
.HasColumnType("int")
.HasColumnName("StreetNumber");
b1.HasKey("CustomerId");
b1.ToTable("Customers");
b1.WithOwner()
.HasForeignKey("CustomerId");
});
b.Navigation("Address");
});
modelBuilder.Entity("PSManagement.Domain.Employees.Entities.Employee", b =>
{
b.HasOne("PSManagement.Domain.Employees.Entities.Department", "Department")
.WithMany()
.HasForeignKey("DepartmentId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("PSManagement.Domain.Identity.Entities.User", "User")
.WithOne("Employee")
.HasForeignKey("PSManagement.Domain.Employees.Entities.Employee", "UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("PSManagement.Domain.Employees.Entities.Availability", "Availability", b1 =>
{
b1.Property<int>("EmployeeId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<int>("CurrentWorkingHours")
.HasColumnType("int")
.HasColumnName("CurrentWorkingHours");
b1.Property<bool>("IsAvailable")
.HasColumnType("bit")
.HasColumnName("IsAvailable");
b1.HasKey("EmployeeId");
b1.ToTable("Employees");
b1.WithOwner()
.HasForeignKey("EmployeeId");
});
b.OwnsOne("PSManagement.Domain.Employees.Entities.PersonalInfo", "PersonalInfo", b1 =>
{
b1.Property<int>("EmployeeId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("FirstName")
.HasColumnType("nvarchar(max)")
.HasColumnName("FirstName");
b1.Property<string>("LastName")
.HasColumnType("nvarchar(max)")
.HasColumnName("LastName");
b1.HasKey("EmployeeId");
b1.ToTable("Employees");
b1.WithOwner()
.HasForeignKey("EmployeeId");
});
b.OwnsOne("PSManagement.Domain.Employees.Entities.WorkInfo", "WorkInfo", b1 =>
{
b1.Property<int>("EmployeeId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("WorkJob")
.HasColumnType("nvarchar(max)")
.HasColumnName("WorkJob");
b1.Property<string>("WorkType")
.HasColumnType("nvarchar(max)")
.HasColumnName("WorkType");
b1.HasKey("EmployeeId");
b1.ToTable("Employees");
b1.WithOwner()
.HasForeignKey("EmployeeId");
});
b.Navigation("Availability");
b.Navigation("Department");
b.Navigation("PersonalInfo");
b.Navigation("User");
b.Navigation("WorkInfo");
});
modelBuilder.Entity("PSManagement.Domain.FinancialSpends.Entities.FinancialSpending", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", null)
.WithMany("FinancialSpending")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("PSManagement.SharedKernel.ValueObjects.Money", "ExternalPurchase", b1 =>
{
b1.Property<int>("FinancialSpendingId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<int>("Ammount")
.HasColumnType("int")
.HasColumnName("ExternalPurchaseAmmount");
b1.Property<string>("Currency")
.ValueGeneratedOnAdd()
.HasColumnType("nvarchar(max)")
.HasDefaultValue("USD")
.HasColumnName("ExternalPurchaseCurrency");
b1.HasKey("FinancialSpendingId");
b1.ToTable("FinancialSpendings");
b1.WithOwner()
.HasForeignKey("FinancialSpendingId");
});
b.Navigation("ExternalPurchase");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Attachment", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", null)
.WithMany("Attachments")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.EmployeeParticipate", b =>
{
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "Employee")
.WithMany("EmployeeParticipates")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithMany("EmployeeParticipates")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Employee");
b.Navigation("Project");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Project", b =>
{
b.HasOne("PSManagement.Domain.Customers.Entities.Customer", null)
.WithMany("Projects")
.HasForeignKey("CustomerId");
b.HasOne("PSManagement.Domain.Employees.Entities.Department", "Executer")
.WithMany()
.HasForeignKey("ExecuterId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "ProjectManager")
.WithMany()
.HasForeignKey("ProjectManagerId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("PSManagement.Domain.Projects.Entities.ProjectType", "ProjectType")
.WithMany()
.HasForeignKey("ProjectTypeId");
b.HasOne("PSManagement.Domain.Projects.Entities.ProjectType", null)
.WithMany("Projects")
.HasForeignKey("ProjectTypeId1");
b.HasOne("PSManagement.Domain.Customers.Entities.Customer", "Proposer")
.WithMany()
.HasForeignKey("ProposerId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "TeamLeader")
.WithMany()
.HasForeignKey("TeamLeaderId")
.OnDelete(DeleteBehavior.Restrict);
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.Aggreement", "ProjectAggreement", b1 =>
{
b1.Property<int>("ProjectId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<DateTime>("AggreementDate")
.HasColumnType("datetime2")
.HasColumnName("AggreementDate");
b1.Property<int>("AggreementNumber")
.HasColumnType("int")
.HasColumnName("AggreementNumber");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
b1.WithOwner()
.HasForeignKey("ProjectId");
});
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.FinancialFund", "FinancialFund", b1 =>
{
b1.Property<int>("ProjectId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("FinancialStatus")
.HasColumnType("nvarchar(max)")
.HasColumnName("FinicialStatus");
b1.Property<string>("Source")
.HasColumnType("nvarchar(max)")
.HasColumnName("FinicialSource");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
b1.WithOwner()
.HasForeignKey("ProjectId");
});
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.ProjectClassification", "ProjectClassification", b1 =>
{
b1.Property<int>("ProjectId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("ProjectNature")
.HasColumnType("nvarchar(max)")
.HasColumnName("ProjectNature");
b1.Property<string>("ProjectStatus")
.HasColumnType("nvarchar(max)")
.HasColumnName("ProjectStatus");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
b1.WithOwner()
.HasForeignKey("ProjectId");
});
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.ProjectInfo", "ProjectInfo", b1 =>
{
b1.Property<int>("ProjectId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Code")
.HasColumnType("nvarchar(max)")
.HasColumnName("Code");
b1.Property<string>("Description")
.HasColumnType("nvarchar(max)")
.HasColumnName("Description");
b1.Property<DateTime>("ExpectedEndDate")
.HasColumnType("datetime2")
.HasColumnName("ExpectedEndDate");
b1.Property<string>("Name")
.HasColumnType("nvarchar(max)")
.HasColumnName("Name");
b1.Property<DateTime>("StartDate")
.HasColumnType("datetime2")
.HasColumnName("StartDate");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
b1.WithOwner()
.HasForeignKey("ProjectId");
});
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.ProposalInfo", "ProposalInfo", b1 =>
{
b1.Property<int>("ProjectId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<DateTime>("ProposingBookDate")
.HasColumnType("datetime2")
.HasColumnName("ProposingBookDate");
b1.Property<int>("ProposingBookNumber")
.HasColumnType("int")
.HasColumnName("ProposingBookNumber");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
b1.WithOwner()
.HasForeignKey("ProjectId");
});
b.Navigation("Executer");
b.Navigation("FinancialFund");
b.Navigation("ProjectAggreement");
b.Navigation("ProjectClassification");
b.Navigation("ProjectInfo");
b.Navigation("ProjectManager");
b.Navigation("ProjectType");
b.Navigation("ProposalInfo");
b.Navigation("Proposer");
b.Navigation("TeamLeader");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectCompletion", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithOne("ProjectCompletion")
.HasForeignKey("PSManagement.Domain.Projects.Entities.ProjectCompletion", "ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Project");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithMany("Steps")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("PSManagement.Domain.Projects.ValueObjects.StepInfo", "StepInfo", b1 =>
{
b1.Property<int>("StepId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("Description")
.HasColumnType("nvarchar(max)")
.HasColumnName("Description");
b1.Property<int>("Duration")
.HasColumnType("int")
.HasColumnName("Duration");
b1.Property<DateTime>("StartDate")
.HasColumnType("datetime2")
.HasColumnName("StartDate");
b1.Property<string>("StepName")
.HasColumnType("nvarchar(max)")
.HasColumnName("StepName");
b1.HasKey("StepId");
b1.ToTable("Steps");
b1.WithOwner()
.HasForeignKey("StepId");
});
b.Navigation("Project");
b.Navigation("StepInfo");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.EmployeeTrack", b =>
{
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "Employee")
.WithMany("EmployeeTracks")
.HasForeignKey("EmployeeId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Tracking.Track", "Track")
.WithMany("EmployeeTracks")
.HasForeignKey("TrackId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("PSManagement.Domain.Tracking.ValueObjects.EmployeeWork", "EmployeeWork", b1 =>
{
b1.Property<int>("EmployeeTrackId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<int>("AssignedWorkingHours")
.HasColumnType("int")
.HasColumnName("AssignedWorkingHours");
b1.Property<int>("ContributingRatio")
.HasColumnType("int")
.HasColumnName("ContributingRatio");
b1.Property<int>("WorkedHours")
.HasColumnType("int")
.HasColumnName("WorkedHours");
b1.HasKey("EmployeeTrackId");
b1.ToTable("EmployeeTrack");
b1.WithOwner()
.HasForeignKey("EmployeeTrackId");
});
b.OwnsOne("PSManagement.Domain.Tracking.ValueObjects.EmployeeWorkInfo", "EmployeeWorkInfo", b1 =>
{
b1.Property<int>("EmployeeTrackId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<string>("AssignedWork")
.HasColumnType("nvarchar(max)")
.HasColumnName("AssignedWork");
b1.Property<DateTime>("AssignedWorkEnd")
.HasColumnType("datetime2")
.HasColumnName("AssignedWorkEnd");
b1.Property<string>("PerformedWork")
.HasColumnType("nvarchar(max)")
.HasColumnName("PerformedWork");
b1.HasKey("EmployeeTrackId");
b1.ToTable("EmployeeTrack");
b1.WithOwner()
.HasForeignKey("EmployeeTrackId");
});
b.Navigation("Employee");
b.Navigation("EmployeeWork");
b.Navigation("EmployeeWorkInfo");
b.Navigation("Track");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Entities.StepTrack", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Step", "Step")
.WithMany("StepTracks")
.HasForeignKey("StepId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.HasOne("PSManagement.Domain.Tracking.Track", "Track")
.WithMany("StepTracks")
.HasForeignKey("TrackId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.Navigation("Step");
b.Navigation("Track");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Track", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithMany("Tracks")
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Restrict)
.IsRequired();
b.OwnsOne("PSManagement.Domain.Tracking.ValueObjects.TrackInfo", "TrackInfo", b1 =>
{
b1.Property<int>("TrackId")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b1.Property<bool>("IsCompleted")
.ValueGeneratedOnAdd()
.HasColumnType("bit")
.HasDefaultValue(false)
.HasColumnName("IsCompleted");
b1.Property<string>("StatusDescription")
.HasColumnType("nvarchar(max)")
.HasColumnName("StatusDescription");
b1.Property<DateTime>("TrackDate")
.HasColumnType("datetime2")
.HasColumnName("TrackDate");
b1.HasKey("TrackId");
b1.ToTable("Tracks");
b1.WithOwner()
.HasForeignKey("TrackId");
});
b.Navigation("Project");
b.Navigation("TrackInfo");
});
modelBuilder.Entity("PermissionRole", b =>
{
b.HasOne("PSManagement.Domain.Identity.Entities.Permission", null)
.WithMany()
.HasForeignKey("PermissionsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Identity.Entities.Role", null)
.WithMany()
.HasForeignKey("RolesId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("UserRole", b =>
{
b.HasOne("PSManagement.Domain.Identity.Entities.Role", null)
.WithMany()
.HasForeignKey("RoleId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Identity.Entities.User", null)
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("PSManagement.Domain.Customers.Entities.Customer", b =>
{
b.Navigation("ContactInfo");
b.Navigation("Projects");
});
modelBuilder.Entity("PSManagement.Domain.Employees.Entities.Employee", b =>
{
b.Navigation("EmployeeParticipates");
b.Navigation("EmployeeTracks");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Entities.User", b =>
{
b.Navigation("Employee");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Project", b =>
{
b.Navigation("Attachments");
b.Navigation("EmployeeParticipates");
b.Navigation("FinancialSpending");
b.Navigation("ProjectCompletion");
b.Navigation("Steps");
b.Navigation("Tracks");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectType", b =>
{
b.Navigation("Projects");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.Navigation("StepTracks");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Track", b =>
{
b.Navigation("EmployeeTracks");
b.Navigation("StepTracks");
});
#pragma warning restore 612, 618
}
}
}
using System;
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class AddProjectType : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Answer");
migrationBuilder.DropTable(
name: "QuestionSection");
migrationBuilder.DropTable(
name: "ReportResults");
migrationBuilder.DropTable(
name: "Question");
migrationBuilder.DropTable(
name: "Section");
migrationBuilder.DropTable(
name: "Reports");
migrationBuilder.DropColumn(
name: "ProjectType",
table: "Projects");
migrationBuilder.AddColumn<int>(
name: "ProjectTypeId",
table: "Projects",
type: "int",
nullable: true);
migrationBuilder.AddColumn<int>(
name: "ProjectTypeId1",
table: "Projects",
type: "int",
nullable: true);
migrationBuilder.CreateTable(
name: "ProjectCompletion",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ProjectId = table.Column<int>(type: "int", nullable: false),
CompletionDate = table.Column<DateTime>(type: "datetime2", nullable: false),
CustomerNotes = table.Column<string>(type: "nvarchar(max)", nullable: true),
CustomerRate = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_ProjectCompletion", x => x.Id);
table.ForeignKey(
name: "FK_ProjectCompletion_Projects_ProjectId",
column: x => x.ProjectId,
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateTable(
name: "ProjectType",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
TypeName = table.Column<string>(type: "nvarchar(max)", nullable: true),
Description = table.Column<string>(type: "nvarchar(max)", nullable: true),
ExpectedEffort = 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.CreateIndex(
name: "IX_Projects_ProjectTypeId1",
table: "Projects",
column: "ProjectTypeId1");
migrationBuilder.CreateIndex(
name: "IX_ProjectCompletion_ProjectId",
table: "ProjectCompletion",
column: "ProjectId",
unique: true);
migrationBuilder.AddForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId",
table: "Projects",
column: "ProjectTypeId",
principalTable: "ProjectType",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
migrationBuilder.AddForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId1",
table: "Projects",
column: "ProjectTypeId1",
principalTable: "ProjectType",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId",
table: "Projects");
migrationBuilder.DropForeignKey(
name: "FK_Projects_ProjectType_ProjectTypeId1",
table: "Projects");
migrationBuilder.DropTable(
name: "ProjectCompletion");
migrationBuilder.DropTable(
name: "ProjectType");
migrationBuilder.DropIndex(
name: "IX_Projects_ProjectTypeId",
table: "Projects");
migrationBuilder.DropIndex(
name: "IX_Projects_ProjectTypeId1",
table: "Projects");
migrationBuilder.DropColumn(
name: "ProjectTypeId",
table: "Projects");
migrationBuilder.DropColumn(
name: "ProjectTypeId1",
table: "Projects");
migrationBuilder.AddColumn<string>(
name: "ProjectType",
table: "Projects",
type: "nvarchar(max)",
nullable: true);
migrationBuilder.CreateTable(
name: "Question",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
QuestionName = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Question", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Reports",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReportName = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Reports", x => x.Id);
});
migrationBuilder.CreateTable(
name: "ReportResults",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReportId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_ReportResults", x => x.Id);
table.ForeignKey(
name: "FK_ReportResults_Reports_ReportId",
column: x => x.ReportId,
principalTable: "Reports",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Section",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
ReportId = table.Column<int>(type: "int", nullable: true),
SectionName = table.Column<string>(type: "nvarchar(max)", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Section", x => x.Id);
table.ForeignKey(
name: "FK_Section_Reports_ReportId",
column: x => x.ReportId,
principalTable: "Reports",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "Answer",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("SqlServer:Identity", "1, 1"),
AnswerValue = table.Column<string>(type: "nvarchar(max)", nullable: true),
QuestionId = table.Column<int>(type: "int", nullable: true),
ReportResultId = table.Column<int>(type: "int", nullable: true)
},
constraints: table =>
{
table.PrimaryKey("PK_Answer", x => x.Id);
table.ForeignKey(
name: "FK_Answer_Question_QuestionId",
column: x => x.QuestionId,
principalTable: "Question",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
table.ForeignKey(
name: "FK_Answer_ReportResults_ReportResultId",
column: x => x.ReportResultId,
principalTable: "ReportResults",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
});
migrationBuilder.CreateTable(
name: "QuestionSection",
columns: table => new
{
QuestionsId = table.Column<int>(type: "int", nullable: false),
SectionsId = table.Column<int>(type: "int", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_QuestionSection", x => new { x.QuestionsId, x.SectionsId });
table.ForeignKey(
name: "FK_QuestionSection_Question_QuestionsId",
column: x => x.QuestionsId,
principalTable: "Question",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
table.ForeignKey(
name: "FK_QuestionSection_Section_SectionsId",
column: x => x.SectionsId,
principalTable: "Section",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_Answer_QuestionId",
table: "Answer",
column: "QuestionId");
migrationBuilder.CreateIndex(
name: "IX_Answer_ReportResultId",
table: "Answer",
column: "ReportResultId");
migrationBuilder.CreateIndex(
name: "IX_QuestionSection_SectionsId",
table: "QuestionSection",
column: "SectionsId");
migrationBuilder.CreateIndex(
name: "IX_ReportResults_ReportId",
table: "ReportResults",
column: "ReportId");
migrationBuilder.CreateIndex(
name: "IX_Section_ReportId",
table: "Section",
column: "ReportId");
}
}
}
......@@ -315,6 +315,12 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Property<int>("ProjectManagerId")
.HasColumnType("int");
b.Property<int?>("ProjectTypeId")
.HasColumnType("int");
b.Property<int?>("ProjectTypeId1")
.HasColumnType("int");
b.Property<int>("ProposerId")
.HasColumnType("int");
......@@ -329,6 +335,10 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.HasIndex("ProjectManagerId");
b.HasIndex("ProjectTypeId");
b.HasIndex("ProjectTypeId1");
b.HasIndex("ProposerId");
b.HasIndex("TeamLeaderId");
......@@ -336,119 +346,75 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.ToTable("Projects");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectCompletion", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("CurrentCompletionRatio")
.HasColumnType("int");
b.Property<int>("ProjectId")
.HasColumnType("int");
b.Property<int>("Weight")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("Steps");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Answer", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<DateTime>("CompletionDate")
.HasColumnType("datetime2");
b.Property<string>("AnswerValue")
b.Property<string>("CustomerNotes")
.HasColumnType("nvarchar(max)");
b.Property<int?>("QuestionId")
b.Property<int>("CustomerRate")
.HasColumnType("int");
b.Property<int?>("ReportResultId")
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("QuestionId");
b.HasIndex("ReportResultId");
b.HasIndex("ProjectId")
.IsUnique();
b.ToTable("Answer");
b.ToTable("ProjectCompletion");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Question", b =>
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectType", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<string>("QuestionName")
b.Property<string>("Description")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Question");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Report", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int>("ExpectedEffort")
.HasColumnType("int");
b.Property<string>("ReportName")
b.Property<string>("TypeName")
.HasColumnType("nvarchar(max)");
b.HasKey("Id");
b.ToTable("Reports");
b.ToTable("ProjectType");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.ReportResult", b =>
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int?>("ReportId")
b.Property<int>("CurrentCompletionRatio")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ReportId");
b.ToTable("ReportResults");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Section", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int")
.HasAnnotation("SqlServer:ValueGenerationStrategy", SqlServerValueGenerationStrategy.IdentityColumn);
b.Property<int?>("ReportId")
b.Property<int>("ProjectId")
.HasColumnType("int");
b.Property<string>("SectionName")
.HasColumnType("nvarchar(max)");
b.Property<int>("Weight")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ReportId");
b.HasIndex("ProjectId");
b.ToTable("Section");
b.ToTable("Steps");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.EmployeeTrack", b =>
......@@ -542,21 +508,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.ToTable("PermissionRole");
});
modelBuilder.Entity("QuestionSection", b =>
{
b.Property<int>("QuestionsId")
.HasColumnType("int");
b.Property<int>("SectionsId")
.HasColumnType("int");
b.HasKey("QuestionsId", "SectionsId");
b.HasIndex("SectionsId");
b.ToTable("QuestionSection");
});
modelBuilder.Entity("UserRole", b =>
{
b.Property<int>("RoleId")
......@@ -792,6 +743,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.HasForeignKey("ProjectManagerId")
.OnDelete(DeleteBehavior.Restrict);
b.HasOne("PSManagement.Domain.Projects.Entities.ProjectType", "ProjectType")
.WithMany()
.HasForeignKey("ProjectTypeId");
b.HasOne("PSManagement.Domain.Projects.Entities.ProjectType", null)
.WithMany("Projects")
.HasForeignKey("ProjectTypeId1");
b.HasOne("PSManagement.Domain.Customers.Entities.Customer", "Proposer")
.WithMany()
.HasForeignKey("ProposerId")
......@@ -864,10 +823,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.HasColumnType("nvarchar(max)")
.HasColumnName("ProjectStatus");
b1.Property<string>("ProjectType")
.HasColumnType("nvarchar(max)")
.HasColumnName("ProjectType");
b1.HasKey("ProjectId");
b1.ToTable("Projects");
......@@ -946,6 +901,8 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Navigation("ProjectManager");
b.Navigation("ProjectType");
b.Navigation("ProposalInfo");
b.Navigation("Proposer");
......@@ -953,6 +910,17 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Navigation("TeamLeader");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectCompletion", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
.WithOne("ProjectCompletion")
.HasForeignKey("PSManagement.Domain.Projects.Entities.ProjectCompletion", "ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("Project");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", "Project")
......@@ -997,37 +965,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Navigation("StepInfo");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Answer", b =>
{
b.HasOne("PSManagement.Domain.Reports.Entities.Question", "Question")
.WithMany()
.HasForeignKey("QuestionId");
b.HasOne("PSManagement.Domain.Reports.Entities.ReportResult", null)
.WithMany("Answers")
.HasForeignKey("ReportResultId");
b.Navigation("Question");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.ReportResult", b =>
{
b.HasOne("PSManagement.Domain.Reports.Entities.Report", "Report")
.WithMany()
.HasForeignKey("ReportId");
b.Navigation("Report");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Section", b =>
{
b.HasOne("PSManagement.Domain.Reports.Entities.Report", "Report")
.WithMany("Sections")
.HasForeignKey("ReportId");
b.Navigation("Report");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.EmployeeTrack", b =>
{
b.HasOne("PSManagement.Domain.Employees.Entities.Employee", "Employee")
......@@ -1181,21 +1118,6 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
.IsRequired();
});
modelBuilder.Entity("QuestionSection", b =>
{
b.HasOne("PSManagement.Domain.Reports.Entities.Question", null)
.WithMany()
.HasForeignKey("QuestionsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.HasOne("PSManagement.Domain.Reports.Entities.Section", null)
.WithMany()
.HasForeignKey("SectionsId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
});
modelBuilder.Entity("UserRole", b =>
{
b.HasOne("PSManagement.Domain.Identity.Entities.Role", null)
......@@ -1238,24 +1160,21 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Navigation("FinancialSpending");
b.Navigation("ProjectCompletion");
b.Navigation("Steps");
b.Navigation("Tracks");
});
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.ProjectType", b =>
{
b.Navigation("StepTracks");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.Report", b =>
{
b.Navigation("Sections");
b.Navigation("Projects");
});
modelBuilder.Entity("PSManagement.Domain.Reports.Entities.ReportResult", b =>
modelBuilder.Entity("PSManagement.Domain.Projects.Entities.Step", b =>
{
b.Navigation("Answers");
b.Navigation("StepTracks");
});
modelBuilder.Entity("PSManagement.Domain.Tracking.Track", b =>
......
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