Added the forign key of organization in eployee table
This commit is contained in:
parent
68cd5acc9c
commit
5158153ee6
6098
Marco.Pms.DataAccess/Migrations/20250917072710_Added_Organization_In_Employee_Table.Designer.cs
generated
Normal file
6098
Marco.Pms.DataAccess/Migrations/20250917072710_Added_Organization_In_Employee_Table.Designer.cs
generated
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,70 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Added_Organization_In_Employee_Table : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Organizations_Employees_CreatedById",
|
||||||
|
table: "Organizations");
|
||||||
|
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Organizations_Employees_UpdatedById",
|
||||||
|
table: "Organizations");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Organizations_CreatedById",
|
||||||
|
table: "Organizations");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Organizations_UpdatedById",
|
||||||
|
table: "Organizations");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "OrganizationId",
|
||||||
|
table: "Employees",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new Guid("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"),
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationId",
|
||||||
|
table: "Employees");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Organizations_CreatedById",
|
||||||
|
table: "Organizations",
|
||||||
|
column: "CreatedById");
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Organizations_UpdatedById",
|
||||||
|
table: "Organizations",
|
||||||
|
column: "UpdatedById");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Organizations_Employees_CreatedById",
|
||||||
|
table: "Organizations",
|
||||||
|
column: "CreatedById",
|
||||||
|
principalTable: "Employees",
|
||||||
|
principalColumn: "Id");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Organizations_Employees_UpdatedById",
|
||||||
|
table: "Organizations",
|
||||||
|
column: "UpdatedById",
|
||||||
|
principalTable: "Employees",
|
||||||
|
principalColumn: "Id");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
File diff suppressed because one or more lines are too long
@ -0,0 +1,39 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Added_Organization_In_Employee_Table_As_Forgin_Key : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Employees_OrganizationId",
|
||||||
|
table: "Employees",
|
||||||
|
column: "OrganizationId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Employees_Organizations_OrganizationId",
|
||||||
|
table: "Employees",
|
||||||
|
column: "OrganizationId",
|
||||||
|
principalTable: "Organizations",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Employees_Organizations_OrganizationId",
|
||||||
|
table: "Employees");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Employees_OrganizationId",
|
||||||
|
table: "Employees");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
6111
Marco.Pms.DataAccess/Migrations/20250917090050_Added_IsPrimary_Parameter_In_Employee_Table.Designer.cs
generated
Normal file
6111
Marco.Pms.DataAccess/Migrations/20250917090050_Added_IsPrimary_Parameter_In_Employee_Table.Designer.cs
generated
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,29 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Added_IsPrimary_Parameter_In_Employee_Table : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.AddColumn<bool>(
|
||||||
|
name: "IsPrimary",
|
||||||
|
table: "Employees",
|
||||||
|
type: "tinyint(1)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "IsPrimary",
|
||||||
|
table: "Employees");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1220,6 +1220,9 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Property<bool>("IsActive")
|
b.Property<bool>("IsActive")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
|
b.Property<bool>("IsPrimary")
|
||||||
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
b.Property<bool>("IsSystem")
|
b.Property<bool>("IsSystem")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
@ -1235,6 +1238,9 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Property<string>("MiddleName")
|
b.Property<string>("MiddleName")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
|
b.Property<Guid>("OrganizationId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("PermanentAddress")
|
b.Property<string>("PermanentAddress")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
@ -1253,6 +1259,8 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.HasIndex("JobRoleId");
|
b.HasIndex("JobRoleId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganizationId");
|
||||||
|
|
||||||
b.HasIndex("TenantId");
|
b.HasIndex("TenantId");
|
||||||
|
|
||||||
b.ToTable("Employees");
|
b.ToTable("Employees");
|
||||||
@ -3647,10 +3655,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
b.HasIndex("CreatedById");
|
|
||||||
|
|
||||||
b.HasIndex("UpdatedById");
|
|
||||||
|
|
||||||
b.ToTable("Organizations");
|
b.ToTable("Organizations");
|
||||||
|
|
||||||
b.HasData(
|
b.HasData(
|
||||||
@ -5131,6 +5135,12 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
.OnDelete(DeleteBehavior.Cascade)
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
.IsRequired();
|
.IsRequired();
|
||||||
|
|
||||||
|
b.HasOne("Marco.Pms.Model.OrganizationModel.Organization", "Organization")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("OrganizationId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Marco.Pms.Model.TenantModels.Tenant", "Tenant")
|
b.HasOne("Marco.Pms.Model.TenantModels.Tenant", "Tenant")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("TenantId")
|
.HasForeignKey("TenantId")
|
||||||
@ -5141,6 +5151,8 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.Navigation("JobRole");
|
b.Navigation("JobRole");
|
||||||
|
|
||||||
|
b.Navigation("Organization");
|
||||||
|
|
||||||
b.Navigation("Tenant");
|
b.Navigation("Tenant");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -5694,21 +5706,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Navigation("Service");
|
b.Navigation("Service");
|
||||||
});
|
});
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.OrganizationModel.Organization", b =>
|
|
||||||
{
|
|
||||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("CreatedById");
|
|
||||||
|
|
||||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "UpdatedBy")
|
|
||||||
.WithMany()
|
|
||||||
.HasForeignKey("UpdatedById");
|
|
||||||
|
|
||||||
b.Navigation("CreatedBy");
|
|
||||||
|
|
||||||
b.Navigation("UpdatedBy");
|
|
||||||
});
|
|
||||||
|
|
||||||
modelBuilder.Entity("Marco.Pms.Model.OrganizationModel.ProjectOrgMapping", b =>
|
modelBuilder.Entity("Marco.Pms.Model.OrganizationModel.ProjectOrgMapping", b =>
|
||||||
{
|
{
|
||||||
b.HasOne("Marco.Pms.Model.OrganizationModel.Organization", "Organization")
|
b.HasOne("Marco.Pms.Model.OrganizationModel.Organization", "Organization")
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Marco.Pms.Model.Entitlements;
|
using Marco.Pms.Model.Entitlements;
|
||||||
|
using Marco.Pms.Model.OrganizationModel;
|
||||||
using Marco.Pms.Model.Roles;
|
using Marco.Pms.Model.Roles;
|
||||||
using Marco.Pms.Model.Utilities;
|
using Marco.Pms.Model.Utilities;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
@ -28,12 +29,19 @@ namespace Marco.Pms.Model.Employees
|
|||||||
public ApplicationUser? ApplicationUser { get; set; }
|
public ApplicationUser? ApplicationUser { get; set; }
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public bool HasApplicationAccess { get; set; } = false;
|
public bool HasApplicationAccess { get; set; } = false;
|
||||||
|
public bool IsPrimary { get; set; } = false;
|
||||||
public bool IsSystem { get; set; } = false;
|
public bool IsSystem { get; set; } = false;
|
||||||
public Guid JobRoleId { get; set; }
|
public Guid JobRoleId { get; set; }
|
||||||
[ForeignKey("JobRoleId")]
|
[ForeignKey("JobRoleId")]
|
||||||
[ValidateNever]
|
[ValidateNever]
|
||||||
public JobRole? JobRole { get; set; }
|
public JobRole? JobRole { get; set; }
|
||||||
|
|
||||||
|
public Guid OrganizationId { get; set; } = Guid.Parse("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea");
|
||||||
|
|
||||||
|
[ValidateNever]
|
||||||
|
[ForeignKey("OrganizationId")]
|
||||||
|
public Organization? Organization { get; set; }
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,8 +1,4 @@
|
|||||||
using Marco.Pms.Model.Employees;
|
namespace Marco.Pms.Model.OrganizationModel
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.OrganizationModel
|
|
||||||
{
|
{
|
||||||
public class Organization
|
public class Organization
|
||||||
{
|
{
|
||||||
@ -16,14 +12,14 @@ namespace Marco.Pms.Model.OrganizationModel
|
|||||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||||
public Guid? CreatedById { get; set; }
|
public Guid? CreatedById { get; set; }
|
||||||
|
|
||||||
[ValidateNever]
|
//[ValidateNever]
|
||||||
[ForeignKey("CreatedById")]
|
//[ForeignKey("CreatedById")]
|
||||||
public Employee? CreatedBy { get; set; }
|
//public Employee? CreatedBy { get; set; }
|
||||||
public Guid? UpdatedById { get; set; }
|
public Guid? UpdatedById { get; set; }
|
||||||
|
|
||||||
[ValidateNever]
|
//[ValidateNever]
|
||||||
[ForeignKey("UpdatedById")]
|
//[ForeignKey("UpdatedById")]
|
||||||
public Employee? UpdatedBy { get; set; }
|
//public Employee? UpdatedBy { get; set; }
|
||||||
public DateTime? UpdatedAt { get; set; }
|
public DateTime? UpdatedAt { get; set; }
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
}
|
}
|
||||||
|
@ -130,7 +130,6 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
UserName = model.Email,
|
UserName = model.Email,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
EmailConfirmed = true
|
EmailConfirmed = true
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var _configuration = scope.ServiceProvider.GetRequiredService<IConfiguration>();
|
var _configuration = scope.ServiceProvider.GetRequiredService<IConfiguration>();
|
||||||
@ -160,8 +159,8 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
JobRoleId = jobRole?.Id ?? Guid.Empty,
|
JobRoleId = jobRole?.Id ?? Guid.Empty,
|
||||||
IsActive = true,
|
IsActive = true,
|
||||||
IsSystem = false,
|
IsSystem = false,
|
||||||
//IsPrimary = true,
|
IsPrimary = true,
|
||||||
//OrganizationId = organization.Id,
|
OrganizationId = organization.Id,
|
||||||
TenantId = tenantId
|
TenantId = tenantId
|
||||||
};
|
};
|
||||||
_context.Employees.Add(newEmployee);
|
_context.Employees.Add(newEmployee);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user