-
-
Save explorer14/bc06243d52e59cc894a4ea315d9fb33c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using Genny; | |
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
namespace ConsoleApp9.Domain | |
{ | |
[GenerateMappedDto] | |
public sealed class Employee | |
{ | |
private readonly List<CompanyAsset> assetsAllocated = | |
new List<CompanyAsset>(); | |
public Employee( | |
string name, | |
DateTime dateOfJoining) | |
{ | |
Id = Guid.NewGuid(); | |
Name = name; | |
DateOfJoining = dateOfJoining; | |
} | |
public Guid Id { get; } | |
public string Name { get; } | |
public DateTime DateOfJoining { get; } | |
public Address? HomeAddress { get; set; } | |
public IReadOnlyCollection<CompanyAsset> AssetsAllocated => | |
assetsAllocated; | |
public void AllocateAsset(CompanyAsset asset) => | |
assetsAllocated.Add(asset); | |
} | |
[GenerateMappedDto] | |
public class CompanyAsset | |
{ | |
public CompanyAsset(string name, decimal worth, string code) | |
{ | |
Name = name; | |
Worth = worth; | |
AssetCode = new AssetCode(code); | |
} | |
public string Name { get; } | |
public decimal Worth { get; } | |
public AssetCode AssetCode { get; } | |
} | |
[GenerateMappedDto] | |
public struct AssetCode | |
{ | |
public AssetCode(string code) | |
{ | |
Code = code; | |
} | |
public string Code { get; } | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment