Compare commits

...

5 Commits

7 changed files with 2294 additions and 13 deletions

View File

@ -3,6 +3,7 @@ using Marco.Pms.Model.AttendanceModule;
using Marco.Pms.Model.Authentication;
using Marco.Pms.Model.Employees;
using Marco.Pms.Model.Entitlements;
using Marco.Pms.Model.Industries;
using Marco.Pms.Model.Projects;
using Marco.Pms.Utility;
using Microsoft.AspNetCore.Http;
@ -62,6 +63,7 @@ namespace Marco.Pms.DataAccess.Data
public DbSet<JobRole> JobRoles { get; set; }
public DbSet<RolePermissionMappings> RolePermissionMappings { get; set; }
public DbSet<Industry>Industries { get; set; }
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
@ -122,7 +124,7 @@ namespace Marco.Pms.DataAccess.Data
});
modelBuilder.Entity<Tenant>().HasData(
new Tenant { Id = 1, Name = "MarcoBMS", ContactName = "Admin", ContactNumber = "123456789", Description = "", DomainName = "www.marcobms.org", OnBoardingDate = DateTime.MinValue }
new Tenant { Id = 1, Name = "MarcoBMS", ContactName = "Admin", ContactNumber = "123456789", Description = "", DomainName = "www.marcobms.org",IndustryId = 1, OnBoardingDate = DateTime.MinValue }
);
modelBuilder.Entity<StatusMaster>().HasData(
@ -268,6 +270,18 @@ namespace Marco.Pms.DataAccess.Data
UnitOfMeasurement = UnitOfMeasurement.Number.ToString(),
TenantId = 1
}
);
modelBuilder.Entity<Industry>().HasData(
new Industry {Id = 1,Name = "Information Technology (IT) Services"},
new Industry { Id = 2,Name = "Manufacturing & Production" },
new Industry { Id = 3,Name = "Energy & Resources" },
new Industry { Id = 4,Name = "Finance & Professional Services" },
new Industry { Id = 5, Name = "Hospitals and Healthcare Services" },
new Industry { Id = 6, Name = "Social Services" },
new Industry { Id = 7, Name = "Retail & Consumer Services" },
new Industry { Id = 8, Name = "Transportation & Logistics" },
new Industry { Id = 9, Name = "Education & Training" }
);
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,135 @@
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
namespace Marco.Pms.DataAccess.Migrations
{
/// <inheritdoc />
public partial class Add_Industry_Table : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
//migrationBuilder.DropColumn(
// name: "Role",
// table: "AspNetUsers");
migrationBuilder.AddColumn<int>(
name: "IndustryId",
table: "Tenants",
type: "int",
nullable: true);
migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "Tenants",
type: "tinyint(1)",
nullable: false,
defaultValue: false);
migrationBuilder.AddColumn<string>(
name: "OragnizationSize",
table: "Tenants",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.AddColumn<bool>(
name: "IsActive",
table: "AspNetUsers",
type: "tinyint(1)",
nullable: true);
migrationBuilder.CreateTable(
name: "Industries",
columns: table => new
{
Id = table.Column<int>(type: "int", nullable: false)
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
Name = table.Column<string>(type: "longtext", nullable: false)
.Annotation("MySql:CharSet", "utf8mb4")
},
constraints: table =>
{
table.PrimaryKey("PK_Industries", x => x.Id);
})
.Annotation("MySql:CharSet", "utf8mb4");
migrationBuilder.InsertData(
table: "Industries",
columns: new[] { "Id", "Name" },
values: new object[,]
{
{ 1, "Information Technology (IT) Services" },
{ 2, "Manufacturing & Production" },
{ 3, "Energy & Resources" },
{ 4, "Finance & Professional Services" },
{ 5, "Hospitals and Healthcare Services" },
{ 6, "Social Services" },
{ 7, "Retail & Consumer Services" },
{ 8, "Transportation & Logistics" },
{ 9, "Education & Training" }
});
migrationBuilder.UpdateData(
table: "Tenants",
keyColumn: "Id",
keyValue: 1,
columns: new[] { "IndustryId", "IsActive", "OragnizationSize" },
values: new object[] { 1, true, null });
migrationBuilder.CreateIndex(
name: "IX_Tenants_IndustryId",
table: "Tenants",
column: "IndustryId");
migrationBuilder.AddForeignKey(
name: "FK_Tenants_Industries_IndustryId",
table: "Tenants",
column: "IndustryId",
principalTable: "Industries",
principalColumn: "Id");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_Tenants_Industries_IndustryId",
table: "Tenants");
migrationBuilder.DropTable(
name: "Industries");
migrationBuilder.DropIndex(
name: "IX_Tenants_IndustryId",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IndustryId",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IsActive",
table: "Tenants");
migrationBuilder.DropColumn(
name: "OragnizationSize",
table: "Tenants");
migrationBuilder.DropColumn(
name: "IsActive",
table: "AspNetUsers");
migrationBuilder.AddColumn<string>(
name: "Role",
table: "AspNetUsers",
type: "longtext",
nullable: true)
.Annotation("MySql:CharSet", "utf8mb4");
}
}
}

