Organization_Management #142
@ -193,6 +193,7 @@ namespace Marco.Pms.DataAccess.Data
|
|||||||
DomainName = "www.marcobms.org",
|
DomainName = "www.marcobms.org",
|
||||||
TenantStatusId = Guid.Parse("62b05792-5115-4f99-8ff5-e8374859b191"),
|
TenantStatusId = Guid.Parse("62b05792-5115-4f99-8ff5-e8374859b191"),
|
||||||
IndustryId = Guid.Parse("15436ee3-a650-469e-bfc2-59993f7514bb"),
|
IndustryId = Guid.Parse("15436ee3-a650-469e-bfc2-59993f7514bb"),
|
||||||
|
OrganizationId = Guid.Parse("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"),
|
||||||
BillingAddress = "2nd Floor, Fullora Building, Tejas CHS, behind Kothrud Stand, Tejas Society, Dahanukar Colony, Kothrud, Pune, Maharashtra 411038",
|
BillingAddress = "2nd Floor, Fullora Building, Tejas CHS, behind Kothrud Stand, Tejas Society, Dahanukar Colony, Kothrud, Pune, Maharashtra 411038",
|
||||||
OnBoardingDate = DateTime.MinValue,
|
OnBoardingDate = DateTime.MinValue,
|
||||||
IsSuperTenant = true,
|
IsSuperTenant = true,
|
||||||
|
@ -62,7 +62,6 @@ namespace Marco.Pms.DataAccess.Initializer
|
|||||||
// State = "State",
|
// State = "State",
|
||||||
// Postalcode = "1234567890",
|
// Postalcode = "1234567890",
|
||||||
// City = "City",
|
// City = "City",
|
||||||
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26"),
|
|
||||||
IsRootUser = true,
|
IsRootUser = true,
|
||||||
|
|
||||||
}, "User@123").GetAwaiter().GetResult();
|
}, "User@123").GetAwaiter().GetResult();
|
||||||
@ -81,8 +80,7 @@ namespace Marco.Pms.DataAccess.Initializer
|
|||||||
ApplicationUserId = user.Id,
|
ApplicationUserId = user.Id,
|
||||||
BirthDate = DateTime.MinValue,
|
BirthDate = DateTime.MinValue,
|
||||||
PermanentAddress = "",
|
PermanentAddress = "",
|
||||||
PhoneNumber = "",
|
PhoneNumber = ""
|
||||||
TenantId = user.TenantId
|
|
||||||
};
|
};
|
||||||
_db.Employees.Add(emp);
|
_db.Employees.Add(emp);
|
||||||
|
|
||||||
|
6122
Marco.Pms.DataAccess/Migrations/20250917092024_Added_Organization_In_Tenant_Table_As_Forgin_Key.Designer.cs
generated
Normal file
6122
Marco.Pms.DataAccess/Migrations/20250917092024_Added_Organization_In_Tenant_Table_As_Forgin_Key.Designer.cs
generated
Normal file
File diff suppressed because one or more lines are too long
@ -0,0 +1,69 @@
|
|||||||
|
using Microsoft.EntityFrameworkCore.Migrations;
|
||||||
|
|
||||||
|
#nullable disable
|
||||||
|
|
||||||
|
namespace Marco.Pms.DataAccess.Migrations
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
public partial class Added_Organization_In_Tenant_Table_As_Forgin_Key : Migration
|
||||||
|
{
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "TenantId",
|
||||||
|
table: "AspNetUsers");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "OrganizationId",
|
||||||
|
table: "Tenants",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: false,
|
||||||
|
defaultValue: new Guid("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"),
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
|
||||||
|
migrationBuilder.UpdateData(
|
||||||
|
table: "Tenants",
|
||||||
|
keyColumn: "Id",
|
||||||
|
keyValue: new Guid("b3466e83-7e11-464c-b93a-daf047838b26"),
|
||||||
|
column: "OrganizationId",
|
||||||
|
value: new Guid("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"));
|
||||||
|
|
||||||
|
migrationBuilder.CreateIndex(
|
||||||
|
name: "IX_Tenants_OrganizationId",
|
||||||
|
table: "Tenants",
|
||||||
|
column: "OrganizationId");
|
||||||
|
|
||||||
|
migrationBuilder.AddForeignKey(
|
||||||
|
name: "FK_Tenants_Organizations_OrganizationId",
|
||||||
|
table: "Tenants",
|
||||||
|
column: "OrganizationId",
|
||||||
|
principalTable: "Organizations",
|
||||||
|
principalColumn: "Id",
|
||||||
|
onDelete: ReferentialAction.Cascade);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <inheritdoc />
|
||||||
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
|
{
|
||||||
|
migrationBuilder.DropForeignKey(
|
||||||
|
name: "FK_Tenants_Organizations_OrganizationId",
|
||||||
|
table: "Tenants");
|
||||||
|
|
||||||
|
migrationBuilder.DropIndex(
|
||||||
|
name: "IX_Tenants_OrganizationId",
|
||||||
|
table: "Tenants");
|
||||||
|
|
||||||
|
migrationBuilder.DropColumn(
|
||||||
|
name: "OrganizationId",
|
||||||
|
table: "Tenants");
|
||||||
|
|
||||||
|
migrationBuilder.AddColumn<Guid>(
|
||||||
|
name: "TenantId",
|
||||||
|
table: "AspNetUsers",
|
||||||
|
type: "char(36)",
|
||||||
|
nullable: true,
|
||||||
|
collation: "ascii_general_ci");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4175,6 +4175,9 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Property<DateTime>("OnBoardingDate")
|
b.Property<DateTime>("OnBoardingDate")
|
||||||
.HasColumnType("datetime(6)");
|
.HasColumnType("datetime(6)");
|
||||||
|
|
||||||
|
b.Property<Guid>("OrganizationId")
|
||||||
|
.HasColumnType("char(36)");
|
||||||
|
|
||||||
b.Property<string>("OrganizationSize")
|
b.Property<string>("OrganizationSize")
|
||||||
.HasColumnType("longtext");
|
.HasColumnType("longtext");
|
||||||
|
|
||||||
@ -4195,6 +4198,8 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.HasIndex("IndustryId");
|
b.HasIndex("IndustryId");
|
||||||
|
|
||||||
|
b.HasIndex("OrganizationId");
|
||||||
|
|
||||||
b.HasIndex("TenantStatusId");
|
b.HasIndex("TenantStatusId");
|
||||||
|
|
||||||
b.ToTable("Tenants");
|
b.ToTable("Tenants");
|
||||||
@ -4214,6 +4219,7 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
IsSuperTenant = true,
|
IsSuperTenant = true,
|
||||||
Name = "MarcoBMS",
|
Name = "MarcoBMS",
|
||||||
OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
OnBoardingDate = new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified),
|
||||||
|
OrganizationId = new Guid("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea"),
|
||||||
OrganizationSize = "100-200",
|
OrganizationSize = "100-200",
|
||||||
Reference = "Root Tenant",
|
Reference = "Root Tenant",
|
||||||
TenantStatusId = new Guid("62b05792-5115-4f99-8ff5-e8374859b191"),
|
TenantStatusId = new Guid("62b05792-5115-4f99-8ff5-e8374859b191"),
|
||||||
@ -4539,9 +4545,6 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
b.Property<bool?>("IsRootUser")
|
b.Property<bool?>("IsRootUser")
|
||||||
.HasColumnType("tinyint(1)");
|
.HasColumnType("tinyint(1)");
|
||||||
|
|
||||||
b.Property<Guid>("TenantId")
|
|
||||||
.HasColumnType("char(36)");
|
|
||||||
|
|
||||||
b.HasDiscriminator().HasValue("ApplicationUser");
|
b.HasDiscriminator().HasValue("ApplicationUser");
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -5982,6 +5985,12 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("IndustryId");
|
.HasForeignKey("IndustryId");
|
||||||
|
|
||||||
|
b.HasOne("Marco.Pms.Model.OrganizationModel.Organization", "Organization")
|
||||||
|
.WithMany()
|
||||||
|
.HasForeignKey("OrganizationId")
|
||||||
|
.OnDelete(DeleteBehavior.Cascade)
|
||||||
|
.IsRequired();
|
||||||
|
|
||||||
b.HasOne("Marco.Pms.Model.Master.TenantStatus", "TenantStatus")
|
b.HasOne("Marco.Pms.Model.Master.TenantStatus", "TenantStatus")
|
||||||
.WithMany()
|
.WithMany()
|
||||||
.HasForeignKey("TenantStatusId")
|
.HasForeignKey("TenantStatusId")
|
||||||
@ -5990,6 +5999,8 @@ namespace Marco.Pms.DataAccess.Migrations
|
|||||||
|
|
||||||
b.Navigation("Industry");
|
b.Navigation("Industry");
|
||||||
|
|
||||||
|
b.Navigation("Organization");
|
||||||
|
|
||||||
b.Navigation("TenantStatus");
|
b.Navigation("TenantStatus");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1,23 +1,10 @@
|
|||||||
using System.ComponentModel;
|
using Microsoft.AspNetCore.Identity;
|
||||||
using Microsoft.AspNetCore.Identity;
|
|
||||||
|
|
||||||
namespace Marco.Pms.Model.Entitlements
|
namespace Marco.Pms.Model.Entitlements
|
||||||
{
|
{
|
||||||
public class ApplicationUser : IdentityUser
|
public class ApplicationUser : IdentityUser
|
||||||
{
|
{
|
||||||
//[Required]
|
|
||||||
// public string Role { get; set; } // e.g. Admin, SiteManager, SkilledWorker, etc.
|
|
||||||
|
|
||||||
|
|
||||||
[DisplayName("TenantId")]
|
|
||||||
public Guid TenantId { get; set; }
|
|
||||||
|
|
||||||
public bool? IsRootUser { get; set; } = false;
|
public bool? IsRootUser { get; set; } = false;
|
||||||
|
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
|
|
||||||
//[ValidateNever]
|
|
||||||
//[ForeignKey(nameof(TenantId))]
|
|
||||||
//public Tenant Tenant { get; set; }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using Marco.Pms.Model.Master;
|
using Marco.Pms.Model.Master;
|
||||||
|
using Marco.Pms.Model.OrganizationModel;
|
||||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||||
using System.ComponentModel.DataAnnotations.Schema;
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
@ -34,5 +35,10 @@ namespace Marco.Pms.Model.TenantModels
|
|||||||
|
|
||||||
public bool IsActive { get; set; } = true;
|
public bool IsActive { get; set; } = true;
|
||||||
public bool IsSuperTenant { get; set; } = false;
|
public bool IsSuperTenant { get; set; } = false;
|
||||||
|
public Guid OrganizationId { get; set; } = Guid.Parse("4e3a6d31-c640-40f7-8d67-6c109fcdb9ea");
|
||||||
|
|
||||||
|
[ValidateNever]
|
||||||
|
[ForeignKey("OrganizationId")]
|
||||||
|
public Organization? Organization { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -520,7 +520,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
OTP = otp,
|
OTP = otp,
|
||||||
ExpriesInSec = 300, // 10 minutes
|
ExpriesInSec = 300, // 10 minutes
|
||||||
TimeStamp = DateTime.UtcNow,
|
TimeStamp = DateTime.UtcNow,
|
||||||
TenantId = requestedUser.TenantId
|
TenantId = Guid.Parse("b3466e83-7e11-464c-b93a-daf047838b26")
|
||||||
};
|
};
|
||||||
|
|
||||||
_context.OTPDetails.Add(otpDetails);
|
_context.OTPDetails.Add(otpDetails);
|
||||||
|
@ -353,8 +353,7 @@ namespace MarcoBMS.Services.Controllers
|
|||||||
{
|
{
|
||||||
UserName = model.Email,
|
UserName = model.Email,
|
||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
EmailConfirmed = true,
|
EmailConfirmed = true
|
||||||
TenantId = tenantId
|
|
||||||
|
|
||||||
};
|
};
|
||||||
var isSeatsAvaiable = await _generalHelper.CheckSeatsRemainingAsync(tenantId);
|
var isSeatsAvaiable = await _generalHelper.CheckSeatsRemainingAsync(tenantId);
|
||||||
|
@ -489,8 +489,7 @@ namespace Marco.Pms.Services.Controllers
|
|||||||
Email = model.Email,
|
Email = model.Email,
|
||||||
UserName = model.Email, // Best practice to use email as username for simplicity
|
UserName = model.Email, // Best practice to use email as username for simplicity
|
||||||
IsRootUser = true,
|
IsRootUser = true,
|
||||||
EmailConfirmed = true, // Auto-confirming email as it's part of a trusted setup process
|
EmailConfirmed = true // Auto-confirming email as it's part of a trusted setup process
|
||||||
TenantId = tenant.Id
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// SECURITY WARNING: Hardcoded passwords are a major vulnerability.
|
// SECURITY WARNING: Hardcoded passwords are a major vulnerability.
|
||||||
|
@ -140,8 +140,7 @@ namespace Marco.Pms.Services.Service
|
|||||||
UserName = settings.Email,
|
UserName = settings.Email,
|
||||||
Email = settings.Email,
|
Email = settings.Email,
|
||||||
EmailConfirmed = true,
|
EmailConfirmed = true,
|
||||||
IsRootUser = true,
|
IsRootUser = true
|
||||||
TenantId = tenantId
|
|
||||||
};
|
};
|
||||||
var result = await userManager.CreateAsync(user, settings.Password);
|
var result = await userManager.CreateAsync(user, settings.Password);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user