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,6 +47,11 @@ namespace PSManagement.Domain.Projects.Builders
_participants = participates;
return this;
}
public ProjectBuilder WithType(ProjectType projectType)
{
_projectType = projectType;
return this;
}
public ProjectBuilder WithFinancialSpending(ICollection<FinancialSpending> financialSpending)
{
......@@ -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)
;
}
}
}
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