View File

@ -1040,6 +1040,12 @@ namespace Marco.Pms.DataAccess.Migrations
.IsRequired()
.HasColumnType("longtext");
b.Property<int?>("IndustryId")
.HasColumnType("int");
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
@ -1047,8 +1053,13 @@ namespace Marco.Pms.DataAccess.Migrations
b.Property<DateTime>("OnBoardingDate")
.HasColumnType("datetime(6)");
b.Property<string>("OragnizationSize")
.HasColumnType("longtext");
b.HasKey("Id");
b.HasIndex("IndustryId");
b.ToTable("Tenants");
b.HasData(
@ -1059,11 +1070,77 @@ namespace Marco.Pms.DataAccess.Migrations
ContactNumber = "123456789",
Description = "",
DomainName = "www.marcobms.org",
IndustryId = 1,
IsActive = true,
Name = "MarcoBMS",
OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified)
});
});
modelBuilder.Entity("Marco.Pms.Model.Industries.Industry", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("int");
MySqlPropertyBuilderExtensions.UseMySqlIdentityColumn(b.Property<int>("Id"));
b.Property<string>("Name")
.IsRequired()
.HasColumnType("longtext");
b.HasKey("Id");
b.ToTable("Industries");
b.HasData(
new
{
Id = 1,
Name = "Information Technology (IT) Services"
},
new
{
Id = 2,
Name = "Manufacturing & Production"
},
new
{
Id = 3,
Name = "Energy & Resources"
},
new
{
Id = 4,
Name = "Finance & Professional Services"
},
new
{
Id = 5,
Name = "Hospitals and Healthcare Services"
},
new
{
Id = 6,
Name = "Social Services"
},
new
{
Id = 7,
Name = "Retail & Consumer Services"
},
new
{
Id = 8,
Name = "Transportation & Logistics"
},
new
{
Id = 9,
Name = "Education & Training"
});
});
modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b =>
{
b.Property<int>("Id")
@ -1465,12 +1542,11 @@ namespace Marco.Pms.DataAccess.Migrations
{
b.HasBaseType("Microsoft.AspNetCore.Identity.IdentityUser");
b.Property<bool?>("IsRootUser")
b.Property<bool>("IsActive")
.HasColumnType("tinyint(1)");
b.Property<string>("Role")
.IsRequired()
.HasColumnType("longtext");
b.Property<bool?>("IsRootUser")
.HasColumnType("tinyint(1)");
b.Property<int>("TenantId")
.HasColumnType("int");
@ -1782,6 +1858,15 @@ namespace Marco.Pms.DataAccess.Migrations
b.Navigation("Tenant");
});
modelBuilder.Entity("Marco.Pms.Model.Entitlements.Tenant", b =>
{
b.HasOne("Marco.Pms.Model.Industries.Industry", "Industry")
.WithMany()
.HasForeignKey("IndustryId");
b.Navigation("Industry");
});
modelBuilder.Entity("Marco.Pms.Model.Projects.Building", b =>
{
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")

View File

@ -9,14 +9,16 @@ namespace Marco.Pms.Model.Entitlements
{
public class ApplicationUser : IdentityUser
{
[Required]
public string Role { get; set; } // e.g. Admin, SiteManager, SkilledWorker, etc.
//[Required]
// public string Role { get; set; } // e.g. Admin, SiteManager, SkilledWorker, etc.
[DisplayName("TenantId")]
public int TenantId { get; set; }
public bool? IsRootUser { get; set; }
public bool? IsRootUser { get; set; } = false;
public bool IsActive { get; set; } = true;
//[ValidateNever]
//[ForeignKey(nameof(TenantId))]

View File

@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.ComponentModel.DataAnnotations.Schema;
using Marco.Pms.Model.Industries;
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
namespace Marco.Pms.Model.Entitlements
{
@ -15,5 +13,13 @@ namespace Marco.Pms.Model.Entitlements
public string ContactName { get; set; }
public string ContactNumber { get; set; }
public DateTime OnBoardingDate { get; set; }
public string? OragnizationSize { get; set; }
public int? IndustryId { get;set; }
[ForeignKey("IndustryId")]
[ValidateNever]
public Industry Industry{ get; set; }
public bool IsActive { get; set; } = true;
}
}

View File

@ -0,0 +1,8 @@
namespace Marco.Pms.Model.Industries
{
public class Industry
{
public int Id { get; set; }
public string Name { get; set; }
}
}