Feature_Directory #90

Merged
vikas.nale merged 501 commits from Feature_Directory into main 2025-06-10 14:44:36 +00:00
6 changed files with 3145 additions and 1 deletions
Showing only changes of commit 4cebaba540 - Show all commits

View File

@ -78,6 +78,7 @@ namespace Marco.Pms.DataAccess.Data
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<ContactProjectMapping> ContactProjectMappings { get; set; }

File diff suppressed because it is too large Load Diff

View File

@ -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");
}
}
}

View File

@ -17,4 +17,4 @@ namespace Marco.Pms.Model.Directory
[ForeignKey("ContactId")]
public Contact? Contact { get; set; }
}
}
}

View File

@ -63,6 +63,24 @@ namespace Marco.Pms.Services.Controllers
}
}
[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)
{

View File

@ -62,6 +62,7 @@ namespace Marco.Pms.Services.Helpers
contacts = await _context.Contacts.Include(c => c.ContactCategory).Where(c => contactIds.Contains(c.Id) && c.TenantId == tenantId && c.IsActive == active).ToListAsync();
}
var phoneNo = await _context.ContactsPhones.Where(p => contactIds.Contains(p.ContactId)).ToListAsync();
var Emails = await _context.ContactsEmails.Where(E => contactIds.Contains(E.ContactId)).ToListAsync();
var Tags = await _context.ContactTagMappings.Where(t => contactIds.Contains(t.ContactId)).ToListAsync();
@ -442,6 +443,9 @@ namespace Marco.Pms.Services.Helpers
var tagIds = contactTags.Select(t => t.ContactTagId).Distinct().ToList();
List<ContactProjectMapping> contactProjects = await _context.ContactProjectMappings.AsNoTracking().Where(m => m.ContactId == contact.Id).ToListAsync();
var projectIds = contactProjects.Select(t => t.ProjectId).Distinct().ToList();
List<ContactProjectMapping> contactProjects = await _context.ContactProjectMappings.AsNoTracking().Where(m => m.ContactId == contact.Id).ToListAsync();
var projectIds = contactProjects.Select(t => t.ProjectId).Distinct().ToList();