Skip to content

Instantly share code, notes, and snippets.

@explorer14
Last active July 14, 2021 22:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save explorer14/bc06243d52e59cc894a4ea315d9fb33c to your computer and use it in GitHub Desktop.
Save explorer14/bc06243d52e59cc894a4ea315d9fb33c to your computer and use it in GitHub Desktop.
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