Feature_Directory #90
@ -2,6 +2,7 @@
|
||||
using Marco.Pms.Model.Activities;
|
||||
using Marco.Pms.Model.AttendanceModule;
|
||||
using Marco.Pms.Model.Authentication;
|
||||
using Marco.Pms.Model.Directory;
|
||||
using Marco.Pms.Model.DocumentManager;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Entitlements;
|
||||
@ -67,6 +68,19 @@ namespace Marco.Pms.DataAccess.Data
|
||||
public DbSet<Document> Documents { get; set; }
|
||||
public DbSet<TicketTag> TicketTags { get; set; }
|
||||
public DbSet<WorkCategoryMaster> WorkCategoryMasters { get; set; }
|
||||
public DbSet<Contact> Contacts { get; set; }
|
||||
public DbSet<ContactCategoryMaster> ContactCategoryMasters { get; set; }
|
||||
public DbSet<ContactEmail> ContactsEmails { get; set; }
|
||||
public DbSet<ContactPhone> ContactsPhones { get; set; }
|
||||
public DbSet<ContactNote> ContactNotes { get; set; }
|
||||
public DbSet<Bucket> Buckets { get; set; }
|
||||
public DbSet<ContactTagMaster> ContactTagMasters { get; set; }
|
||||
public DbSet<ContactTagMapping> ContactTagMappings { get; set; }
|
||||
public DbSet<EmployeeBucketMapping> EmployeeBucketMappings { get; set; }
|
||||
public DbSet<ContactBucketMapping> ContactBucketMappings { get; set; }
|
||||
public DbSet<ContactProjectMapping> ContactProjectMappings { get; set; }
|
||||
public DbSet<DirectoryUpdateLog> DirectoryUpdateLogs { get; set; }
|
||||
|
||||
public DbSet<MailingList> MailingList { get; set; }
|
||||
public DbSet<MailDetails> MailDetails { get; set; }
|
||||
public DbSet<MailLog> MailLogs { get; set; }
|
||||
@ -466,17 +480,15 @@ namespace Marco.Pms.DataAccess.Data
|
||||
modelBuilder.Entity<Feature>().HasData(
|
||||
new Feature { Id = new Guid("53176ebf-c75d-42e5-839f-4508ffac3def"), Description = "Manage Project", Name = "Manage Project", ModuleId = new Guid("bf59fd88-b57a-4d67-bf01-3780f385896b"), IsActive = true },
|
||||
new Feature { Id = new Guid("9666de86-d7c7-4d3d-acaa-fcd6d6b81f3c"), Description = "Manage Infra", Name = "Manage Infra", ModuleId = new Guid("bf59fd88-b57a-4d67-bf01-3780f385896b"), IsActive = true },
|
||||
|
||||
new Feature { Id = new Guid("9d4b5489-2079-40b9-bd77-6e1bf90bc19f"), Description = "Manage Tasks", Name = "Task Management", ModuleId = new Guid("bf59fd88-b57a-4d67-bf01-3780f385896b"), IsActive = true },
|
||||
|
||||
//new Feature { Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), Description = "Assign and Update Tasks Progress", Name = "Assign and Update Tasks Progress", ModuleId = new Guid("bf59fd88-b57a-4d67-bf01-3780f385896b"), IsActive = true },
|
||||
|
||||
|
||||
new Feature { Id = new Guid("81ab8a87-8ccd-4015-a917-0627cee6a100"), Description = "Manage Employee", Name = "Employee Management", ModuleId = new Guid("2a231490-bcb1-4bdd-91f1-f25fb7f25b23"), IsActive = true },
|
||||
new Feature { Id = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), Description = "Attendance", Name = "Attendance", ModuleId = new Guid("2a231490-bcb1-4bdd-91f1-f25fb7f25b23"), IsActive = true },
|
||||
|
||||
new Feature { Id = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), Description = "Global Masters", Name = "Global Masters", ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), IsActive = true }
|
||||
//new Feature { Id = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), Description = "Tenant Masters", Name = "Tenant Masters", ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), IsActive = true }
|
||||
new Feature { Id = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), Description = "Global Masters", Name = "Global Masters", ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), IsActive = true },
|
||||
new Feature { Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), Description = "Managing all directory related rights", Name = "Directory Management", ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), IsActive = true }
|
||||
|
||||
//new Feature { Id = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), Description = "Tenant Masters", Name = "Tenant Masters", ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), IsActive = true }
|
||||
);
|
||||
|
||||
modelBuilder.Entity<FeaturePermission>().HasData(
|
||||
@ -504,8 +516,11 @@ namespace Marco.Pms.DataAccess.Data
|
||||
new FeaturePermission { Id = new Guid("ccb0589f-712b-43de-92ed-5b6088e7dc4e"), FeatureId = new Guid("52c9cf54-1eb2-44d2-81bb-524cf29c0a94"), IsEnabled = true, Name = "Self Attendance", Description = "Team Attendance refers to tracking and managing the attendance of all team members collectively, often monitored by a team lead or manager." },
|
||||
|
||||
new FeaturePermission { Id = new Guid("5ffbafe0-7ab0-48b1-bb50-c1bf76b65f9d"), FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), IsEnabled = true, Name = "View Masters", Description = "Grants a user read-only access to foundational or reference data within the system. \"Masters\" typically refer to predefined lists, categories, or templates that are used throughout the application to standardize information and maintain consistency" },
|
||||
new FeaturePermission { Id = new Guid("588a8824-f924-4955-82d8-fc51956cf323"), FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), IsEnabled = true, Name = "Manage Masters", Description = "Grants a user the authority to create, modify, and delete foundational or reference data within the system. These \"masters\" are typically the core lists, categories, and configurations that other data and functionalities rely upon, such as departments, job titles, product categories" }
|
||||
//new FeaturePermission { Id = new Guid("cb8ec407-46d4-4467-930c-69127cda6dec"), FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), IsEnabled = true, Name = "View Masters", Description = "" },
|
||||
new FeaturePermission { Id = new Guid("588a8824-f924-4955-82d8-fc51956cf323"), FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"), IsEnabled = true, Name = "Manage Masters", Description = "Grants a user the authority to create, modify, and delete foundational or reference data within the system. These \"masters\" are typically the core lists, categories, and configurations that other data and functionalities rely upon, such as departments, job titles, product categories" },
|
||||
|
||||
new FeaturePermission { Id = new Guid("4286a13b-bb40-4879-8c6d-18e9e393beda"), FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), IsEnabled = true, Name = "Directory Admin", Description = "Full control over all directories, including the ability to manage permissions for all directories in the system." },
|
||||
new FeaturePermission { Id = new Guid("62668630-13ce-4f52-a0f0-db38af2230c5"), FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), IsEnabled = true, Name = "Directory Manager", Description = "Full control over directories they created or have been assigned. Can also manage permissions for those directories." },
|
||||
new FeaturePermission { Id = new Guid("0f919170-92d4-4337-abd3-49b66fc871bb"), FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), IsEnabled = true, Name = "Directory User", Description = "Full control over directories they created. Can view contacts in directories they either created or were assigned to. Can manage permissions only for directories they created." }
|
||||
//new FeaturePermission { Id = new Guid("6b1a6d97-a951-4de5-9b19-709bac7c4f18"), FeatureId = new Guid("660131a4-788c-4739-a082-cbbf7879cbf2"), IsEnabled = true, Name = "Manage Masters", Description = "" }
|
||||
|
||||
);
|
||||
|
2987
Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs
generated
Normal file
2987
Marco.Pms.DataAccess/Migrations/20250514103249_Added_Directory_Related_Tables.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,438 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Marco.Pms.DataAccess.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Added_Directory_Related_Tables : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Buckets",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Buckets", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Buckets_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactCategoryMasters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactCategoryMasters", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactCategoryMasters_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactTagMasters",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactTagMasters", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactTagMasters_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "DirectoryUpdateLogs",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
RefereanceId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
UpdateAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
UpdatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_DirectoryUpdateLogs", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_DirectoryUpdateLogs_Employees_UpdatedById",
|
||||
column: x => x.UpdatedById,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "EmployeeBucketMappings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
BucketId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
EmployeeId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_EmployeeBucketMappings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_EmployeeBucketMappings_Buckets_BucketId",
|
||||
column: x => x.BucketId,
|
||||
principalTable: "Buckets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_EmployeeBucketMappings_Employees_EmployeeId",
|
||||
column: x => x.EmployeeId,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "Contacts",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ProjectId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
Name = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Description = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Organization = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
Address = table.Column<string>(type: "longtext", nullable: true)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ContactCategoryId = table.Column<Guid>(type: "char(36)", nullable: true, collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_Contacts", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_Contacts_ContactCategoryMasters_ContactCategoryId",
|
||||
column: x => x.ContactCategoryId,
|
||||
principalTable: "ContactCategoryMasters",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_Contacts_Employees_CreatedById",
|
||||
column: x => x.CreatedById,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_Contacts_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactBucketMappings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
BucketId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactBucketMappings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactBucketMappings_Buckets_BucketId",
|
||||
column: x => x.BucketId,
|
||||
principalTable: "Buckets",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactBucketMappings_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactNotes",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Note = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
CreatedById = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
CreatedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
IsActive = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactNotes", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactNotes_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactNotes_Employees_CreatedById",
|
||||
column: x => x.CreatedById,
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactNotes_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactsEmails",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Label = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
EmailAddress = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
IsPrimary = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactsEmails", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactsEmails_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactsPhones",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
Label = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
PhoneNumber = table.Column<string>(type: "longtext", nullable: false)
|
||||
.Annotation("MySql:CharSet", "utf8mb4"),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
IsPrimary = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactsPhones", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactsPhones_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactTagMappings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ContactTagId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactTagMappings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
|
||||
column: x => x.ContactTagId,
|
||||
principalTable: "ContactTagMasters",
|
||||
principalColumn: "Id");
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactTagMappings_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Buckets_TenantId",
|
||||
table: "Buckets",
|
||||
column: "TenantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactBucketMappings_BucketId",
|
||||
table: "ContactBucketMappings",
|
||||
column: "BucketId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactBucketMappings_ContactId",
|
||||
table: "ContactBucketMappings",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactCategoryMasters_TenantId",
|
||||
table: "ContactCategoryMasters",
|
||||
column: "TenantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactNotes_ContactId",
|
||||
table: "ContactNotes",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactNotes_CreatedById",
|
||||
table: "ContactNotes",
|
||||
column: "CreatedById");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactNotes_TenantId",
|
||||
table: "ContactNotes",
|
||||
column: "TenantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Contacts_ContactCategoryId",
|
||||
table: "Contacts",
|
||||
column: "ContactCategoryId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Contacts_CreatedById",
|
||||
table: "Contacts",
|
||||
column: "CreatedById");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Contacts_TenantId",
|
||||
table: "Contacts",
|
||||
column: "TenantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactsEmails_ContactId",
|
||||
table: "ContactsEmails",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactsPhones_ContactId",
|
||||
table: "ContactsPhones",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactTagMappings_ContactId",
|
||||
table: "ContactTagMappings",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactTagMappings_ContactTagId",
|
||||
table: "ContactTagMappings",
|
||||
column: "ContactTagId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactTagMasters_TenantId",
|
||||
table: "ContactTagMasters",
|
||||
column: "TenantId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DirectoryUpdateLogs_UpdatedById",
|
||||
table: "DirectoryUpdateLogs",
|
||||
column: "UpdatedById");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmployeeBucketMappings_BucketId",
|
||||
table: "EmployeeBucketMappings",
|
||||
column: "BucketId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_EmployeeBucketMappings_EmployeeId",
|
||||
table: "EmployeeBucketMappings",
|
||||
column: "EmployeeId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactBucketMappings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactNotes");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactsEmails");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactsPhones");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactTagMappings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DirectoryUpdateLogs");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "EmployeeBucketMappings");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactTagMasters");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Contacts");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "Buckets");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactCategoryMasters");
|
||||
}
|
||||
}
|
||||
}
|
3038
Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs
generated
Normal file
3038
Marco.Pms.DataAccess/Migrations/20250517063809_Added_ContactProjectMapping_Table.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Marco.Pms.DataAccess.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Added_ContactProjectMapping_Table : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "ProjectId",
|
||||
table: "Contacts");
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "ContactProjectMappings",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ProjectId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
ContactId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci"),
|
||||
TenantId = table.Column<Guid>(type: "char(36)", nullable: false, collation: "ascii_general_ci")
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_ContactProjectMappings", x => x.Id);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactProjectMappings_Contacts_ContactId",
|
||||
column: x => x.ContactId,
|
||||
principalTable: "Contacts",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactProjectMappings_Projects_ProjectId",
|
||||
column: x => x.ProjectId,
|
||||
principalTable: "Projects",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
table.ForeignKey(
|
||||
name: "FK_ContactProjectMappings_Tenants_TenantId",
|
||||
column: x => x.TenantId,
|
||||
principalTable: "Tenants",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
})
|
||||
.Annotation("MySql:CharSet", "utf8mb4");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactProjectMappings_ContactId",
|
||||
table: "ContactProjectMappings",
|
||||
column: "ContactId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactProjectMappings_ProjectId",
|
||||
table: "ContactProjectMappings",
|
||||
column: "ProjectId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_ContactProjectMappings_TenantId",
|
||||
table: "ContactProjectMappings",
|
||||
column: "TenantId");
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "ContactProjectMappings");
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "ProjectId",
|
||||
table: "Contacts",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci");
|
||||
}
|
||||
}
|
||||
}
|
3007
Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs
generated
Normal file
3007
Marco.Pms.DataAccess/Migrations/20250519053019_Fixed_Typo_Of_ColumnName.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,64 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Marco.Pms.DataAccess.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Fixed_Typo_Of_ColumnName : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
|
||||
table: "ContactTagMappings");
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "ContactTagId",
|
||||
table: "ContactTagMappings",
|
||||
type: "char(36)",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
||||
collation: "ascii_general_ci",
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "char(36)",
|
||||
oldNullable: true)
|
||||
.OldAnnotation("Relational:Collation", "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
|
||||
table: "ContactTagMappings",
|
||||
column: "ContactTagId",
|
||||
principalTable: "ContactTagMasters",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
|
||||
table: "ContactTagMappings");
|
||||
|
||||
migrationBuilder.AlterColumn<Guid>(
|
||||
name: "ContactTagId",
|
||||
table: "ContactTagMappings",
|
||||
type: "char(36)",
|
||||
nullable: true,
|
||||
collation: "ascii_general_ci",
|
||||
oldClrType: typeof(Guid),
|
||||
oldType: "char(36)")
|
||||
.OldAnnotation("Relational:Collation", "ascii_general_ci");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_ContactTagMappings_ContactTagMasters_ContactTagId",
|
||||
table: "ContactTagMappings",
|
||||
column: "ContactTagId",
|
||||
principalTable: "ContactTagMasters",
|
||||
principalColumn: "Id");
|
||||
}
|
||||
}
|
||||
}
|
3055
Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs
generated
Normal file
3055
Marco.Pms.DataAccess/Migrations/20250524074333_Added_Feature_Directory_Management.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,100 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
|
||||
|
||||
namespace Marco.Pms.DataAccess.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class Added_Feature_Directory_Management : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<DateTime>(
|
||||
name: "CreatedAt",
|
||||
table: "Buckets",
|
||||
type: "datetime(6)",
|
||||
nullable: false,
|
||||
defaultValue: new DateTime(1, 1, 1, 0, 0, 0, 0, DateTimeKind.Unspecified));
|
||||
|
||||
migrationBuilder.AddColumn<Guid>(
|
||||
name: "CreatedByID",
|
||||
table: "Buckets",
|
||||
type: "char(36)",
|
||||
nullable: false,
|
||||
defaultValue: new Guid("00000000-0000-0000-0000-000000000000"),
|
||||
collation: "ascii_general_ci");
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "Features",
|
||||
columns: new[] { "Id", "Description", "IsActive", "ModuleId", "Name" },
|
||||
values: new object[] { new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), "Managing all directory related rights", true, new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"), "Directory Management" });
|
||||
|
||||
migrationBuilder.InsertData(
|
||||
table: "FeaturePermissions",
|
||||
columns: new[] { "Id", "Description", "FeatureId", "IsEnabled", "Name" },
|
||||
values: new object[,]
|
||||
{
|
||||
{ new Guid("0f919170-92d4-4337-abd3-49b66fc871bb"), "Full control over directories they created. Can view contacts in directories they either created or were assigned to. Can manage permissions only for directories they created.", new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), true, "Directory User" },
|
||||
{ new Guid("4286a13b-bb40-4879-8c6d-18e9e393beda"), "Full control over all directories, including the ability to manage permissions for all directories in the system.", new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), true, "Directory Admin" },
|
||||
{ new Guid("62668630-13ce-4f52-a0f0-db38af2230c5"), "Full control over directories they created or have been assigned. Can also manage permissions for those directories.", new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"), true, "Directory Manager" }
|
||||
});
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_Buckets_CreatedByID",
|
||||
table: "Buckets",
|
||||
column: "CreatedByID");
|
||||
|
||||
migrationBuilder.AddForeignKey(
|
||||
name: "FK_Buckets_Employees_CreatedByID",
|
||||
table: "Buckets",
|
||||
column: "CreatedByID",
|
||||
principalTable: "Employees",
|
||||
principalColumn: "Id",
|
||||
onDelete: ReferentialAction.Cascade);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropForeignKey(
|
||||
name: "FK_Buckets_Employees_CreatedByID",
|
||||
table: "Buckets");
|
||||
|
||||
migrationBuilder.DropIndex(
|
||||
name: "IX_Buckets_CreatedByID",
|
||||
table: "Buckets");
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "FeaturePermissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("0f919170-92d4-4337-abd3-49b66fc871bb"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "FeaturePermissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("4286a13b-bb40-4879-8c6d-18e9e393beda"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "FeaturePermissions",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("62668630-13ce-4f52-a0f0-db38af2230c5"));
|
||||
|
||||
migrationBuilder.DeleteData(
|
||||
table: "Features",
|
||||
keyColumn: "Id",
|
||||
keyValue: new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"));
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedAt",
|
||||
table: "Buckets");
|
||||
|
||||
migrationBuilder.DropColumn(
|
||||
name: "CreatedByID",
|
||||
table: "Buckets");
|
||||
}
|
||||
}
|
||||
}
|
@ -325,6 +325,340 @@ namespace Marco.Pms.DataAccess.Migrations
|
||||
b.ToTable("RefreshTokens");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.Bucket", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("CreatedByID")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("CreatedByID");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("Buckets");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.Contact", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Address")
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid?>("ContactCategoryId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("CreatedById")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Organization")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactCategoryId");
|
||||
|
||||
b.HasIndex("CreatedById");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("Contacts");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactBucketMapping", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("BucketId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BucketId");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.ToTable("ContactBucketMappings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactCategoryMaster", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("ContactCategoryMasters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactEmail", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("EmailAddress")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<bool>("IsPrimary")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.ToTable("ContactsEmails");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactNote", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("CreatedAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("CreatedById")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsActive")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Note")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.HasIndex("CreatedById");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("ContactNotes");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactPhone", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<bool>("IsPrimary")
|
||||
.HasColumnType("tinyint(1)");
|
||||
|
||||
b.Property<string>("Label")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("PhoneNumber")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.ToTable("ContactsPhones");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactProjectMapping", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ProjectId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.HasIndex("ProjectId");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("ContactProjectMappings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactTagMapping", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("ContactTagId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("ContactId");
|
||||
|
||||
b.HasIndex("ContactTagId");
|
||||
|
||||
b.ToTable("ContactTagMappings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactTagMaster", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<string>("Description")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<string>("Name")
|
||||
.IsRequired()
|
||||
.HasColumnType("longtext");
|
||||
|
||||
b.Property<Guid>("TenantId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("TenantId");
|
||||
|
||||
b.ToTable("ContactTagMasters");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.DirectoryUpdateLog", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("RefereanceId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<DateTime>("UpdateAt")
|
||||
.HasColumnType("datetime(6)");
|
||||
|
||||
b.Property<Guid>("UpdatedById")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("UpdatedById");
|
||||
|
||||
b.ToTable("DirectoryUpdateLogs");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.EmployeeBucketMapping", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
.ValueGeneratedOnAdd()
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("BucketId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.Property<Guid>("EmployeeId")
|
||||
.HasColumnType("char(36)");
|
||||
|
||||
b.HasKey("Id");
|
||||
|
||||
b.HasIndex("BucketId");
|
||||
|
||||
b.HasIndex("EmployeeId");
|
||||
|
||||
b.ToTable("EmployeeBucketMappings");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.DocumentManager.Document", b =>
|
||||
{
|
||||
b.Property<Guid>("Id")
|
||||
@ -705,6 +1039,30 @@ namespace Marco.Pms.DataAccess.Migrations
|
||||
FeatureId = new Guid("be3b3afc-6ccf-4566-b9b6-aafcb65546be"),
|
||||
IsEnabled = true,
|
||||
Name = "Manage Masters"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("4286a13b-bb40-4879-8c6d-18e9e393beda"),
|
||||
Description = "Full control over all directories, including the ability to manage permissions for all directories in the system.",
|
||||
FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"),
|
||||
IsEnabled = true,
|
||||
Name = "Directory Admin"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("62668630-13ce-4f52-a0f0-db38af2230c5"),
|
||||
Description = "Full control over directories they created or have been assigned. Can also manage permissions for those directories.",
|
||||
FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"),
|
||||
IsEnabled = true,
|
||||
Name = "Directory Manager"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("0f919170-92d4-4337-abd3-49b66fc871bb"),
|
||||
Description = "Full control over directories they created. Can view contacts in directories they either created or were assigned to. Can manage permissions only for directories they created.",
|
||||
FeatureId = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"),
|
||||
IsEnabled = true,
|
||||
Name = "Directory User"
|
||||
});
|
||||
});
|
||||
|
||||
@ -1140,6 +1498,14 @@ namespace Marco.Pms.DataAccess.Migrations
|
||||
IsActive = true,
|
||||
ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"),
|
||||
Name = "Global Masters"
|
||||
},
|
||||
new
|
||||
{
|
||||
Id = new Guid("39e66f81-efc6-446c-95bd-46bff6cfb606"),
|
||||
Description = "Managing all directory related rights",
|
||||
IsActive = true,
|
||||
ModuleId = new Guid("c43db8c7-ab73-47f4-9d3b-f83e81357924"),
|
||||
Name = "Directory Management"
|
||||
});
|
||||
});
|
||||
|
||||
@ -2212,6 +2578,216 @@ namespace Marco.Pms.DataAccess.Migrations
|
||||
b.Navigation("User");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.Bucket", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedByID")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("CreatedBy");
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.Contact", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.ContactCategoryMaster", "ContactCategory")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactCategoryId");
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "CreatedBy")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedById")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("ContactCategory");
|
||||
|
||||
b.Navigation("CreatedBy");
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactBucketMapping", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Bucket", "Bucket")
|
||||
.WithMany()
|
||||
.HasForeignKey("BucketId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bucket");
|
||||
|
||||
b.Navigation("Contact");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactCategoryMaster", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactEmail", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Contact");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactNote", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "Createdby")
|
||||
.WithMany()
|
||||
.HasForeignKey("CreatedById")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Contact");
|
||||
|
||||
b.Navigation("Createdby");
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactPhone", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Contact");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactProjectMapping", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Projects.Project", "Project")
|
||||
.WithMany()
|
||||
.HasForeignKey("ProjectId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Contact");
|
||||
|
||||
b.Navigation("Project");
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactTagMapping", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Contact", "Contact")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Directory.ContactTagMaster", "ContactTag")
|
||||
.WithMany()
|
||||
.HasForeignKey("ContactTagId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Contact");
|
||||
|
||||
b.Navigation("ContactTag");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.ContactTagMaster", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
.WithMany()
|
||||
.HasForeignKey("TenantId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Tenant");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.DirectoryUpdateLog", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("UpdatedById")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.Directory.EmployeeBucketMapping", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Directory.Bucket", "Bucket")
|
||||
.WithMany()
|
||||
.HasForeignKey("BucketId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.HasOne("Marco.Pms.Model.Employees.Employee", "Employee")
|
||||
.WithMany()
|
||||
.HasForeignKey("EmployeeId")
|
||||
.OnDelete(DeleteBehavior.Cascade)
|
||||
.IsRequired();
|
||||
|
||||
b.Navigation("Bucket");
|
||||
|
||||
b.Navigation("Employee");
|
||||
});
|
||||
|
||||
modelBuilder.Entity("Marco.Pms.Model.DocumentManager.Document", b =>
|
||||
{
|
||||
b.HasOne("Marco.Pms.Model.Entitlements.Tenant", "Tenant")
|
||||
|
15
Marco.Pms.Model/Directory/Bucket.cs
Normal file
15
Marco.Pms.Model/Directory/Bucket.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class Bucket : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public Guid CreatedByID { get; set; }
|
||||
public Employee? CreatedBy { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
31
Marco.Pms.Model/Directory/Contact.cs
Normal file
31
Marco.Pms.Model/Directory/Contact.cs
Normal file
@ -0,0 +1,31 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class Contact : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
//public Guid? ProjectId { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
public string Organization { get; set; } = string.Empty;
|
||||
public string? Address { get; set; }
|
||||
public bool IsActive { get; set; } = true;
|
||||
public Guid CreatedById { get; set; }
|
||||
|
||||
[ValidateNever]
|
||||
[ForeignKey("CreatedById")]
|
||||
public Employee? CreatedBy { get; set; }
|
||||
|
||||
[DisplayName("ContactCategoryId")]
|
||||
public Guid? ContactCategoryId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey(nameof(ContactCategoryId))]
|
||||
public ContactCategoryMaster? ContactCategory { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
}
|
||||
}
|
18
Marco.Pms.Model/Directory/ContactBucketMapping.cs
Normal file
18
Marco.Pms.Model/Directory/ContactBucketMapping.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactBucketMapping
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid BucketId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("BucketId")]
|
||||
public Bucket? Bucket { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("ContactId")]
|
||||
public Contact? Contact { get; set; }
|
||||
}
|
||||
}
|
11
Marco.Pms.Model/Directory/ContactCategoryMaster.cs
Normal file
11
Marco.Pms.Model/Directory/ContactCategoryMaster.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Marco.Pms.Model.Utilities;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactCategoryMaster : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
21
Marco.Pms.Model/Directory/ContactEmail.cs
Normal file
21
Marco.Pms.Model/Directory/ContactEmail.cs
Normal file
@ -0,0 +1,21 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactEmail
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Label { get; set; } = string.Empty;
|
||||
public string EmailAddress { get; set; } = string.Empty;
|
||||
[DisplayName("ContactId")]
|
||||
public Guid ContactId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey(nameof(ContactId))]
|
||||
public Contact? Contact { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
public Guid TenantId { get; set; }
|
||||
|
||||
}
|
||||
}
|
25
Marco.Pms.Model/Directory/ContactNote.cs
Normal file
25
Marco.Pms.Model/Directory/ContactNote.cs
Normal file
@ -0,0 +1,25 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactNote : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Note { get; set; } = string.Empty;
|
||||
public Guid CreatedById { get; set; }
|
||||
|
||||
[ValidateNever]
|
||||
[ForeignKey("CreatedById")]
|
||||
public Employee? Createdby { get; set; }
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public Guid ContactId { get; set; }
|
||||
|
||||
[ValidateNever]
|
||||
[ForeignKey("ContactId")]
|
||||
public Contact? Contact { get; set; }
|
||||
public bool IsActive { get; set; } = true;
|
||||
}
|
||||
}
|
22
Marco.Pms.Model/Directory/ContactPhone.cs
Normal file
22
Marco.Pms.Model/Directory/ContactPhone.cs
Normal file
@ -0,0 +1,22 @@
|
||||
using System.ComponentModel;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactPhone
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Label { get; set; } = string.Empty;
|
||||
public string PhoneNumber { get; set; } = string.Empty;
|
||||
[DisplayName("ContactId")]
|
||||
public Guid ContactId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey(nameof(ContactId))]
|
||||
public Contact? Contact { get; set; }
|
||||
public bool IsPrimary { get; set; }
|
||||
|
||||
public Guid TenantId { get; set; }
|
||||
|
||||
}
|
||||
}
|
20
Marco.Pms.Model/Directory/ContactProjectMapping.cs
Normal file
20
Marco.Pms.Model/Directory/ContactProjectMapping.cs
Normal file
@ -0,0 +1,20 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Projects;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactProjectMapping : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ProjectId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("ProjectId")]
|
||||
public Project? Project { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("ContactId")]
|
||||
public Contact? Contact { get; set; }
|
||||
}
|
||||
}
|
11
Marco.Pms.Model/Directory/ContactTagMapping.cs
Normal file
11
Marco.Pms.Model/Directory/ContactTagMapping.cs
Normal file
@ -0,0 +1,11 @@
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactTagMapping
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
public Contact? Contact { get; set; }
|
||||
public Guid ContactTagId { get; set; }
|
||||
public ContactTagMaster? ContactTag { get; set; }
|
||||
}
|
||||
}
|
11
Marco.Pms.Model/Directory/ContactTagMaster.cs
Normal file
11
Marco.Pms.Model/Directory/ContactTagMaster.cs
Normal file
@ -0,0 +1,11 @@
|
||||
using Marco.Pms.Model.Utilities;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class ContactTagMaster : TenantRelation
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
18
Marco.Pms.Model/Directory/DirectoryUpdateLog.cs
Normal file
18
Marco.Pms.Model/Directory/DirectoryUpdateLog.cs
Normal file
@ -0,0 +1,18 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class DirectoryUpdateLog
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid RefereanceId { get; set; }
|
||||
public DateTime UpdateAt { get; set; } = DateTime.UtcNow;
|
||||
public Guid UpdatedById { get; set; }
|
||||
|
||||
[ValidateNever]
|
||||
[ForeignKey("UpdatedById")]
|
||||
public Employee? Employee { get; set; }
|
||||
}
|
||||
}
|
19
Marco.Pms.Model/Directory/EmployeeBucketMapping.cs
Normal file
19
Marco.Pms.Model/Directory/EmployeeBucketMapping.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Microsoft.AspNetCore.Mvc.ModelBinding.Validation;
|
||||
|
||||
namespace Marco.Pms.Model.Directory
|
||||
{
|
||||
public class EmployeeBucketMapping
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public Guid BucketId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("BucketId")]
|
||||
public Bucket? Bucket { get; set; }
|
||||
public Guid EmployeeId { get; set; }
|
||||
[ValidateNever]
|
||||
[ForeignKey("EmployeeId")]
|
||||
public Employee? Employee { get; set; }
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Directory/AssignBucketDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Directory/AssignBucketDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class AssignBucketDto
|
||||
{
|
||||
public Guid EmployeeId { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Directory/ContactFilterDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Directory/ContactFilterDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class ContactFilterDto
|
||||
{
|
||||
public List<Guid>? BucketIds { get; set; }
|
||||
public List<Guid>? CategoryIds { get; set; }
|
||||
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Directory/ContactTagDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Directory/ContactTagDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class ContactTagDto
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string Name { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Directory/CreateBucketDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Directory/CreateBucketDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class CreateBucketDto
|
||||
{
|
||||
public string Name { get; set; } = string.Empty;
|
||||
public string Description { get; set; } = string.Empty;
|
||||
}
|
||||
}
|
16
Marco.Pms.Model/Dtos/Directory/CreateContactDto.cs
Normal file
16
Marco.Pms.Model/Dtos/Directory/CreateContactDto.cs
Normal file
@ -0,0 +1,16 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class CreateContactDto
|
||||
{
|
||||
public List<Guid>? ProjectIds { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public List<CreateContactPhoneDto>? ContactPhones { get; set; }
|
||||
public List<CreateContactEmailDto>? ContactEmails { get; set; }
|
||||
public List<Guid>? BucketIds { get; set; }
|
||||
public Guid? ContactCategoryId { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public List<ContactTagDto>? Tags { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Directory/CreateContactEmailDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Directory/CreateContactEmailDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class CreateContactEmailDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
}
|
||||
}
|
||||
|
8
Marco.Pms.Model/Dtos/Directory/CreateContactNoteDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Directory/CreateContactNoteDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class CreateContactNoteDto
|
||||
{
|
||||
public string Note { get; set; } = string.Empty;
|
||||
public Guid ContactId { get; set; }
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Directory/CreateContactPhoneDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Directory/CreateContactPhoneDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class CreateContactPhoneDto
|
||||
{
|
||||
public string? Label { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Directory/UpdateBucketDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Directory/UpdateBucketDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class UpdateBucketDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
17
Marco.Pms.Model/Dtos/Directory/UpdateContactDto.cs
Normal file
17
Marco.Pms.Model/Dtos/Directory/UpdateContactDto.cs
Normal file
@ -0,0 +1,17 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class UpdateContactDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public List<Guid>? ProjectIds { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public List<UpdateContactPhoneDto>? ContactPhones { get; set; }
|
||||
public List<UpdateContactEmailDto>? ContactEmails { get; set; }
|
||||
public List<Guid>? BucketIds { get; set; }
|
||||
public Guid ContactCategoryId { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public List<ContactTagDto>? Tags { get; set; }
|
||||
}
|
||||
}
|
10
Marco.Pms.Model/Dtos/Directory/UpdateContactEmailDto.cs
Normal file
10
Marco.Pms.Model/Dtos/Directory/UpdateContactEmailDto.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class UpdateContactEmailDto
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public Guid? ContactId { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Directory/UpdateContactNoteDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Directory/UpdateContactNoteDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class UpdateContactNoteDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Note { get; set; } = string.Empty;
|
||||
public Guid ContactId { get; set; }
|
||||
}
|
||||
}
|
10
Marco.Pms.Model/Dtos/Directory/UpdateContactPhoneDto.cs
Normal file
10
Marco.Pms.Model/Dtos/Directory/UpdateContactPhoneDto.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Marco.Pms.Model.Dtos.Directory
|
||||
{
|
||||
public class UpdateContactPhoneDto
|
||||
{
|
||||
public Guid? Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public Guid? ContactId { get; set; }
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Master/CreateContactCategoryDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Master/CreateContactCategoryDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Master
|
||||
{
|
||||
public class CreateContactCategoryDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/Dtos/Master/CreateContactTagDto.cs
Normal file
8
Marco.Pms.Model/Dtos/Master/CreateContactTagDto.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.Dtos.Master
|
||||
{
|
||||
public class CreateContactTagDto
|
||||
{
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Master/UpdateContactCategoryDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Master/UpdateContactCategoryDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Master
|
||||
{
|
||||
public class UpdateContactCategoryDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/Dtos/Master/UpdateContactTagDto.cs
Normal file
9
Marco.Pms.Model/Dtos/Master/UpdateContactTagDto.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.Dtos.Master
|
||||
{
|
||||
public class UpdateContactTagDto
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
@ -8,4 +8,13 @@
|
||||
|
||||
public bool Status { get; set; }
|
||||
}
|
||||
|
||||
|
||||
public class ProjectsAllocationDto
|
||||
{
|
||||
public Guid ProjectId { get; set; }
|
||||
public Guid JobRoleId { get; set; }
|
||||
|
||||
public bool Status { get; set; }
|
||||
}
|
||||
}
|
||||
|
242
Marco.Pms.Model/Mapper/DirectoryMapper.cs
Normal file
242
Marco.Pms.Model/Mapper/DirectoryMapper.cs
Normal file
@ -0,0 +1,242 @@
|
||||
using Marco.Pms.Model.Directory;
|
||||
using Marco.Pms.Model.Dtos.Directory;
|
||||
using Marco.Pms.Model.Dtos.Master;
|
||||
using Marco.Pms.Model.ViewModels.Directory;
|
||||
using Marco.Pms.Model.ViewModels.Master;
|
||||
|
||||
namespace Marco.Pms.Model.Mapper
|
||||
{
|
||||
public static class DirectoryMapper
|
||||
{
|
||||
public static Contact ToContactFromCreateContactDto(this CreateContactDto createContactDto, Guid tenantId, Guid employeeId)
|
||||
{
|
||||
|
||||
return new Contact
|
||||
{
|
||||
Name = createContactDto.Name ?? string.Empty,
|
||||
ContactCategoryId = createContactDto.ContactCategoryId,
|
||||
Description = createContactDto.Description ?? string.Empty,
|
||||
Organization = createContactDto?.Organization ?? string.Empty,
|
||||
Address = createContactDto != null ? createContactDto.Address : string.Empty,
|
||||
CreatedById = employeeId,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static Contact ToContactFromUpdateContactDto(this UpdateContactDto updateContactDto, Guid tenantId, Contact contact)
|
||||
{
|
||||
|
||||
return new Contact
|
||||
{
|
||||
Id = updateContactDto.Id,
|
||||
Name = updateContactDto.Name ?? string.Empty,
|
||||
ContactCategoryId = updateContactDto.ContactCategoryId,
|
||||
CreatedAt = contact.CreatedAt,
|
||||
CreatedById = contact.CreatedById,
|
||||
Description = updateContactDto.Description ?? string.Empty,
|
||||
Organization = updateContactDto?.Organization ?? string.Empty,
|
||||
Address = updateContactDto != null ? updateContactDto.Address : string.Empty,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactVM ToContactVMFromContact(this Contact contact)
|
||||
{
|
||||
return new ContactVM
|
||||
{
|
||||
Id = contact.Id,
|
||||
Name = contact.Name,
|
||||
ContactCategory = contact.ContactCategory != null ? contact.ContactCategory.ToContactCategoryVMFromContactCategoryMaster() : null,
|
||||
Description = contact.Description ?? string.Empty,
|
||||
Organization = contact.Organization ?? string.Empty,
|
||||
Address = contact.Address ?? string.Empty
|
||||
};
|
||||
}
|
||||
public static ContactProfileVM ToContactProfileVMFromContact(this Contact contact)
|
||||
{
|
||||
return new ContactProfileVM
|
||||
{
|
||||
Id = contact.Id,
|
||||
Name = contact.Name,
|
||||
ContactCategory = contact.ContactCategory != null ? contact.ContactCategory.ToContactCategoryVMFromContactCategoryMaster() : null,
|
||||
Description = contact.Description ?? string.Empty,
|
||||
Organization = contact.Organization ?? string.Empty,
|
||||
Address = contact.Address ?? string.Empty,
|
||||
CreatedAt = contact.CreatedAt,
|
||||
CreatedBy = contact.CreatedBy != null ? contact.CreatedBy.ToBasicEmployeeVMFromEmployee() : null
|
||||
};
|
||||
}
|
||||
|
||||
//Contact Phone Mapper
|
||||
public static ContactPhone ToContactPhoneFromCreateContactPhoneDto(this CreateContactPhoneDto createContactPhoneDto, Guid tenantId, Guid contactId)
|
||||
{
|
||||
return new ContactPhone
|
||||
{
|
||||
Label = createContactPhoneDto.Label ?? string.Empty,
|
||||
PhoneNumber = createContactPhoneDto.PhoneNumber ?? string.Empty,
|
||||
ContactId = contactId,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactPhone ToContactPhoneFromUpdateContactPhoneDto(this UpdateContactPhoneDto updateContactPhoneDto, Guid tenantId, Guid contactId)
|
||||
{
|
||||
return new ContactPhone
|
||||
{
|
||||
Id = updateContactPhoneDto.Id ?? Guid.Empty,
|
||||
Label = updateContactPhoneDto.Label ?? string.Empty,
|
||||
PhoneNumber = updateContactPhoneDto.PhoneNumber ?? string.Empty,
|
||||
ContactId = contactId,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactPhoneVM ToContactPhoneVMFromContactPhone(this ContactPhone phone)
|
||||
{
|
||||
return new ContactPhoneVM
|
||||
{
|
||||
Id = phone.Id,
|
||||
Label = phone.Label ?? string.Empty,
|
||||
PhoneNumber = phone.PhoneNumber ?? string.Empty,
|
||||
ContactId = phone.ContactId
|
||||
};
|
||||
}
|
||||
|
||||
//Contact Email Mapper
|
||||
public static ContactEmail ToContactEmailFromCreateContactEmailDto(this CreateContactEmailDto createContactEmailDto, Guid tenantId, Guid contactId)
|
||||
{
|
||||
return new ContactEmail
|
||||
{
|
||||
Label = createContactEmailDto.Label ?? string.Empty,
|
||||
EmailAddress = createContactEmailDto.EmailAddress ?? string.Empty,
|
||||
ContactId = contactId,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactEmail ToContactEmailFromUpdateContactEmailDto(this UpdateContactEmailDto updateContactEmailDto, Guid tenantId, Guid contactId)
|
||||
{
|
||||
return new ContactEmail
|
||||
{
|
||||
Id = updateContactEmailDto.Id ?? Guid.Empty,
|
||||
Label = updateContactEmailDto.Label ?? string.Empty,
|
||||
EmailAddress = updateContactEmailDto.EmailAddress ?? string.Empty,
|
||||
ContactId = contactId,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactEmailVM ToContactEmailVMFromContactEmail(this ContactEmail email)
|
||||
{
|
||||
return new ContactEmailVM
|
||||
{
|
||||
Id = email.Id,
|
||||
Label = email.Label ?? string.Empty,
|
||||
EmailAddress = email.EmailAddress ?? string.Empty,
|
||||
ContactId = email.ContactId
|
||||
};
|
||||
}
|
||||
|
||||
//Contact Tag Mapper
|
||||
public static ContactTagMaster ToContactTagMasterFromCreateContactTagDto(this CreateContactTagDto createContactTagDto, Guid tenantId)
|
||||
{
|
||||
return new ContactTagMaster
|
||||
{
|
||||
Name = createContactTagDto.Name ?? string.Empty,
|
||||
Description = createContactTagDto.Description ?? string.Empty,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactTagMaster ToContactTagMasterFromUpdateContactTagDto(this UpdateContactTagDto updateContactTagDto, Guid tenantId)
|
||||
{
|
||||
return new ContactTagMaster
|
||||
{
|
||||
Id = updateContactTagDto.Id,
|
||||
Name = updateContactTagDto.Name ?? string.Empty,
|
||||
Description = updateContactTagDto.Description ?? string.Empty,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactTagVM ToContactTagVMFromContactTagMaster(this ContactTagMaster contactTag)
|
||||
{
|
||||
return new ContactTagVM
|
||||
{
|
||||
Id = contactTag.Id,
|
||||
Description = contactTag.Description ?? string.Empty,
|
||||
Name = contactTag.Name ?? string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
//Contact Category Mapper
|
||||
public static ContactCategoryMaster ToContactCategoryMasterFromCreateContactCategoryDto(this CreateContactCategoryDto createContactTypeDto, Guid tenantId)
|
||||
{
|
||||
return new ContactCategoryMaster
|
||||
{
|
||||
Name = createContactTypeDto.Name ?? string.Empty,
|
||||
Description = createContactTypeDto.Description ?? string.Empty,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactCategoryMaster ToContactCategoryMasterFromUpdateContactCategoryDto(this UpdateContactCategoryDto updateContactTypeDto, Guid tenantId)
|
||||
{
|
||||
return new ContactCategoryMaster
|
||||
{
|
||||
Id = updateContactTypeDto.Id,
|
||||
Name = updateContactTypeDto.Name ?? string.Empty,
|
||||
Description = updateContactTypeDto.Description ?? string.Empty,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactCategoryVM ToContactCategoryVMFromContactCategoryMaster(this ContactCategoryMaster contactType)
|
||||
{
|
||||
return new ContactCategoryVM
|
||||
{
|
||||
Id = contactType.Id,
|
||||
Name = contactType.Name ?? string.Empty,
|
||||
Description = contactType.Description ?? string.Empty,
|
||||
};
|
||||
}
|
||||
|
||||
// Bucket
|
||||
public static BucketVM ToBucketVMFromBucket(this Bucket bucket)
|
||||
{
|
||||
return new BucketVM
|
||||
{
|
||||
Id = bucket.Id,
|
||||
Name = bucket.Name,
|
||||
Description = bucket.Description,
|
||||
CreatedBy = bucket.CreatedBy != null ? bucket.CreatedBy.ToBasicEmployeeVMFromEmployee() : null
|
||||
};
|
||||
}
|
||||
public static AssignBucketVM ToAssignBucketVMFromBucket(this Bucket bucket)
|
||||
{
|
||||
return new AssignBucketVM
|
||||
{
|
||||
Id = bucket.Id,
|
||||
Name = bucket.Name,
|
||||
Description = bucket.Description,
|
||||
CreatedBy = bucket.CreatedBy != null ? bucket.CreatedBy.ToBasicEmployeeVMFromEmployee() : null
|
||||
};
|
||||
}
|
||||
|
||||
//Contact Note
|
||||
public static ContactNote ToContactNoteFromCreateContactNoteDto(this CreateContactNoteDto noteDto, Guid tenantId, Guid employeeId)
|
||||
{
|
||||
return new ContactNote
|
||||
{
|
||||
Note = noteDto.Note,
|
||||
ContactId = noteDto.ContactId,
|
||||
CreatedAt = DateTime.UtcNow,
|
||||
CreatedById = employeeId,
|
||||
TenantId = tenantId
|
||||
};
|
||||
}
|
||||
public static ContactNoteVM ToContactNoteVMFromContactNote(this ContactNote note)
|
||||
{
|
||||
return new ContactNoteVM
|
||||
{
|
||||
Id = note.Id,
|
||||
Note = note.Note,
|
||||
ContactId = note.ContactId,
|
||||
CreatedAt = note.CreatedAt,
|
||||
CreatedBy = note.Createdby != null ? note.Createdby.ToBasicEmployeeVMFromEmployee() : null,
|
||||
IsActive = note.IsActive
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
@ -61,6 +61,19 @@ namespace Marco.Pms.Model.Mapper
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
public static ProjectAllocation ToProjectAllocationFromProjectsAllocationDto(this ProjectsAllocationDto model, Guid TenantId,Guid employeeId)
|
||||
{
|
||||
return new ProjectAllocation
|
||||
{
|
||||
AllocationDate = DateTime.Now,
|
||||
EmployeeId = employeeId,
|
||||
JobRoleId = model.JobRoleId,
|
||||
TenantId = TenantId,
|
||||
ProjectId = model.ProjectId
|
||||
};
|
||||
}
|
||||
|
||||
public static ProjectListVM ToProjectListVMFromProject(this Project project)
|
||||
{
|
||||
return new ProjectListVM
|
||||
|
14
Marco.Pms.Model/ViewModels/Directory/AssignBucketVM.cs
Normal file
14
Marco.Pms.Model/ViewModels/Directory/AssignBucketVM.cs
Normal file
@ -0,0 +1,14 @@
|
||||
using Marco.Pms.Model.ViewModels.Activities;
|
||||
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class AssignBucketVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||
public List<Guid>? EmployeeIds { get; set; }
|
||||
public int NumberOfContacts { get; set; }
|
||||
}
|
||||
}
|
12
Marco.Pms.Model/ViewModels/Directory/BucketVM.cs
Normal file
12
Marco.Pms.Model/ViewModels/Directory/BucketVM.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Marco.Pms.Model.ViewModels.Activities;
|
||||
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class BucketVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||
}
|
||||
}
|
10
Marco.Pms.Model/ViewModels/Directory/ContactEmailVM.cs
Normal file
10
Marco.Pms.Model/ViewModels/Directory/ContactEmailVM.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class ContactEmailVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public string? EmailAddress { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
}
|
||||
}
|
16
Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs
Normal file
16
Marco.Pms.Model/ViewModels/Directory/ContactNoteVM.cs
Normal file
@ -0,0 +1,16 @@
|
||||
using Marco.Pms.Model.ViewModels.Activities;
|
||||
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class ContactNoteVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string Note { get; set; } = string.Empty;
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
public BasicEmployeeVM? UpdatedBy { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
public bool IsActive { get; set; }
|
||||
}
|
||||
}
|
10
Marco.Pms.Model/ViewModels/Directory/ContactPhoneVM.cs
Normal file
10
Marco.Pms.Model/ViewModels/Directory/ContactPhoneVM.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class ContactPhoneVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Label { get; set; }
|
||||
public string? PhoneNumber { get; set; }
|
||||
public Guid ContactId { get; set; }
|
||||
}
|
||||
}
|
26
Marco.Pms.Model/ViewModels/Directory/ContactProfileVM.cs
Normal file
26
Marco.Pms.Model/ViewModels/Directory/ContactProfileVM.cs
Normal file
@ -0,0 +1,26 @@
|
||||
using Marco.Pms.Model.ViewModels.Activities;
|
||||
using Marco.Pms.Model.ViewModels.Master;
|
||||
using Marco.Pms.Model.ViewModels.Projects;
|
||||
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class ContactProfileVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public BasicEmployeeVM? CreatedBy { get; set; }
|
||||
public DateTime? UpdatedAt { get; set; }
|
||||
public BasicEmployeeVM? UpdatedBy { get; set; }
|
||||
public List<ContactPhoneVM> ContactPhones { get; set; } = new List<ContactPhoneVM>();
|
||||
public List<ContactEmailVM> ContactEmails { get; set; } = new List<ContactEmailVM>();
|
||||
public ContactCategoryVM? ContactCategory { get; set; }
|
||||
public List<BasicProjectVM> Projects { get; set; } = new List<BasicProjectVM>();
|
||||
public List<BucketVM> Buckets { get; set; } = new List<BucketVM>();
|
||||
public List<ContactTagVM> Tags { get; set; } = new List<ContactTagVM>();
|
||||
public List<ContactNoteVM> Notes { get; set; } = new List<ContactNoteVM>();
|
||||
}
|
||||
}
|
19
Marco.Pms.Model/ViewModels/Directory/ContactVM.cs
Normal file
19
Marco.Pms.Model/ViewModels/Directory/ContactVM.cs
Normal file
@ -0,0 +1,19 @@
|
||||
using Marco.Pms.Model.ViewModels.Master;
|
||||
|
||||
namespace Marco.Pms.Model.ViewModels.Directory
|
||||
{
|
||||
public class ContactVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public List<Guid>? ProjectIds { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public List<ContactPhoneVM>? ContactPhones { get; set; }
|
||||
public List<ContactEmailVM>? ContactEmails { get; set; }
|
||||
public ContactCategoryVM? ContactCategory { get; set; }
|
||||
public List<Guid>? BucketIds { get; set; }
|
||||
public string? Description { get; set; }
|
||||
public string? Organization { get; set; }
|
||||
public string? Address { get; set; }
|
||||
public List<ContactTagVM>? Tags { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/ViewModels/Master/ContactCategoryVM.cs
Normal file
9
Marco.Pms.Model/ViewModels/Master/ContactCategoryVM.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Master
|
||||
{
|
||||
public class ContactCategoryVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
9
Marco.Pms.Model/ViewModels/Master/ContactTagVM.cs
Normal file
9
Marco.Pms.Model/ViewModels/Master/ContactTagVM.cs
Normal file
@ -0,0 +1,9 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Master
|
||||
{
|
||||
public class ContactTagVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
public string? Description { get; set; }
|
||||
}
|
||||
}
|
8
Marco.Pms.Model/ViewModels/Projects/BasicProjectVM.cs
Normal file
8
Marco.Pms.Model/ViewModels/Projects/BasicProjectVM.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Marco.Pms.Model.ViewModels.Projects
|
||||
{
|
||||
public class BasicProjectVM
|
||||
{
|
||||
public Guid Id { get; set; }
|
||||
public string? Name { get; set; }
|
||||
}
|
||||
}
|
@ -150,12 +150,12 @@ namespace MarcoBMS.Services.Controllers
|
||||
|
||||
if (dateFrom != null && DateTime.TryParse(dateFrom, out fromDate) == false)
|
||||
{
|
||||
_logger.LogError("User sent Invalid from Date while featching attendance logs");
|
||||
_logger.LogError("User sent Invalid fromDate while featching attendance logs");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid Date", "Invalid Date", 400));
|
||||
}
|
||||
if (dateTo != null && DateTime.TryParse(dateTo, out toDate) == false)
|
||||
{
|
||||
_logger.LogError("User sent Invalid to Date while featching attendance logs");
|
||||
_logger.LogError("User sent Invalid toDate while featching attendance logs");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid Date", "Invalid Date", 400));
|
||||
}
|
||||
|
||||
|
341
Marco.Pms.Services/Controllers/DirectoryController.cs
Normal file
341
Marco.Pms.Services/Controllers/DirectoryController.cs
Normal file
@ -0,0 +1,341 @@
|
||||
using Marco.Pms.Model.Dtos.Directory;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Services.Helpers;
|
||||
using MarcoBMS.Services.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
|
||||
namespace Marco.Pms.Services.Controllers
|
||||
{
|
||||
[ApiController]
|
||||
[Route("api/[controller]")]
|
||||
[Authorize]
|
||||
|
||||
public class DirectoryController : ControllerBase
|
||||
{
|
||||
|
||||
private readonly DirectoryHelper _directoryHelper;
|
||||
private readonly ILoggingService _logger;
|
||||
|
||||
|
||||
public DirectoryController(DirectoryHelper directoryHelper, ILoggingService logger)
|
||||
{
|
||||
_directoryHelper = directoryHelper;
|
||||
_logger = logger;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
public async Task<IActionResult> GetContactList([FromQuery] string? search, [FromQuery] List<Guid>? bucketIds, [FromQuery] List<Guid>? categoryIds, [FromQuery] Guid? projectId, [FromQuery] bool active = true)
|
||||
{
|
||||
ContactFilterDto filterDto = new ContactFilterDto
|
||||
{
|
||||
BucketIds = bucketIds,
|
||||
CategoryIds = categoryIds
|
||||
};
|
||||
var response = await _directoryHelper.GetListOfContacts(search, active, filterDto, projectId);
|
||||
|
||||
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("contact-bucket/{bucketId}")]
|
||||
public async Task<IActionResult> GetContactsListByBucketId(Guid bucketId)
|
||||
{
|
||||
var response = await _directoryHelper.GetContactsListByBucketId(bucketId);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> CreateContact([FromBody] CreateContactDto createContact)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var errors = ModelState.Values
|
||||
.SelectMany(v => v.Errors)
|
||||
.Select(e => e.ErrorMessage)
|
||||
.ToList();
|
||||
_logger.LogError("User sent Invalid Date while marking attendance");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||
}
|
||||
var response = await _directoryHelper.CreateContact(createContact);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("{id}")]
|
||||
public async Task<IActionResult> UpdateContact(Guid id, [FromBody] UpdateContactDto updateContact)
|
||||
{
|
||||
var response = await _directoryHelper.UpdateContact(id, updateContact);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("profile/{id}")]
|
||||
public async Task<IActionResult> GetContactProfile(Guid id)
|
||||
{
|
||||
var response = await _directoryHelper.GetContactProfile(id);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("organization")]
|
||||
public async Task<IActionResult> GetOrganizationList()
|
||||
{
|
||||
var response = await _directoryHelper.GetOrganizationList();
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpDelete("{id}")]
|
||||
public async Task<IActionResult> DeleteContact(Guid id, [FromQuery] bool? active)
|
||||
{
|
||||
var response = await _directoryHelper.DeleteContact(id, active ?? false);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------- Contact Notes --------------------------------
|
||||
|
||||
[HttpPost("note")]
|
||||
public async Task<IActionResult> CreateContactNote([FromBody] CreateContactNoteDto noteDto)
|
||||
{
|
||||
|
||||
var response = await _directoryHelper.CreateContactNote(noteDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpGet("notes/{ContactId}")]
|
||||
public async Task<IActionResult> GetNoteListByContactId(Guid contactId, [FromQuery] bool active = true)
|
||||
{
|
||||
var response = await _directoryHelper.GetNoteListByContactId(contactId, active);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPut("note/{id}")]
|
||||
public async Task<IActionResult> UpdateContactNote(Guid id, [FromBody] UpdateContactNoteDto noteDto)
|
||||
{
|
||||
var response = await _directoryHelper.UpdateContactNote(id, noteDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("note/{id}")]
|
||||
public async Task<IActionResult> DeleteContactNote(Guid id, [FromQuery] bool? active)
|
||||
{
|
||||
var response = await _directoryHelper.DeleteContactNote(id, active ?? false);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
// -------------------------------- Bucket --------------------------------
|
||||
|
||||
[HttpGet("buckets")]
|
||||
public async Task<IActionResult> GetBucketList()
|
||||
{
|
||||
var response = await _directoryHelper.GetBucketList();
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("bucket")]
|
||||
public async Task<IActionResult> CreateBucket(CreateBucketDto bucketDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var errors = ModelState.Values
|
||||
.SelectMany(v => v.Errors)
|
||||
.Select(e => e.ErrorMessage)
|
||||
.ToList();
|
||||
_logger.LogError("User sent Invalid Date while marking attendance");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||
}
|
||||
var response = await _directoryHelper.CreateBucket(bucketDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 409)
|
||||
{
|
||||
return Conflict(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
[HttpPut("bucket/{id}")]
|
||||
public async Task<IActionResult> UpdateBucket(Guid id, [FromBody] UpdateBucketDto bucketDto)
|
||||
{
|
||||
var response = await _directoryHelper.UpdateBucket(id, bucketDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("assign-bucket/{bucketId}")]
|
||||
public async Task<IActionResult> AssignBucket(Guid bucketId, [FromBody] List<AssignBucketDto> assignBuckets)
|
||||
{
|
||||
var response = await _directoryHelper.AssignBucket(bucketId, assignBuckets);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("bucket/{id}")]
|
||||
public async Task<IActionResult> DeleteBucket(Guid id)
|
||||
{
|
||||
var response = await _directoryHelper.DeleteBucket(id);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else if (response.StatusCode == 401)
|
||||
{
|
||||
return Unauthorized(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -9,6 +9,7 @@ using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Model.ViewModels.Activities;
|
||||
using Marco.Pms.Model.ViewModels.Forum;
|
||||
using Marco.Pms.Model.ViewModels.Master;
|
||||
using Marco.Pms.Services.Helpers;
|
||||
using MarcoBMS.Services.Helpers;
|
||||
using MarcoBMS.Services.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
@ -25,11 +26,13 @@ namespace Marco.Pms.Services.Controllers
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly UserHelper _userHelper;
|
||||
private readonly ILoggingService _logger;
|
||||
public MasterController(ApplicationDbContext context, UserHelper userHelper, ILoggingService logger)
|
||||
private readonly MasterHelper _masterHelper;
|
||||
public MasterController(ApplicationDbContext context, UserHelper userHelper, ILoggingService logger, MasterHelper masterHelper)
|
||||
{
|
||||
_context = context;
|
||||
_userHelper = userHelper;
|
||||
_logger = logger;
|
||||
_masterHelper = masterHelper;
|
||||
}
|
||||
|
||||
// -------------------------------- Activity --------------------------------
|
||||
@ -667,5 +670,142 @@ namespace Marco.Pms.Services.Controllers
|
||||
return NotFound(ApiResponse<object>.ErrorResponse("Work category not found", "Work category not found", 404));
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------------- Contact Category --------------------------------
|
||||
|
||||
[HttpGet("contact-categories")]
|
||||
public async Task<IActionResult> GetContactCategoryMasterList()
|
||||
{
|
||||
var response = await _masterHelper.GetContactCategoriesList();
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet("contact-category/{id}")]
|
||||
public async Task<IActionResult> GetContactCategoryMaster(Guid id)
|
||||
{
|
||||
var response = await _masterHelper.GetContactCategoryById(id);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("contact-category")]
|
||||
public async Task<IActionResult> CreateContactCategoryMaster([FromBody] CreateContactCategoryDto contactCategoryDto)
|
||||
{
|
||||
var response = await _masterHelper.CreateContactCategory(contactCategoryDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 409)
|
||||
{
|
||||
return Conflict(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
[HttpPost("contact-category/edit/{id}")]
|
||||
public async Task<IActionResult> UpdateContactCategoryMaster(Guid id, [FromBody] UpdateContactCategoryDto updateContactCategoryDto)
|
||||
{
|
||||
var response = await _masterHelper.UpdateContactCategory(id, updateContactCategoryDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("contact-category/{id}")]
|
||||
public async Task<IActionResult> DeletecontactCategoryMaster(Guid id)
|
||||
{
|
||||
var response = await _masterHelper.DeleteContactCategory(id);
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
// -------------------------------- Contact Tag --------------------------------
|
||||
|
||||
[HttpGet("contact-tags")]
|
||||
public async Task<IActionResult> GetContactTagMasterList()
|
||||
{
|
||||
var response = await _masterHelper.GetContactTags();
|
||||
return Ok(response);
|
||||
}
|
||||
|
||||
[HttpGet("contact-tag/{id}")]
|
||||
public async Task<IActionResult> GetContactTagMaster(Guid id)
|
||||
{
|
||||
return Ok();
|
||||
}
|
||||
|
||||
[HttpPost("contact-tag")]
|
||||
public async Task<IActionResult> CreateContactTagMaster([FromBody] CreateContactTagDto contactTagDto)
|
||||
{
|
||||
if (!ModelState.IsValid)
|
||||
{
|
||||
var errors = ModelState.Values
|
||||
.SelectMany(v => v.Errors)
|
||||
.Select(e => e.ErrorMessage)
|
||||
.ToList();
|
||||
_logger.LogError("User sent Invalid Date while marking attendance");
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid data", errors, 400));
|
||||
}
|
||||
var response = await _masterHelper.CreateContactTag(contactTagDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 409)
|
||||
{
|
||||
return Conflict(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
}
|
||||
}
|
||||
|
||||
[HttpPost("contact-tag/edit/{id}")]
|
||||
public async Task<IActionResult> UpdateContactTagMaster(Guid id, [FromBody] UpdateContactTagDto updateContactTagDto)
|
||||
{
|
||||
var response = await _masterHelper.UpdateContactTag(id, updateContactTagDto);
|
||||
if (response.StatusCode == 200)
|
||||
{
|
||||
return Ok(response);
|
||||
}
|
||||
else if (response.StatusCode == 404)
|
||||
{
|
||||
return NotFound(response);
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(response);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
[HttpDelete("contact-tag/{id}")]
|
||||
public async Task<IActionResult> DeletecontactTagMaster(Guid id)
|
||||
{
|
||||
var response = await _masterHelper.DeleteContactTag(id);
|
||||
return Ok(response);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ using MarcoBMS.Services.Service;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Logging;
|
||||
|
||||
namespace MarcoBMS.Services.Controllers
|
||||
{
|
||||
@ -682,5 +683,122 @@ namespace MarcoBMS.Services.Controllers
|
||||
|
||||
}
|
||||
|
||||
[HttpGet("assigned-projects/{employeeId}")]
|
||||
public async Task<IActionResult> GetProjectsByEmployee([FromRoute] Guid employeeId)
|
||||
{
|
||||
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
if (employeeId == Guid.Empty)
|
||||
{
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "Employee id not valid.", 400));
|
||||
}
|
||||
|
||||
List<Guid> projectList = await _context.ProjectAllocations
|
||||
.Where(c => c.TenantId == tenantId && c.EmployeeId == employeeId && c.IsActive)
|
||||
.Select(c => c.ProjectId).Distinct()
|
||||
.ToListAsync();
|
||||
|
||||
if (!projectList.Any())
|
||||
{
|
||||
return NotFound(ApiResponse<object>.SuccessResponse(new List<object>(), "No projects found.",200));
|
||||
}
|
||||
|
||||
|
||||
List<Project> projectlist = await _context.Projects
|
||||
.Where(p => projectList.Contains(p.Id))
|
||||
.ToListAsync();
|
||||
|
||||
List<ProjectListVM> projects = new List<ProjectListVM>();
|
||||
|
||||
|
||||
foreach (var project in projectlist) {
|
||||
|
||||
projects.Add(project.ToProjectListVMFromProject());
|
||||
}
|
||||
|
||||
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(projects, "Success.", 200));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
[HttpPost("assign-projects/{employeeId}")]
|
||||
public async Task<ActionResult> AssigneProjectsToEmployee([FromBody] List<ProjectsAllocationDto> projectAllocationDtos, [FromRoute] Guid employeeId)
|
||||
{
|
||||
if(projectAllocationDtos != null && employeeId != Guid.Empty)
|
||||
{
|
||||
Guid TenentID = GetTenantId();
|
||||
List<object>? result = new List<object>();
|
||||
|
||||
foreach(var projectAllocationDto in projectAllocationDtos)
|
||||
{
|
||||
try
|
||||
{
|
||||
ProjectAllocation projectAllocation = projectAllocationDto.ToProjectAllocationFromProjectsAllocationDto(TenentID,employeeId);
|
||||
ProjectAllocation? projectAllocationFromDb = await _context.ProjectAllocations.Where(c => c.EmployeeId == employeeId && c.ProjectId == projectAllocationDto.ProjectId && c.ReAllocationDate == null && c.TenantId == TenentID).SingleOrDefaultAsync();
|
||||
|
||||
if(projectAllocationFromDb != null)
|
||||
{
|
||||
|
||||
|
||||
_context.ProjectAllocations.Attach(projectAllocationFromDb);
|
||||
|
||||
if (projectAllocationDto.Status)
|
||||
{
|
||||
projectAllocationFromDb.JobRoleId = projectAllocation.JobRoleId; ;
|
||||
projectAllocationFromDb.IsActive = true;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.JobRoleId).IsModified = true;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
projectAllocationFromDb.ReAllocationDate = DateTime.UtcNow;
|
||||
projectAllocationFromDb.IsActive = false;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.ReAllocationDate).IsModified = true;
|
||||
_context.Entry(projectAllocationFromDb).Property(e => e.IsActive).IsModified = true;
|
||||
}
|
||||
await _context.SaveChangesAsync();
|
||||
var result1 = new
|
||||
{
|
||||
Id = projectAllocationFromDb.Id,
|
||||
EmployeeId = projectAllocation.EmployeeId,
|
||||
JobRoleId = projectAllocation.JobRoleId,
|
||||
IsActive = projectAllocation.IsActive,
|
||||
ProjectId = projectAllocation.ProjectId,
|
||||
AllocationDate = projectAllocation.AllocationDate,
|
||||
ReAllocationDate = projectAllocation.ReAllocationDate,
|
||||
TenantId = projectAllocation.TenantId
|
||||
};
|
||||
result.Add(result1);
|
||||
}
|
||||
else
|
||||
{
|
||||
projectAllocation.AllocationDate = DateTime.Now;
|
||||
projectAllocation.IsActive = true;
|
||||
_context.ProjectAllocations.Add(projectAllocation);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex) {
|
||||
|
||||
return Ok(ApiResponse<object>.ErrorResponse(ex.Message, ex, 400));
|
||||
}
|
||||
}
|
||||
|
||||
return Ok(ApiResponse<object>.SuccessResponse(result, "Data saved successfully", 200));
|
||||
}
|
||||
else
|
||||
{
|
||||
return BadRequest(ApiResponse<object>.ErrorResponse("Invalid details.", "All Field is required", 400));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
1348
Marco.Pms.Services/Helpers/DirectoryHelper.cs
Normal file
1348
Marco.Pms.Services/Helpers/DirectoryHelper.cs
Normal file
File diff suppressed because it is too large
Load Diff
251
Marco.Pms.Services/Helpers/MasterHelper.cs
Normal file
251
Marco.Pms.Services/Helpers/MasterHelper.cs
Normal file
@ -0,0 +1,251 @@
|
||||
using Marco.Pms.DataAccess.Data;
|
||||
using Marco.Pms.Model.Directory;
|
||||
using Marco.Pms.Model.Dtos.Master;
|
||||
using Marco.Pms.Model.Employees;
|
||||
using Marco.Pms.Model.Mapper;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Model.ViewModels.Master;
|
||||
using MarcoBMS.Services.Helpers;
|
||||
using MarcoBMS.Services.Service;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace Marco.Pms.Services.Helpers
|
||||
{
|
||||
public class MasterHelper
|
||||
{
|
||||
private readonly ApplicationDbContext _context;
|
||||
private readonly ILoggingService _logger;
|
||||
private readonly UserHelper _userHelper;
|
||||
|
||||
|
||||
public MasterHelper(ApplicationDbContext context, ILoggingService logger, UserHelper userHelper)
|
||||
{
|
||||
_context = context;
|
||||
_logger = logger;
|
||||
_userHelper = userHelper;
|
||||
}
|
||||
// -------------------------------- Contact Category --------------------------------
|
||||
public async Task<ApiResponse<object>> CreateContactCategory(CreateContactCategoryDto contactCategoryDto)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
if (contactCategoryDto != null)
|
||||
{
|
||||
ContactCategoryMaster? existingContactCategory = await _context.ContactCategoryMasters.FirstOrDefaultAsync(c => c.TenantId == tenantId && c.Name.ToLower() == (contactCategoryDto.Name != null ? contactCategoryDto.Name.ToLower() : ""));
|
||||
if (existingContactCategory == null)
|
||||
{
|
||||
ContactCategoryMaster contactCategory = contactCategoryDto.ToContactCategoryMasterFromCreateContactCategoryDto(tenantId);
|
||||
_context.ContactCategoryMasters.Add(contactCategory);
|
||||
await _context.SaveChangesAsync();
|
||||
ContactCategoryVM categoryVM = contactCategory.ToContactCategoryVMFromContactCategoryMaster();
|
||||
|
||||
_logger.LogInfo("Employee ID {LoggedInEmployeeId} created a contact category {ContactCategoryId}.", LoggedInEmployee.Id, contactCategory.Id);
|
||||
return ApiResponse<object>.SuccessResponse(categoryVM, "Category Created Successfully", 200);
|
||||
}
|
||||
_logger.LogWarning("Employee ID {LoggedInEmployeeId} attempted to create an existing contact category.", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("Category already existed", "Category already existed", 409);
|
||||
}
|
||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
||||
}
|
||||
public async Task<ApiResponse<object>> UpdateContactCategory(Guid id, UpdateContactCategoryDto contactCategoryDto)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
if (contactCategoryDto != null && id == contactCategoryDto.Id)
|
||||
{
|
||||
ContactCategoryMaster? contactCategory = await _context.ContactCategoryMasters.FirstOrDefaultAsync(c => c.TenantId == tenantId && c.Id == id);
|
||||
if (contactCategory != null)
|
||||
{
|
||||
contactCategory.Name = contactCategoryDto.Name ?? "";
|
||||
contactCategory.Description = contactCategoryDto.Description ?? "";
|
||||
|
||||
_context.DirectoryUpdateLogs.Add(new DirectoryUpdateLog
|
||||
{
|
||||
RefereanceId = contactCategory.Id,
|
||||
UpdatedById = LoggedInEmployee.Id,
|
||||
UpdateAt = DateTime.UtcNow
|
||||
});
|
||||
|
||||
await _context.SaveChangesAsync();
|
||||
ContactCategoryVM categoryVM = contactCategory.ToContactCategoryVMFromContactCategoryMaster();
|
||||
|
||||
_logger.LogInfo("Employee ID {LoggedInEmployeeId} created a contact category {ContactCategoryId}.", LoggedInEmployee.Id, contactCategory.Id);
|
||||
return ApiResponse<object>.SuccessResponse(categoryVM, "Category Created Successfully", 200);
|
||||
}
|
||||
_logger.LogWarning("Employee ID {LoggedInEmployeeId} attempted to update a contact category but not found in database.", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("Category not found", "Category not found", 404);
|
||||
}
|
||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
||||
}
|
||||
public async Task<ApiResponse<object>> GetContactCategoriesList()
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
|
||||
var categoryList = await _context.ContactCategoryMasters.Where(c => c.TenantId == tenantId).ToListAsync();
|
||||
List<ContactCategoryVM> contactCategories = new List<ContactCategoryVM>();
|
||||
foreach (var category in categoryList)
|
||||
{
|
||||
ContactCategoryVM categoryVM = category.ToContactCategoryVMFromContactCategoryMaster();
|
||||
contactCategories.Add(categoryVM);
|
||||
}
|
||||
_logger.LogInfo("{count} contact categoires are fetched by Employee with ID {LoggedInEmployeeId}", contactCategories.Count, LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.SuccessResponse(contactCategories, System.String.Format("{0} contact categories fetched successfully", contactCategories.Count), 200);
|
||||
}
|
||||
public async Task<ApiResponse<object>> GetContactCategoryById(Guid id)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
|
||||
var category = await _context.ContactCategoryMasters.FirstOrDefaultAsync(c => c.Id == id && c.TenantId == tenantId);
|
||||
if (category != null)
|
||||
{
|
||||
ContactCategoryVM categoryVM = category.ToContactCategoryVMFromContactCategoryMaster();
|
||||
_logger.LogInfo("Employee {EmployeeId} fetched contact category {ContactCategoryID}", LoggedInEmployee.Id, category.Id);
|
||||
return ApiResponse<object>.SuccessResponse(categoryVM, "Category fetched successfully", 200);
|
||||
}
|
||||
|
||||
_logger.LogWarning("Employee {EmployeeId} attempted to fetch contact category {ContactCategoryID} but not found in database", LoggedInEmployee.Id, id);
|
||||
return ApiResponse<object>.ErrorResponse("Category not found", "Category not found", 404);
|
||||
}
|
||||
public async Task<ApiResponse<object>> DeleteContactCategory(Guid id)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
ContactCategoryMaster? contactCategory = await _context.ContactCategoryMasters.FirstOrDefaultAsync(c => c.Id == id && c.TenantId == tenantId);
|
||||
if (contactCategory != null)
|
||||
{
|
||||
List<Contact>? existingContacts = await _context.Contacts.AsNoTracking().Where(c => c.ContactCategoryId == contactCategory.Id).ToListAsync();
|
||||
if (existingContacts.Count > 0)
|
||||
{
|
||||
List<Contact>? contacts = new List<Contact>();
|
||||
foreach (var contact in existingContacts)
|
||||
{
|
||||
contact.ContactCategoryId = null;
|
||||
contacts.Add(contact);
|
||||
}
|
||||
_context.Contacts.UpdateRange(contacts);
|
||||
}
|
||||
_context.ContactCategoryMasters.Remove(contactCategory);
|
||||
|
||||
_context.DirectoryUpdateLogs.Add(new DirectoryUpdateLog
|
||||
{
|
||||
RefereanceId = id,
|
||||
UpdatedById = LoggedInEmployee.Id,
|
||||
UpdateAt = DateTime.UtcNow
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
_logger.LogInfo("Employee {EmployeeId} deleted contact category {ContactCategoryId}", LoggedInEmployee.Id, id);
|
||||
}
|
||||
|
||||
_logger.LogWarning("Employee {EmployeeId} tries to delete Category {CategoryId} but not found in database", LoggedInEmployee.Id, id);
|
||||
return ApiResponse<object>.SuccessResponse(new { }, "Category deleted successfully", 200);
|
||||
}
|
||||
|
||||
// -------------------------------- Contact Tag --------------------------------
|
||||
|
||||
|
||||
public async Task<ApiResponse<Object>> GetContactTags()
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
|
||||
var taglist = await _context.ContactTagMasters.Where(t => t.TenantId == tenantId).ToListAsync();
|
||||
List<ContactTagVM> contactTags = new List<ContactTagVM>();
|
||||
foreach (var tag in taglist)
|
||||
{
|
||||
ContactTagVM tagVm = tag.ToContactTagVMFromContactTagMaster();
|
||||
contactTags.Add(tagVm);
|
||||
}
|
||||
_logger.LogInfo("{count} contact Tags are fetched by Employee with ID {LoggedInEmployeeId}", contactTags.Count, LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.SuccessResponse(contactTags, System.String.Format("{0} contact tags fetched successfully", contactTags.Count), 200);
|
||||
}
|
||||
public async Task<ApiResponse<object>> CreateContactTag(CreateContactTagDto contactTagDto)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
if (contactTagDto != null)
|
||||
{
|
||||
ContactTagMaster? existingContactTag = await _context.ContactTagMasters.FirstOrDefaultAsync(c => c.TenantId == tenantId && c.Name.ToLower() == (contactTagDto.Name != null ? contactTagDto.Name.ToLower() : ""));
|
||||
if (existingContactTag == null)
|
||||
{
|
||||
ContactTagMaster contactTag = contactTagDto.ToContactTagMasterFromCreateContactTagDto(tenantId);
|
||||
_context.ContactTagMasters.Add(contactTag);
|
||||
await _context.SaveChangesAsync();
|
||||
ContactTagVM tagVM = contactTag.ToContactTagVMFromContactTagMaster();
|
||||
|
||||
_logger.LogInfo("Employee ID {LoggedInEmployeeId} created a contact tag {ContactTagId}.", LoggedInEmployee.Id, contactTag.Id);
|
||||
return ApiResponse<object>.SuccessResponse(tagVM, "Tag Created Successfully", 200);
|
||||
}
|
||||
_logger.LogWarning("Employee ID {LoggedInEmployeeId} attempted to create an existing contact tag.", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("Tag already existed", "Tag already existed", 409);
|
||||
}
|
||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
||||
}
|
||||
public async Task<ApiResponse<object>> UpdateContactTag(Guid id, UpdateContactTagDto contactTagDto)
|
||||
{
|
||||
var tenantId = _userHelper.GetTenantId();
|
||||
Employee LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
if (contactTagDto != null && contactTagDto.Id == id)
|
||||
{
|
||||
ContactTagMaster? contactTag = await _context.ContactTagMasters.AsNoTracking().FirstOrDefaultAsync(t => t.TenantId == tenantId && t.Id == contactTagDto.Id);
|
||||
if (contactTag != null)
|
||||
{
|
||||
contactTag = contactTagDto.ToContactTagMasterFromUpdateContactTagDto(tenantId);
|
||||
_context.ContactTagMasters.Update(contactTag);
|
||||
|
||||
_context.DirectoryUpdateLogs.Add(new DirectoryUpdateLog
|
||||
{
|
||||
RefereanceId = contactTag.Id,
|
||||
UpdatedById = LoggedInEmployee.Id,
|
||||
UpdateAt = DateTime.UtcNow
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
ContactTagVM contactTagVm = contactTag.ToContactTagVMFromContactTagMaster();
|
||||
|
||||
|
||||
|
||||
_logger.LogInfo("Work category master {ConatctTagId} updated successfully by employee {EmployeeId}", contactTagVm.Id, LoggedInEmployee.Id);
|
||||
ApiResponse<object>.SuccessResponse(contactTagVm, "Contact Tag master updated successfully", 200);
|
||||
}
|
||||
_logger.LogError("Contact Tag master {ContactTagId} not found in database", id);
|
||||
ApiResponse<object>.ErrorResponse("Contact Tag master not found", "Contact tag master not found", 404);
|
||||
}
|
||||
_logger.LogWarning("Employee with ID {LoggedInEmployeeId} sended empty payload", LoggedInEmployee.Id);
|
||||
return ApiResponse<object>.ErrorResponse("User Send empty Payload", "User Send empty Payload", 400);
|
||||
}
|
||||
public async Task<ApiResponse<object>> DeleteContactTag(Guid id)
|
||||
{
|
||||
Guid tenantId = _userHelper.GetTenantId();
|
||||
var LoggedInEmployee = await _userHelper.GetCurrentEmployeeAsync();
|
||||
ContactTagMaster? contactTag = await _context.ContactTagMasters.FirstOrDefaultAsync(c => c.Id == id && c.TenantId == tenantId);
|
||||
if (contactTag != null)
|
||||
{
|
||||
List<ContactTagMapping>? tagMappings = await _context.ContactTagMappings.Where(t => t.ContactTagId == contactTag.Id).ToListAsync();
|
||||
|
||||
_context.ContactTagMasters.Remove(contactTag);
|
||||
if (tagMappings.Any())
|
||||
{
|
||||
_context.ContactTagMappings.RemoveRange(tagMappings);
|
||||
}
|
||||
_context.DirectoryUpdateLogs.Add(new DirectoryUpdateLog
|
||||
{
|
||||
RefereanceId = id,
|
||||
UpdatedById = LoggedInEmployee.Id,
|
||||
UpdateAt = DateTime.UtcNow
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
_logger.LogInfo("Employee {EmployeeId} deleted contact tag {ContactTagId}", LoggedInEmployee.Id, id);
|
||||
}
|
||||
|
||||
_logger.LogWarning("Employee {EmployeeId} tries to delete Tag {ContactTagId} but not found in database", LoggedInEmployee.Id, id);
|
||||
return ApiResponse<object>.SuccessResponse(new { }, "Tag deleted successfully", 200);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ using Marco.Pms.DataAccess.Data;
|
||||
using Marco.Pms.Model.Authentication;
|
||||
using Marco.Pms.Model.Entitlements;
|
||||
using Marco.Pms.Model.Utilities;
|
||||
using Marco.Pms.Services.Helpers;
|
||||
using Marco.Pms.Services.Service;
|
||||
using MarcoBMS.Services.Helpers;
|
||||
using MarcoBMS.Services.Middleware;
|
||||
@ -131,6 +132,8 @@ builder.Services.AddScoped<UserHelper>();
|
||||
builder.Services.AddScoped<RolesHelper>();
|
||||
builder.Services.AddScoped<EmployeeHelper>();
|
||||
builder.Services.AddScoped<ProjectsHelper>();
|
||||
builder.Services.AddScoped<DirectoryHelper>();
|
||||
builder.Services.AddScoped<MasterHelper>();
|
||||
builder.Services.AddSingleton<ILoggingService, LoggingService>();
|
||||
|
||||
|
||||
|
@ -9,7 +9,7 @@
|
||||
"Title": "Dev"
|
||||
},
|
||||
"ConnectionStrings": {
|
||||
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS10"
|
||||
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMSGuid"
|
||||
},
|
||||
"SmtpSettings": {
|
||||
"SmtpServer": "smtp.gmail.com",
|
||||
|
Loading…
x
Reference in New Issue
Block a user