Commit ebb68b8b authored by hasan khaddour's avatar hasan khaddour

fix s.

parent 49ba44c1
......@@ -6,6 +6,29 @@ namespace PSManagement.Domain.FinancialSpends.Entities
{
public class FinancialSpending : BaseEntity
{
public FinancialSpending()
{
}
public FinancialSpending(
int projectId,
int localPurchase,
Money externalPurchase,
string costType,
string description,
DateTime expectedSpendingDate)
{
ProjectId = projectId;
LocalPurchase = localPurchase;
ExternalPurchase = externalPurchase;
CostType = costType;
Description = description;
ExpectedSpendingDate = expectedSpendingDate;
}
public int ProjectId { get; set; }
public DateTime ExpectedSpendingDate { get; set; }
public string CostType { get; set; }
public string Description { get; set; }
......
using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.SharedKernel.Specification;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;
namespace PSManagement.Domain.FinancialSpends.Specification
{
public class FinancialSpendingSpecification : BaseSpecification<FinancialSpending>
{
public FinancialSpendingSpecification(Expression<Func<FinancialSpending, bool>> criteria = null) : base(criteria)
{
}
}
}
......@@ -3,7 +3,6 @@ using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.Domain.Projects.DomainEvents;
using PSManagement.Domain.Projects.Entities;
using PSManagement.Domain.Projects.ValueObjects;
using PSManagement.Domain.ProjectsStatus.Entites;
using System;
using System.Collections.Generic;
using System.Linq;
......
using PSManagement.SharedKernel.DomainErrors;
namespace PSManagement.Domain.Projects.DomainErrors
{
public class StepsErrors
{
public static DomainError InvalidEntryError { get; } = new("StepError.InvalidEntry.", "Invalid Step Data");
public static DomainError InvalidWeightError { get; } = new("StepError.WeightEror", "the Step weight incompatible");
public static DomainError InvalidCompletionRatioError { get; } = new("StepError.CompleteionRatioEror", "the Step Completion Ratio Entered is incompatible");
}
}
......@@ -2,7 +2,6 @@
using PSManagement.Domain.Employees.Entities;
using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.Domain.Projects.ValueObjects;
using PSManagement.Domain.ProjectsStatus.Entites;
using PSManagement.Domain.ProjectTypes.Entities;
using PSManagement.Domain.Tracking;
using PSManagement.SharedKernel.Aggregate;
......
......@@ -13,10 +13,10 @@ namespace PSManagement.Domain.Projects.Repositories
{
public interface IProjectsRepository :IRepository<Project>
{
public IEnumerable<EmployeeParticipate> GetProjectParticipants(int projectId);
public IEnumerable<EmployeeParticipate> GetProjectParticipants(int projectId, ISpecification<Project> specification=null);
public IEnumerable<Step> GetProjectPlan(int projectId);
public IEnumerable<Track> GetProjectTracks(int projectId);
}
}
using PSManagement.Domain.Projects.Entities;
using PSManagement.SharedKernel.Specification;
using System;
using System.Linq.Expressions;
namespace PSManagement.Domain.Projects
{
public class StepSpecification : BaseSpecification<Step>
{
public StepSpecification(Expression<Func<Step, bool>> criteria = null) : base(criteria)
{
}
}
}
using PSManagement.Domain.Projects.Entities;
using PSManagement.SharedKernel.Entities;
using System;
using System.Collections.Generic;
namespace PSManagement.Domain.Tracking.Entities
......@@ -10,6 +11,8 @@ namespace PSManagement.Domain.Tracking.Entities
public Step Step { get; set; }
public int TrackId { get; set; }
public Track Track { get; set; }
public String ExecutionState { get; set; }
public int ExecutionRatio { get; set; }
//public ICollection<EmployeeWork> EmployeeWorks { get; set; }
public StepTrack()
......
using PSManagement.SharedKernel.Entities;
namespace PSManagement.Domain.ProjectsStatus.Entites
{
public class ProjectStatus : BaseEntity
{
public string Name { get; set; }
public string Details { get; set; }
public string Code { get; set; }
}
}
using PSManagement.Domain.ProjectsStatus.Entites;
using PSManagement.SharedKernel.Repositories;
namespace PSManagement.Domain.ProjectsStatus.Repositories
{
public interface IProjectStatusRepository : IRepository<ProjectStatus>
{
}
}
using Microsoft.EntityFrameworkCore;
using PSManagement.Domain.Customers.Entities;
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;
......@@ -27,6 +28,8 @@ namespace PSManagement.Infrastructure.Persistence
public DbSet<Employee> Employees { get; set; }
public DbSet<Department> Departments { get; set; }
public DbSet<Project> Projects { get; set; }
public DbSet<FinancialSpending> FinancialSpendings { get; set; }
public DbSet<Step> Steps { get; set; }
public DbSet<Track> Tracks { get; set; }
......
......@@ -3,6 +3,8 @@ using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using PSManagement.Domain.Customers.Repositories;
using PSManagement.Domain.Employees.Repositories;
using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.Domain.FinincialSpending.Repositories;
using PSManagement.Domain.Identity.Repositories;
using PSManagement.Domain.Projects.Builders;
using PSManagement.Domain.Projects.Repositories;
......@@ -33,6 +35,7 @@ namespace PSManagement.Infrastructure.Persistence.DI
services.AddScoped<IRolesRepository, RolesRepository>();
services.AddScoped<IEmployeesRepository, EmployeesRespository>();
services.AddScoped<IStepsRepository, StepsRepository>();
services.AddScoped<IFinancialSpendingRepository, FinancialSpendingRepository>();
services.AddScoped<ProjectBuilder>();
......
......@@ -66,7 +66,7 @@ namespace PSManagement.Infrastructure.Persistence.EntitiesConfiguration
builder.Property(p => p.CurrentState).HasDefaultValue("Proposed");
builder.HasMany(e => e.Attachments).WithOne().HasForeignKey(e => e.ProjectId);
builder.HasMany(e => e.FinancialSpending);
builder.HasMany(e => e.FinancialSpending).WithOne().HasForeignKey(e=>e.ProjectId);
builder.HasMany(e => e.Tracks).WithOne(e => e.Project).HasForeignKey(e => e.ProjectId);
}
......
using Microsoft.EntityFrameworkCore.Migrations;
namespace PSManagement.Infrastructure.Persistence.Migrations
{
public partial class FixSomeIssues : Migration
{
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FinancialSpending_Projects_ProjectId",
table: "FinancialSpending");
migrationBuilder.DropPrimaryKey(
name: "PK_FinancialSpending",
table: "FinancialSpending");
migrationBuilder.RenameTable(
name: "FinancialSpending",
newName: "FinancialSpendings");
migrationBuilder.RenameIndex(
name: "IX_FinancialSpending_ProjectId",
table: "FinancialSpendings",
newName: "IX_FinancialSpendings_ProjectId");
migrationBuilder.AlterColumn<int>(
name: "ProjectId",
table: "FinancialSpendings",
type: "int",
nullable: false,
defaultValue: 0,
oldClrType: typeof(int),
oldType: "int",
oldNullable: true);
migrationBuilder.AddPrimaryKey(
name: "PK_FinancialSpendings",
table: "FinancialSpendings",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FinancialSpendings_Projects_ProjectId",
table: "FinancialSpendings",
column: "ProjectId",
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
}
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_FinancialSpendings_Projects_ProjectId",
table: "FinancialSpendings");
migrationBuilder.DropPrimaryKey(
name: "PK_FinancialSpendings",
table: "FinancialSpendings");
migrationBuilder.RenameTable(
name: "FinancialSpendings",
newName: "FinancialSpending");
migrationBuilder.RenameIndex(
name: "IX_FinancialSpendings_ProjectId",
table: "FinancialSpending",
newName: "IX_FinancialSpending_ProjectId");
migrationBuilder.AlterColumn<int>(
name: "ProjectId",
table: "FinancialSpending",
type: "int",
nullable: true,
oldClrType: typeof(int),
oldType: "int");
migrationBuilder.AddPrimaryKey(
name: "PK_FinancialSpending",
table: "FinancialSpending",
column: "Id");
migrationBuilder.AddForeignKey(
name: "FK_FinancialSpending_Projects_ProjectId",
table: "FinancialSpending",
column: "ProjectId",
principalTable: "Projects",
principalColumn: "Id",
onDelete: ReferentialAction.Restrict);
}
}
}
......@@ -130,14 +130,14 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b.Property<int>("LocalPurchase")
.HasColumnType("int");
b.Property<int?>("ProjectId")
b.Property<int>("ProjectId")
.HasColumnType("int");
b.HasKey("Id");
b.HasIndex("ProjectId");
b.ToTable("FinancialSpending");
b.ToTable("FinancialSpendings");
});
modelBuilder.Entity("PSManagement.Domain.Identity.Entities.Permission", b =>
......@@ -721,7 +721,9 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
{
b.HasOne("PSManagement.Domain.Projects.Entities.Project", null)
.WithMany("FinancialSpending")
.HasForeignKey("ProjectId");
.HasForeignKey("ProjectId")
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.OwnsOne("PSManagement.SharedKernel.ValueObjects.Money", "ExternalPurchase", b1 =>
{
......@@ -742,7 +744,7 @@ namespace PSManagement.Infrastructure.Persistence.Migrations
b1.HasKey("FinancialSpendingId");
b1.ToTable("FinancialSpending");
b1.ToTable("FinancialSpendings");
b1.WithOwner()
.HasForeignKey("FinancialSpendingId");
......
using PSManagement.Domain.FinancialSpends.Entities;
using PSManagement.Domain.FinincialSpending.Repositories;
using PSManagement.Infrastructure.Persistence.Repositories.Base;
namespace PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
{
public class FinancialSpendingRepository : BaseRepository<FinancialSpending>, IFinancialSpendingRepository
{
public FinancialSpendingRepository(AppDbContext context) : base(context)
{
}
}
}
......@@ -19,10 +19,11 @@ namespace PSManagement.Infrastructure.Persistence.Repositories.ProjectRepository
{
}
public IEnumerable<EmployeeParticipate> GetProjectParticipants(int projectId)
public IEnumerable<EmployeeParticipate> GetProjectParticipants(int projectId, ISpecification<Project> specification)
{
return _dbContext.Projects.Where(p => p.Id == projectId).FirstOrDefault()?.EmployeeParticipates.AsEnumerable();
return ApplySpecification(specification).Where(p =>p.Id== projectId).FirstOrDefault().EmployeeParticipates.AsEnumerable();
}
......
using MediatR;
namespace PSManagement.SharedKernel.CQRS.Command
{
public interface ILoggableCommand<out TResponse> : ICommand<TResponse>
{
}
}
......@@ -15,7 +15,7 @@ namespace PSManagement.SharedKernel.Specification
}
public Expression<Func<T, bool>> Criteria { get; set; }
public List<Expression<Func<T, object>>> Includes { get; } = new List<Expression<Func<T, object>>>();
public List<string> IncludeStrings { get; } = new List<string>();
public List<string> IncludeStrings { get; set; } = new List<string>();
public Expression<Func<T, object>> OrderBy { get; private set; }
public Expression<Func<T, object>> OrderByDescending { get; private set; }
......
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