Models, DTOs (Data Transfer Objects), and view models have been created for the directory.

This commit is contained in:
ashutosh.nehete 2025-05-14 15:17:05 +05:30
parent 621b96a805
commit ccef0ba192
15 changed files with 24 additions and 94 deletions

View File

@ -1,5 +1,4 @@
using Marco.Pms.Model.Employees; using Marco.Pms.Model.Utilities;
using Marco.Pms.Model.Utilities;
namespace Marco.Pms.Model.Directory namespace Marco.Pms.Model.Directory
{ {
@ -7,9 +6,6 @@ namespace Marco.Pms.Model.Directory
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public string Name { get; set; } = string.Empty; 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; public string Description { get; set; } = string.Empty;
} }
} }

View File

@ -9,7 +9,7 @@ namespace Marco.Pms.Model.Directory
public class Contact : TenantRelation public class Contact : TenantRelation
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
//public Guid? ProjectId { get; set; } public Guid? ProjectId { get; set; }
public string Name { get; set; } = string.Empty; public string Name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string Description { get; set; } = string.Empty;
public string Organization { get; set; } = string.Empty; public string Organization { get; set; } = string.Empty;

View File

@ -5,7 +5,7 @@
public Guid Id { get; set; } public Guid Id { get; set; }
public Guid ContactId { get; set; } public Guid ContactId { get; set; }
public Contact? Contact { get; set; } public Contact? Contact { get; set; }
public Guid ContactTagId { get; set; } public Guid ContactTagtId { get; set; }
public ContactTagMaster? ContactTag { get; set; } public ContactTagMaster? ContactTag { get; set; }
} }
} }

View File

@ -2,7 +2,7 @@
{ {
public class CreateBucketDto public class CreateBucketDto
{ {
public string Name { get; set; } = string.Empty; public string name { get; set; } = string.Empty;
public string Description { get; set; } = string.Empty; public string description { get; set; } = string.Empty;
} }
} }

View File

@ -2,15 +2,14 @@
{ {
public class CreateContactDto public class CreateContactDto
{ {
public List<Guid>? ProjectIds { get; set; } public Guid? ProjectId { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public List<CreateContactPhoneDto>? ContactPhones { get; set; } public List<CreateContactPhoneDto>? ContactPhones { get; set; }
public List<CreateContactEmailDto>? ContactEmails { get; set; } public List<CreateContactEmailDto>? ContactEmails { get; set; }
public List<Guid>? BucketIds { get; set; } public Guid ContactCategoryId { get; set; }
public Guid? ContactCategoryId { get; set; }
public string? Description { get; set; } public string? Description { get; set; }
public string? Organization { get; set; } public string? Organization { get; set; }
public string? Address { get; set; } public string? Address { get; set; }
public List<ContactTagDto>? Tags { get; set; } public List<Guid>? TagIds { get; set; }
} }
} }

View File

@ -4,6 +4,7 @@
{ {
public string? Label { get; set; } public string? Label { get; set; }
public string? EmailAddress { get; set; } public string? EmailAddress { get; set; }
public Guid? ContactId { get; set; }
} }
} }

View File

@ -4,5 +4,6 @@
{ {
public string? Label { get; set; } public string? Label { get; set; }
public string? PhoneNumber { get; set; } public string? PhoneNumber { get; set; }
public Guid? ContactId { get; set; }
} }
} }

View File

@ -3,7 +3,7 @@
public class UpdateContactDto public class UpdateContactDto
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public List<Guid>? ProjectIds { get; set; } public Guid? ProjectId { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public List<UpdateContactPhoneDto>? ContactPhones { get; set; } public List<UpdateContactPhoneDto>? ContactPhones { get; set; }
public List<UpdateContactEmailDto>? ContactEmails { get; set; } public List<UpdateContactEmailDto>? ContactEmails { get; set; }
@ -12,6 +12,6 @@
public string? Description { get; set; } public string? Description { get; set; }
public string? Organization { get; set; } public string? Organization { get; set; }
public string? Address { get; set; } public string? Address { get; set; }
public List<ContactTagDto>? Tags { get; set; } public List<Guid>? TagIds { get; set; }
} }
} }

