shoc-backend/Api.SeaHavenIndustries/DTOs/EditContact_DTO.cs
2026-05-06 10:49:33 -05:00

95 lines
3.6 KiB
C#

using Data.SeaHavenIndustries;
using SeaHaven.Services.DTOs;
namespace Api.SeaHavenIndustries.DTOs
{
public class EditContact_DTO
{
public int Id { get; set; }
public string? Title { get; set; }
public string? Owner { get; set; }
public string? FirstName { get; set; }
public string? MiddleName { get; set; }
public string? LastName { get; set; }
public string? ContactType { get; set; }
public string? PhoneNumber { get; set; }
public string? Email { get; set; }
public string? Address1 { get; set; }
public string? Address2 { get; set; }
public string? City { get; set; }
public string? State { get; set; }
public string? Zip { get; set; }
public string? FacebookUrl { get; set; }
public string? LinkedInUrl { get; set; }
public string? TwitterUrl { get; set; }
public int? LocationId { get; set; }
public int? AccountId { get; set; }
// ✅ Map API DTO to Service DTO
public UpdateContactDTO ToServiceUpdateDTO()
{
return new UpdateContactDTO
{
FirstName = this.FirstName,
LastName = this.LastName,
Email = this.Email,
Phone = this.PhoneNumber,
Title = this.Title,
Type = this.ContactType,
AccountId = this.AccountId
};
}
// Map from Entity to DTO (Model)
public static EditContact_DTO MapToModel(Contacts entity)
{
return new EditContact_DTO
{
Id = entity.Id,
Title = entity.Title,
Owner = entity.Owner,
FirstName = entity.FirstName,
MiddleName = entity.MiddleName,
LastName = entity.LastName,
ContactType = entity.ContactType,
PhoneNumber = entity.PhoneNumber,
Email = entity.Email,
Address1 = entity.Address1,
Address2 = entity.Address2,
City = entity.City,
State = entity.State,
Zip = entity.Zip,
FacebookUrl = entity.FacebookUrl,
LinkedInUrl = entity.LinkedInUrl,
TwitterUrl = entity.TwitterUrl,
LocationId = entity.LocationId,
AccountId = entity.AccountId
};
}
// Map from DTO (Model) to Entity - updates existing entity
public static Contacts MapToEntity(EditContact_DTO dto, Contacts existingEntity)
{
existingEntity.Title = dto.Title;
existingEntity.Owner = dto.Owner;
existingEntity.FirstName = dto.FirstName;
existingEntity.MiddleName = dto.MiddleName;
existingEntity.LastName = dto.LastName;
existingEntity.ContactType = dto.ContactType;
existingEntity.PhoneNumber = dto.PhoneNumber;
existingEntity.Email = dto.Email;
existingEntity.Address1 = dto.Address1;
existingEntity.Address2 = dto.Address2;
existingEntity.City = dto.City;
existingEntity.State = dto.State;
existingEntity.Zip = dto.Zip;
existingEntity.FacebookUrl = dto.FacebookUrl;
existingEntity.LinkedInUrl = dto.LinkedInUrl;
existingEntity.TwitterUrl = dto.TwitterUrl;
existingEntity.LocationId = dto.LocationId;
existingEntity.AccountId = dto.AccountId;
return existingEntity;
}
}
}