183 lines
7.6 KiB
C#
183 lines
7.6 KiB
C#
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
|
|
{
|
|
ProjectId = createContactDto.ProjectId,
|
|
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)
|
|
{
|
|
|
|
return new Contact
|
|
{
|
|
Id = updateContactDto.Id,
|
|
ProjectId = updateContactDto.ProjectId,
|
|
Name = updateContactDto.Name ?? string.Empty,
|
|
ContactCategoryId = updateContactDto.ContactCategoryId,
|
|
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,
|
|
ProjectId = contact.ProjectId,
|
|
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
|
|
};
|
|
}
|
|
|
|
//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,
|
|
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,
|
|
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,
|
|
};
|
|
}
|
|
}
|
|
}
|