View File

@ -2,7 +2,7 @@
{ {
public class UpdateContactEmailDto public class UpdateContactEmailDto
{ {
public Guid? Id { get; set; } public Guid Id { get; set; }
public string? Label { get; set; } public string? Label { get; set; }
public string? EmailAddress { get; set; } public string? EmailAddress { get; set; }
public Guid? ContactId { get; set; } public Guid? ContactId { get; set; }

View File

@ -2,7 +2,7 @@
{ {
public class UpdateContactPhoneDto public class UpdateContactPhoneDto
{ {
public Guid? Id { get; set; } public Guid Id { get; set; }
public string? Label { get; set; } public string? Label { get; set; }
public string? PhoneNumber { get; set; } public string? PhoneNumber { get; set; }
public Guid? ContactId { get; set; } public Guid? ContactId { get; set; }

View File

@ -3,6 +3,5 @@
public class CreateContactTagDto public class CreateContactTagDto
{ {
public string? Name { get; set; } public string? Name { get; set; }
public string? Description { get; set; }
} }
} }

View File

@ -4,6 +4,5 @@
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public string? Description { get; set; }
} }
} }

View File

@ -8,31 +8,29 @@ namespace Marco.Pms.Model.Mapper
{ {
public static class DirectoryMapper public static class DirectoryMapper
{ {
public static Contact ToContactFromCreateContactDto(this CreateContactDto createContactDto, Guid tenantId, Guid employeeId) public static Contact ToContactFromCreateContactDto(this CreateContactDto createContactDto, Guid tenantId)
{ {
return new Contact return new Contact
{ {
ProjectId = createContactDto.ProjectId,
Name = createContactDto.Name ?? string.Empty, Name = createContactDto.Name ?? string.Empty,
ContactCategoryId = createContactDto.ContactCategoryId, ContactCategoryId = createContactDto.ContactCategoryId,
Description = createContactDto.Description ?? string.Empty, Description = createContactDto.Description ?? string.Empty,
Organization = createContactDto?.Organization ?? string.Empty, Organization = createContactDto?.Organization ?? string.Empty,
Address = createContactDto != null ? createContactDto.Address : string.Empty, Address = createContactDto != null ? createContactDto.Address : string.Empty,
CreatedById = employeeId,
CreatedAt = DateTime.UtcNow,
TenantId = tenantId TenantId = tenantId
}; };
} }
public static Contact ToContactFromUpdateContactDto(this UpdateContactDto updateContactDto, Guid tenantId, Contact contact) public static Contact ToContactFromUpdateContactDto(this UpdateContactDto updateContactDto, Guid tenantId)
{ {
return new Contact return new Contact
{ {
Id = updateContactDto.Id, Id = updateContactDto.Id,
ProjectId = updateContactDto.ProjectId,
Name = updateContactDto.Name ?? string.Empty, Name = updateContactDto.Name ?? string.Empty,
ContactCategoryId = updateContactDto.ContactCategoryId, ContactCategoryId = updateContactDto.ContactCategoryId,
CreatedAt = contact.CreatedAt,
CreatedById = contact.CreatedById,
Description = updateContactDto.Description ?? string.Empty, Description = updateContactDto.Description ?? string.Empty,
Organization = updateContactDto?.Organization ?? string.Empty, Organization = updateContactDto?.Organization ?? string.Empty,
Address = updateContactDto != null ? updateContactDto.Address : string.Empty, Address = updateContactDto != null ? updateContactDto.Address : string.Empty,
@ -44,27 +42,14 @@ namespace Marco.Pms.Model.Mapper
return new ContactVM return new ContactVM
{ {
Id = contact.Id, Id = contact.Id,
ProjectId = contact.ProjectId,
Name = contact.Name, Name = contact.Name,
ContactCategory = contact.ContactCategory != null ? contact.ContactCategory.ToContactCategoryVMFromContactCategoryMaster() : null, ContactType = contact.ContactCategory != null ? contact.ContactCategory.ToContactTypeVMFromContactTypeMaster() : new ContactCategoryVM(),
Description = contact.Description ?? string.Empty, Description = contact.Description ?? string.Empty,
Organization = contact.Organization ?? string.Empty, Organization = contact.Organization ?? string.Empty,
Address = contact.Address ?? 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 //Contact Phone Mapper
public static ContactPhone ToContactPhoneFromCreateContactPhoneDto(this CreateContactPhoneDto createContactPhoneDto, Guid tenantId, Guid contactId) public static ContactPhone ToContactPhoneFromCreateContactPhoneDto(this CreateContactPhoneDto createContactPhoneDto, Guid tenantId, Guid contactId)
@ -81,7 +66,7 @@ namespace Marco.Pms.Model.Mapper
{ {
return new ContactPhone return new ContactPhone
{ {
Id = updateContactPhoneDto.Id ?? Guid.Empty, Id = updateContactPhoneDto.Id,
Label = updateContactPhoneDto.Label ?? string.Empty, Label = updateContactPhoneDto.Label ?? string.Empty,
PhoneNumber = updateContactPhoneDto.PhoneNumber ?? string.Empty, PhoneNumber = updateContactPhoneDto.PhoneNumber ?? string.Empty,
ContactId = contactId, ContactId = contactId,
@ -114,7 +99,7 @@ namespace Marco.Pms.Model.Mapper
{ {
return new ContactEmail return new ContactEmail
{ {
Id = updateContactEmailDto.Id ?? Guid.Empty, Id = updateContactEmailDto.Id,
Label = updateContactEmailDto.Label ?? string.Empty, Label = updateContactEmailDto.Label ?? string.Empty,
EmailAddress = updateContactEmailDto.EmailAddress ?? string.Empty, EmailAddress = updateContactEmailDto.EmailAddress ?? string.Empty,
ContactId = contactId, ContactId = contactId,
@ -148,7 +133,6 @@ namespace Marco.Pms.Model.Mapper
{ {
Id = updateContactTagDto.Id, Id = updateContactTagDto.Id,
Name = updateContactTagDto.Name ?? string.Empty, Name = updateContactTagDto.Name ?? string.Empty,
Description = updateContactTagDto.Description ?? string.Empty,
TenantId = tenantId TenantId = tenantId
}; };
} }
@ -157,7 +141,6 @@ namespace Marco.Pms.Model.Mapper
return new ContactTagVM return new ContactTagVM
{ {
Id = contactTag.Id, Id = contactTag.Id,
Description = contactTag.Description ?? string.Empty,
Name = contactTag.Name ?? string.Empty, Name = contactTag.Name ?? string.Empty,
}; };
} }
@ -191,51 +174,5 @@ namespace Marco.Pms.Model.Mapper
Description = contactType.Description ?? 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
};
}
} }
} }

View File

@ -5,12 +5,11 @@ namespace Marco.Pms.Model.ViewModels.Directory
public class ContactVM public class ContactVM
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public List<Guid>? ProjectIds { get; set; } public Guid? ProjectId { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public List<ContactPhoneVM>? ContactPhones { get; set; } public List<ContactPhoneVM>? ContactPhones { get; set; }
public List<ContactEmailVM>? ContactEmails { get; set; } public List<ContactEmailVM>? ContactEmails { get; set; }
public ContactCategoryVM? ContactCategory { get; set; } public ContactCategoryVM? ContactType { get; set; }
public List<Guid>? BucketIds { get; set; }
public string? Description { get; set; } public string? Description { get; set; }
public string? Organization { get; set; } public string? Organization { get; set; }
public string? Address { get; set; } public string? Address { get; set; }

View File

@ -4,6 +4,5 @@
{ {
public Guid Id { get; set; } public Guid Id { get; set; }
public string? Name { get; set; } public string? Name { get; set; }
public string? Description { get; set; }
} }
} }