1- using CodeBlock . DevKit . Core . Extensions ;
1+ using System . ComponentModel . DataAnnotations ;
2+ using CanBeYours . Core . Resources ;
3+ using CodeBlock . DevKit . Core . Extensions ;
24using CodeBlock . DevKit . Domain . Entities ;
35
46namespace CanBeYours . Core . Domain . DemoThings ;
57
68public sealed class DemoThing : AggregateRoot
79{
8- private DemoThing ( string name , string description )
10+ private DemoThing ( string name , string description , DemoThingType type , string userId )
911 {
1012 Name = name ;
1113 Description = description ;
14+ Type = type ;
15+ UserId = userId ;
1216
1317 CheckPolicies ( ) ;
1418
@@ -18,19 +22,22 @@ private DemoThing(string name, string description)
1822
1923 public string Name { get ; private set ; }
2024 public string Description { get ; private set ; }
25+ public DemoThingType Type { get ; private set ; }
26+ public string UserId { get ; private set ; }
2127
22- public static DemoThing Create ( string name , string description )
28+ public static DemoThing Create ( string name , string description , DemoThingType type , string userId )
2329 {
24- return new DemoThing ( name , description ) ;
30+ return new DemoThing ( name , description , type , userId ) ;
2531 }
2632
27- public void Update ( string name , string description )
33+ public void Update ( string name , string description , DemoThingType type )
2834 {
29- if ( Name == name && Description == description )
35+ if ( Name == name && Description == description && Type == type )
3036 return ;
3137
3238 Name = name ;
3339 Description = description ;
40+ Type = type ;
3441
3542 CheckPolicies ( ) ;
3643
@@ -47,5 +54,20 @@ private void CheckPolicies()
4754
4855 if ( Description . IsNullOrEmptyOrWhiteSpace ( ) )
4956 throw DemoThingDomainExceptions . DescriptionIsRequired ( ) ;
57+
58+ if ( UserId . IsNullOrEmptyOrWhiteSpace ( ) )
59+ throw DemoThingDomainExceptions . UserIdIsRequired ( ) ;
5060 }
5161}
62+
63+ public enum DemoThingType
64+ {
65+ [ Display ( Name = nameof ( SharedResource . DemoThingType_DemoType1 ) , ResourceType = typeof ( SharedResource ) ) ]
66+ DemoType1 = 0 ,
67+
68+ [ Display ( Name = nameof ( SharedResource . DemoThingType_DemoType2 ) , ResourceType = typeof ( SharedResource ) ) ]
69+ DemoType2 = 1 ,
70+
71+ [ Display ( Name = nameof ( SharedResource . DemoThingType_DemoType3 ) , ResourceType = typeof ( SharedResource ) ) ]
72+ DemoType3 = 2 ,
73+ }
0 commit comments