-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShip.cs
More file actions
30 lines (25 loc) · 1.07 KB
/
Copy pathShip.cs
File metadata and controls
30 lines (25 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using CoreDdd.Domain;
using CoreDdd.Domain.Events;
namespace CoreDddSampleWebAppCommon.Domain
{
public class Ship : Entity, IAggregateRoot
{
protected Ship() { } // parameterless constructor needed by nhibernate
// to be able to instantiate the entity when loaded from database
public Ship(string name, decimal tonnage)
{
Name = name;
Tonnage = tonnage;
}
public virtual string Name { get; protected set; } // virtual modifier needed by nhibernate
// - https://stackoverflow.com/a/848116/379279
public virtual decimal Tonnage { get; protected set; } // protected modifier on set needed by nhibernate
// - cannot be private
public virtual void UpdateData(string name, decimal tonnage)
{
Name = name;
Tonnage = tonnage;
DomainEvents.RaiseEvent(new ShipUpdatedDomainEvent { ShipId = Id });
}
}
}