/// <summary> /// Add mapped authors in domain entity from table entity /// </summary> /// <param name="entity">Domain entity object</param> /// <param name="table">Table entity object</param> public static void MapAuthor(this IAuditAuthor <Guid> entity, IAuditNavigation <Guid, User> table) { entity.CreatedAuthor = new Author <Guid>(table.CreatedBy, table.CreatedAuthor?.GetFullName()); if (table.ChangedBy != null) { entity.ChangedAuthor = new AuthorNullable <Guid>(table.ChangedBy.Value, table.ChangedAuthor.GetFullName()); } }
/// <summary> /// Map author data /// </summary> /// <param name="dto">Data transport object instance</param> /// <param name="entity">Entity object instance</param> public static void Map <TKey>(IAuditDto <TKey> dto, IAuditAuthor <TKey> entity) where TKey : struct { AuditAuthor <TKey> createdBy = null; AuditAuthor <TKey> changedBy = null; if (entity.CreatedAuthor != null) { createdBy = new AuditAuthor <TKey>(entity.CreatedOn, entity.CreatedAuthor.Id, entity.CreatedAuthor.Name); } if (entity.ChangedAuthor != null) { changedBy = new AuditAuthor <TKey>(entity.ChangedOn.Value, entity.ChangedAuthor.Id.Value, entity.ChangedAuthor.Name); } dto.CreatedBy = createdBy; dto.ChangedBy = changedBy; }