├── README.md ├── DomainNotification.Prompt ├── App.config ├── Dto │ └── PersonDto.cs ├── Properties │ └── AssemblyInfo.cs ├── Program.cs └── DomainNotification.Prompt.csproj ├── DomainNotification.Domain ├── Interfaces │ ├── Errors │ │ └── ILevel.cs │ └── Notifications │ │ ├── IDescription.cs │ │ └── INotification.cs ├── Commands │ ├── Command.cs │ └── SavePerson.cs ├── ValueObjects │ ├── Email.cs │ └── ValueObject.cs ├── Errors │ ├── Warning.cs │ ├── Critical.cs │ ├── ErrorDescription.cs │ ├── Information.cs │ ├── Error.cs │ └── ErrorLevel.cs ├── Notifications │ ├── Description.cs │ └── Notification.cs ├── Entities │ ├── Person.cs │ └── Entity.cs ├── Properties │ └── AssemblyInfo.cs └── DomainNotification.Domain.csproj ├── DomainNotification.Application ├── Services │ ├── PersonService.cs │ └── Service.cs ├── Properties │ └── AssemblyInfo.cs └── DomainNotification.Application.csproj ├── DomainNotification.sln └── .gitignore /README.md: -------------------------------------------------------------------------------- 1 | # DomainNotification 2 | Usando o padrão Notification com C# 3 | -------------------------------------------------------------------------------- /DomainNotification.Prompt/App.config: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /DomainNotification.Domain/Interfaces/Errors/ILevel.cs: -------------------------------------------------------------------------------- 1 | namespace DomainNotification.Domain.Interfaces.Errors 2 | { 3 | public interface ILevel 4 | { 5 | string Description { get; } 6 | 7 | string ToString(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /DomainNotification.Domain/Interfaces/Notifications/IDescription.cs: -------------------------------------------------------------------------------- 1 | namespace DomainNotification.Domain.Interfaces.Notifications 2 | { 3 | public interface IDescription 4 | { 5 | string Message { get; } 6 | 7 | string ToString(); 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /DomainNotification.Domain/Commands/Command.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Entities; 2 | using DomainNotification.Domain.Errors; 3 | 4 | namespace DomainNotification.Domain.Commands 5 | { 6 | public abstract class Command 7 | { 8 | protected Command(Entity entity) 9 | { 10 | Entity = entity; 11 | } 12 | 13 | protected Entity Entity; 14 | protected Error Errors => Entity.Errors; 15 | } 16 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Interfaces/Notifications/INotification.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using DomainNotification.Domain.Notifications; 3 | 4 | namespace DomainNotification.Domain.Interfaces.Notifications 5 | { 6 | public interface INotification 7 | { 8 | IList List { get; } 9 | bool HasNotifications { get; } 10 | 11 | bool Includes(Description error); 12 | void Add(Description error); 13 | } 14 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/ValueObjects/Email.cs: -------------------------------------------------------------------------------- 1 | namespace DomainNotification.Domain.ValueObjects 2 | { 3 | public class Email : ValueObject 4 | { 5 | public Email(string address) 6 | { 7 | Address = address; 8 | Validate(); 9 | } 10 | 11 | public sealed override void Validate() 12 | { 13 | IsInvalidEmail(Address, InvalidEmail); 14 | } 15 | 16 | public string Address { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /DomainNotification.Prompt/Dto/PersonDto.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | 3 | namespace DomainNotification.Prompt.Dto 4 | { 5 | public class PersonDto 6 | { 7 | public PersonDto(Guid personId, string name, string email) 8 | { 9 | PersonId = personId; 10 | Name = name; 11 | Email = email; 12 | } 13 | 14 | public Guid PersonId { get; } 15 | public string Name { get; } 16 | public string Email { get; } 17 | } 18 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/Warning.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Interfaces.Errors; 2 | 3 | namespace DomainNotification.Domain.Errors 4 | { 5 | public class Warning : ILevel 6 | { 7 | public Warning(string description = "Warning") 8 | { 9 | Description = description; 10 | } 11 | 12 | public string Description { get; } 13 | 14 | public override string ToString() 15 | { 16 | return Description; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/Critical.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Interfaces.Errors; 2 | 3 | namespace DomainNotification.Domain.Errors 4 | { 5 | public class Critical : ILevel 6 | { 7 | public Critical(string description = "Critical") 8 | { 9 | Description = description; 10 | } 11 | 12 | public string Description { get; } 13 | 14 | public override string ToString() 15 | { 16 | return Description; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/ErrorDescription.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Interfaces.Errors; 2 | using DomainNotification.Domain.Notifications; 3 | 4 | namespace DomainNotification.Domain.Errors 5 | { 6 | public class ErrorDescription : Description 7 | { 8 | public ILevel Level { get; } 9 | 10 | public ErrorDescription(string message, ILevel level, params string[] args) 11 | : base(message, args) 12 | { 13 | Level = level; 14 | } 15 | } 16 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/Information.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Interfaces.Errors; 2 | 3 | namespace DomainNotification.Domain.Errors 4 | { 5 | public class Information : ILevel 6 | { 7 | public Information(string description = "Information") 8 | { 9 | Description = description; 10 | } 11 | 12 | public string Description { get; } 13 | 14 | public override string ToString() 15 | { 16 | return Description; 17 | } 18 | } 19 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Notifications/Description.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Interfaces.Notifications; 2 | 3 | namespace DomainNotification.Domain.Notifications 4 | { 5 | public abstract class Description : IDescription 6 | { 7 | public string Message { get; } 8 | 9 | protected Description(string message, params string[] args) 10 | { 11 | Message = message; 12 | 13 | for (var i = 0; i < args.Length; i++) 14 | { 15 | Message = Message.Replace("{" + i + "}", args[i]); 16 | } 17 | } 18 | 19 | public override string ToString() => Message; 20 | } 21 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Notifications/Notification.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using DomainNotification.Domain.Interfaces.Notifications; 4 | 5 | namespace DomainNotification.Domain.Notifications 6 | { 7 | public abstract class Notification : INotification 8 | { 9 | public IList List { get; } = new List(); 10 | public bool HasNotifications => List.Any(); 11 | 12 | public bool Includes(Description error) 13 | { 14 | return List.Contains(error); 15 | } 16 | 17 | public void Add(Description description) 18 | { 19 | List.Add(description); 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /DomainNotification.Application/Services/PersonService.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DomainNotification.Domain.Commands; 3 | using DomainNotification.Domain.Entities; 4 | using DomainNotification.Domain.ValueObjects; 5 | 6 | namespace DomainNotification.Application.Services 7 | { 8 | public class PersonService : Service 9 | { 10 | private readonly Person _entity; 11 | 12 | public PersonService(Guid personId, string name, string email) 13 | { 14 | _entity = new Person(personId, name, new Email(email)); 15 | NotificationEntity = _entity; 16 | } 17 | 18 | public void SavePerson(Guid personId, string name) 19 | { 20 | var cmd = new SavePerson(_entity); 21 | cmd.Run(); 22 | } 23 | } 24 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/Error.cs: -------------------------------------------------------------------------------- 1 | using System.Collections.Generic; 2 | using System.Linq; 3 | using DomainNotification.Domain.Notifications; 4 | 5 | namespace DomainNotification.Domain.Errors 6 | { 7 | public class Error : Notification 8 | { 9 | public IList Errors => List.Cast().Where(x => x.Level is Critical).ToList(); 10 | public IList Warnings => List.Cast().Where(x => x.Level is Warning).ToList(); 11 | public IList Informations => List.Cast().Where(x => x.Level is Information).ToList(); 12 | public bool HasErrors => List.Cast().Any(x => x.Level is Critical); 13 | public bool HasWarnings => List.Cast().Any(x => x.Level is Warning); 14 | public bool HasInformations => List.Cast().Any(x => x.Level is Information); 15 | } 16 | } -------------------------------------------------------------------------------- /DomainNotification.Application/Services/Service.cs: -------------------------------------------------------------------------------- 1 | using System.Collections; 2 | using DomainNotification.Domain.Entities; 3 | 4 | namespace DomainNotification.Application.Services 5 | { 6 | public abstract class Service 7 | { 8 | protected Entity NotificationEntity; 9 | 10 | public bool HasNotifications => NotificationEntity != null && NotificationEntity.Errors.HasNotifications; 11 | public bool HasErrors => NotificationEntity != null && NotificationEntity.Errors.HasErrors; 12 | public bool HasWarnings => NotificationEntity != null && NotificationEntity.Errors.HasWarnings; 13 | public bool HasInformations => NotificationEntity != null && NotificationEntity.Errors.HasInformations; 14 | 15 | public IEnumerable Errors() 16 | { 17 | return NotificationEntity?.Errors.Errors; 18 | } 19 | 20 | public IEnumerable Warnings() 21 | { 22 | return NotificationEntity?.Errors.Warnings; 23 | } 24 | 25 | public IEnumerable Informations() 26 | { 27 | return NotificationEntity?.Errors.Informations; 28 | } 29 | } 30 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/ValueObjects/ValueObject.cs: -------------------------------------------------------------------------------- 1 | using System.Text.RegularExpressions; 2 | using DomainNotification.Domain.Errors; 3 | 4 | namespace DomainNotification.Domain.ValueObjects 5 | { 6 | public class ValueObject 7 | { 8 | public Error Notification { get; } = new Error(); 9 | 10 | public virtual void Validate() { } 11 | 12 | protected void Fail(bool condition, ErrorDescription error) 13 | { 14 | if (condition) 15 | Notification.Add(error); 16 | } 17 | 18 | public bool IsValid() 19 | { 20 | return !Notification.HasErrors; 21 | } 22 | 23 | #region Validations 24 | 25 | protected void IsInvalidEmail(string s, ErrorDescription error) 26 | { 27 | const string pattern = @"^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$"; 28 | Fail(!Regex.IsMatch(s, pattern), error); 29 | } 30 | 31 | #endregion 32 | 33 | #region Errors 34 | 35 | public static ErrorDescription InvalidEmail = new ErrorDescription("Invalid E-mail address", new Critical()); 36 | 37 | #endregion 38 | } 39 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Commands/SavePerson.cs: -------------------------------------------------------------------------------- 1 | using DomainNotification.Domain.Entities; 2 | using DomainNotification.Domain.Errors; 3 | 4 | namespace DomainNotification.Domain.Commands 5 | { 6 | public class SavePerson : Command 7 | { 8 | private readonly Person _person; 9 | 10 | public SavePerson(Person person) : base(person) 11 | { 12 | _person = person; 13 | var description = new ErrorDescription("New person create on memory.", new Warning()); 14 | _person.Errors.Add(description); 15 | } 16 | 17 | public void Run() 18 | { 19 | if (!Errors.HasErrors) 20 | { 21 | SavePersonInBackendSystems(); 22 | } 23 | else 24 | { 25 | var error = new ErrorDescription("Registration not saved.", new Critical()); 26 | _person.Errors.Add(error); 27 | } 28 | } 29 | 30 | private void SavePersonInBackendSystems() 31 | { 32 | var message = new ErrorDescription("Registration succeeded.", new Information()); 33 | _person.Errors.Add(message); 34 | } 35 | } 36 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Entities/Person.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DomainNotification.Domain.Errors; 3 | using DomainNotification.Domain.ValueObjects; 4 | 5 | namespace DomainNotification.Domain.Entities 6 | { 7 | public class Person : Entity 8 | { 9 | public Person(Guid personId, string name, Email email) 10 | { 11 | PersonId = personId; 12 | Name = name; 13 | Email = email; 14 | Validate(); 15 | } 16 | 17 | public sealed override void Validate() 18 | { 19 | IsInvalidGuid(PersonId, InvalidId); 20 | IsInvalidName(Name, InvalidName); 21 | IsInvalidEmail(Email, InvalidPersonEmail); 22 | } 23 | 24 | protected void IsInvalidEmail(Email s, ErrorDescription error) 25 | { 26 | Fail(Email.Notification.HasErrors, error); 27 | } 28 | 29 | public Guid PersonId { get; } 30 | public string Name { get; } 31 | public Email Email { get; } 32 | 33 | #region Errors 34 | 35 | public static ErrorDescription InvalidPersonEmail = new ErrorDescription("Invalid E-mail, see object notifications for more details.", new Critical()); 36 | 37 | #endregion 38 | } 39 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Entities/Entity.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DomainNotification.Domain.Errors; 3 | 4 | namespace DomainNotification.Domain.Entities 5 | { 6 | public class Entity 7 | { 8 | public Error Errors { get; } = new Error(); 9 | 10 | public virtual void Validate() { } 11 | 12 | protected void Fail(bool condition, ErrorDescription description) 13 | { 14 | if (condition) 15 | Errors.Add(description); 16 | } 17 | 18 | public bool IsValid() 19 | { 20 | return !Errors.HasErrors; 21 | } 22 | 23 | #region Validations 24 | 25 | protected void IsInvalidGuid(Guid guid, ErrorDescription error) 26 | { 27 | Fail(guid == Guid.Empty, error); 28 | } 29 | 30 | protected void IsInvalidName(string s, ErrorDescription error) 31 | { 32 | Fail(string.IsNullOrWhiteSpace(s), error); 33 | } 34 | 35 | #endregion 36 | 37 | #region Errors 38 | 39 | public static ErrorDescription InvalidId = new ErrorDescription("Invalid Id", new Critical()); 40 | public static ErrorDescription InvalidName = new ErrorDescription("Invalid Name", new Critical()); 41 | 42 | #endregion 43 | } 44 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DomainNotification.Domain")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DomainNotification.Domain")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("2e84a86c-3658-4ae4-bb3c-dd0721841043")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DomainNotification.Prompt/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DomainNotification.Prompt")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DomainNotification.Prompt")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("575eb410-ded3-4bef-a233-98a5915056a2")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DomainNotification.Application/Properties/AssemblyInfo.cs: -------------------------------------------------------------------------------- 1 | using System.Reflection; 2 | using System.Runtime.CompilerServices; 3 | using System.Runtime.InteropServices; 4 | 5 | // General Information about an assembly is controlled through the following 6 | // set of attributes. Change these attribute values to modify the information 7 | // associated with an assembly. 8 | [assembly: AssemblyTitle("DomainNotification.Application")] 9 | [assembly: AssemblyDescription("")] 10 | [assembly: AssemblyConfiguration("")] 11 | [assembly: AssemblyCompany("")] 12 | [assembly: AssemblyProduct("DomainNotification.Application")] 13 | [assembly: AssemblyCopyright("Copyright © 2017")] 14 | [assembly: AssemblyTrademark("")] 15 | [assembly: AssemblyCulture("")] 16 | 17 | // Setting ComVisible to false makes the types in this assembly not visible 18 | // to COM components. If you need to access a type in this assembly from 19 | // COM, set the ComVisible attribute to true on that type. 20 | [assembly: ComVisible(false)] 21 | 22 | // The following GUID is for the ID of the typelib if this project is exposed to COM 23 | [assembly: Guid("8d1f526e-2fa5-4706-ab1e-6db59faf25c9")] 24 | 25 | // Version information for an assembly consists of the following four values: 26 | // 27 | // Major Version 28 | // Minor Version 29 | // Build Number 30 | // Revision 31 | // 32 | // You can specify all the values or you can default the Build and Revision Numbers 33 | // by using the '*' as shown below: 34 | // [assembly: AssemblyVersion("1.0.*")] 35 | [assembly: AssemblyVersion("1.0.0.0")] 36 | [assembly: AssemblyFileVersion("1.0.0.0")] 37 | -------------------------------------------------------------------------------- /DomainNotification.Domain/Errors/ErrorLevel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Reflection; 4 | 5 | namespace DomainNotification.Domain.Errors 6 | { 7 | public abstract class ErrorLevel : IComparable 8 | { 9 | public static ErrorLevel Error = new ErrorLevel("Error"); 10 | public static ErrorLevel Warning = new CardType(2, "Visa"); 11 | public static ErrorLevel Information = new CardType(3, "MasterCard"); 12 | 13 | public string Description { get; } 14 | 15 | protected ErrorLevel() 16 | { 17 | } 18 | 19 | protected ErrorLevel(string description) 20 | { 21 | Description = description; 22 | } 23 | 24 | public override string ToString() 25 | { 26 | return Description; 27 | } 28 | 29 | public static IEnumerable GetAll() where T : ErrorLevel, new() 30 | { 31 | var type = typeof(T); 32 | var fields = type.GetTypeInfo().GetFields(BindingFlags.Public | 33 | BindingFlags.Static | 34 | BindingFlags.DeclaredOnly); 35 | foreach (var info in fields) 36 | { 37 | var instance = new T(); 38 | var locatedValue = info.GetValue(instance) as T; 39 | if (locatedValue != null) 40 | { 41 | yield return locatedValue; 42 | } 43 | } 44 | } 45 | 46 | public override bool Equals(object obj) 47 | { 48 | var otherValue = obj as ErrorLevel; 49 | if (otherValue == null) 50 | { 51 | return false; 52 | } 53 | var typeMatches = GetType().Equals(obj.GetType()); 54 | var valueMatches = Description.Equals(otherValue.Description); 55 | return typeMatches && valueMatches; 56 | } 57 | 58 | public int CompareTo(object other) 59 | { 60 | return string.Compare(Description, ((ErrorLevel)other).Description, StringComparison.Ordinal); 61 | } 62 | } 63 | } -------------------------------------------------------------------------------- /DomainNotification.Prompt/Program.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using DomainNotification.Application.Services; 3 | using DomainNotification.Prompt.Dto; 4 | 5 | namespace DomainNotification.Prompt 6 | { 7 | internal class Program 8 | { 9 | private static void Main() 10 | { 11 | Console.WriteLine("Type your name"); 12 | var name = Console.ReadLine(); 13 | Console.WriteLine("Type your E-mail"); 14 | var email = Console.ReadLine(); 15 | 16 | var personDto = new PersonDto(Guid.NewGuid(), name, email); 17 | var personService = new PersonService(personDto.PersonId, personDto.Name, personDto.Email); 18 | 19 | Submit(personService, personDto); 20 | Console.ReadKey(); 21 | } 22 | 23 | public static void Submit(PersonService personService, PersonDto personDto) 24 | { 25 | personService.SavePerson(personDto.PersonId, 26 | personDto.Name); 27 | 28 | if (personService.HasNotifications) 29 | ShowNotifications(personService); 30 | } 31 | 32 | private static void ShowNotifications(Service personService) 33 | { 34 | if (!personService.HasNotifications) return; 35 | 36 | if (personService.HasErrors) 37 | { 38 | Console.ForegroundColor = ConsoleColor.Red; 39 | Console.WriteLine("\nErrors\n"); 40 | 41 | foreach (var error in personService.Errors()) 42 | { 43 | Console.WriteLine(error.ToString()); 44 | } 45 | } 46 | 47 | if (personService.HasWarnings) 48 | { 49 | Console.ForegroundColor = ConsoleColor.Yellow; 50 | Console.WriteLine("\nWarnings\n"); 51 | 52 | foreach (var error in personService.Warnings()) 53 | { 54 | Console.WriteLine(error.ToString()); 55 | } 56 | } 57 | 58 | if (personService.HasInformations) 59 | { 60 | Console.ForegroundColor = ConsoleColor.Blue; 61 | Console.WriteLine("\nInformations\n"); 62 | 63 | foreach (var error in personService.Informations()) 64 | { 65 | Console.WriteLine(error.ToString()); 66 | } 67 | } 68 | } 69 | } 70 | } -------------------------------------------------------------------------------- /DomainNotification.Domain/DomainNotification.Domain.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {2E84A86C-3658-4AE4-BB3C-DD0721841043} 8 | Library 9 | Properties 10 | DomainNotification.Domain 11 | DomainNotification.Domain 12 | v4.7 13 | 512 14 | 15 | 16 | true 17 | full 18 | false 19 | bin\Debug\ 20 | DEBUG;TRACE 21 | prompt 22 | 4 23 | 24 | 25 | pdbonly 26 | true 27 | bin\Release\ 28 | TRACE 29 | prompt 30 | 4 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | -------------------------------------------------------------------------------- /DomainNotification.Prompt/DomainNotification.Prompt.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {575EB410-DED3-4BEF-A233-98A5915056A2} 8 | Exe 9 | DomainNotification.Prompt 10 | DomainNotification.Prompt 11 | v4.7 12 | 512 13 | true 14 | 15 | 16 | AnyCPU 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | AnyCPU 27 | pdbonly 28 | true 29 | bin\Release\ 30 | TRACE 31 | prompt 32 | 4 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | {8d1f526e-2fa5-4706-ab1e-6db59faf25c9} 55 | DomainNotification.Application 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /DomainNotification.Application/DomainNotification.Application.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Debug 6 | AnyCPU 7 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9} 8 | Library 9 | Properties 10 | DomainNotification.Application 11 | DomainNotification.Application 12 | v4.7 13 | 512 14 | 15 | 16 | 17 | true 18 | full 19 | false 20 | bin\Debug\ 21 | DEBUG;TRACE 22 | prompt 23 | 4 24 | 25 | 26 | pdbonly 27 | true 28 | bin\Release\ 29 | TRACE 30 | prompt 31 | 4 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | {2e84a86c-3658-4ae4-bb3c-dd0721841043} 51 | DomainNotification.Domain 52 | 53 | 54 | 55 | 62 | -------------------------------------------------------------------------------- /DomainNotification.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 14 4 | VisualStudioVersion = 14.0.25420.1 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainNotification.Prompt", "DomainNotification.Prompt\DomainNotification.Prompt.csproj", "{575EB410-DED3-4BEF-A233-98A5915056A2}" 7 | EndProject 8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainNotification.Domain", "DomainNotification.Domain\DomainNotification.Domain.csproj", "{2E84A86C-3658-4AE4-BB3C-DD0721841043}" 9 | EndProject 10 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{CCA39B8A-8A0B-4C55-A1AA-21369FF4DAC3}" 11 | EndProject 12 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Application", "Application", "{CC4FB620-09C8-477F-AA1B-078FD5CA436C}" 13 | EndProject 14 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DomainNotification.Application", "DomainNotification.Application\DomainNotification.Application.csproj", "{8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9}" 15 | EndProject 16 | Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Presentation", "Presentation", "{9C01E2A5-64AC-4C6F-BB8E-0FB47F667BB5}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {575EB410-DED3-4BEF-A233-98A5915056A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {575EB410-DED3-4BEF-A233-98A5915056A2}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {575EB410-DED3-4BEF-A233-98A5915056A2}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {575EB410-DED3-4BEF-A233-98A5915056A2}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {2E84A86C-3658-4AE4-BB3C-DD0721841043}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {2E84A86C-3658-4AE4-BB3C-DD0721841043}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {2E84A86C-3658-4AE4-BB3C-DD0721841043}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {2E84A86C-3658-4AE4-BB3C-DD0721841043}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9}.Release|Any CPU.Build.0 = Release|Any CPU 36 | EndGlobalSection 37 | GlobalSection(SolutionProperties) = preSolution 38 | HideSolutionNode = FALSE 39 | EndGlobalSection 40 | GlobalSection(NestedProjects) = preSolution 41 | {575EB410-DED3-4BEF-A233-98A5915056A2} = {9C01E2A5-64AC-4C6F-BB8E-0FB47F667BB5} 42 | {2E84A86C-3658-4AE4-BB3C-DD0721841043} = {CCA39B8A-8A0B-4C55-A1AA-21369FF4DAC3} 43 | {8D1F526E-2FA5-4706-AB1E-6DB59FAF25C9} = {CC4FB620-09C8-477F-AA1B-078FD5CA436C} 44 | EndGlobalSection 45 | GlobalSection(ExtensibilityGlobals) = postSolution 46 | SolutionGuid = {9BCA50E9-51CA-40F7-B021-8D88D711393C} 47 | EndGlobalSection 48 | EndGlobal 49 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.suo 8 | *.user 9 | *.userosscache 10 | *.sln.docstates 11 | 12 | # User-specific files (MonoDevelop/Xamarin Studio) 13 | *.userprefs 14 | 15 | # Build results 16 | [Dd]ebug/ 17 | [Dd]ebugPublic/ 18 | [Rr]elease/ 19 | [Rr]eleases/ 20 | x64/ 21 | x86/ 22 | bld/ 23 | [Bb]in/ 24 | [Oo]bj/ 25 | [Ll]og/ 26 | 27 | # Visual Studio 2015 cache/options directory 28 | .vs/ 29 | # Uncomment if you have tasks that create the project's static files in wwwroot 30 | #wwwroot/ 31 | 32 | # MSTest test Results 33 | [Tt]est[Rr]esult*/ 34 | [Bb]uild[Ll]og.* 35 | 36 | # NUNIT 37 | *.VisualState.xml 38 | TestResult.xml 39 | 40 | # Build Results of an ATL Project 41 | [Dd]ebugPS/ 42 | [Rr]eleasePS/ 43 | dlldata.c 44 | 45 | # .NET Core 46 | project.lock.json 47 | project.fragment.lock.json 48 | artifacts/ 49 | **/Properties/launchSettings.json 50 | 51 | *_i.c 52 | *_p.c 53 | *_i.h 54 | *.ilk 55 | *.meta 56 | *.obj 57 | *.pch 58 | *.pdb 59 | *.pgc 60 | *.pgd 61 | *.rsp 62 | *.sbr 63 | *.tlb 64 | *.tli 65 | *.tlh 66 | *.tmp 67 | *.tmp_proj 68 | *.log 69 | *.vspscc 70 | *.vssscc 71 | .builds 72 | *.pidb 73 | *.svclog 74 | *.scc 75 | 76 | # Chutzpah Test files 77 | _Chutzpah* 78 | 79 | # Visual C++ cache files 80 | ipch/ 81 | *.aps 82 | *.ncb 83 | *.opendb 84 | *.opensdf 85 | *.sdf 86 | *.cachefile 87 | *.VC.db 88 | *.VC.VC.opendb 89 | 90 | # Visual Studio profiler 91 | *.psess 92 | *.vsp 93 | *.vspx 94 | *.sap 95 | 96 | # TFS 2012 Local Workspace 97 | $tf/ 98 | 99 | # Guidance Automation Toolkit 100 | *.gpState 101 | 102 | # ReSharper is a .NET coding add-in 103 | _ReSharper*/ 104 | *.[Rr]e[Ss]harper 105 | *.DotSettings.user 106 | 107 | # JustCode is a .NET coding add-in 108 | .JustCode 109 | 110 | # TeamCity is a build add-in 111 | _TeamCity* 112 | 113 | # DotCover is a Code Coverage Tool 114 | *.dotCover 115 | 116 | # Visual Studio code coverage results 117 | *.coverage 118 | *.coveragexml 119 | 120 | # NCrunch 121 | _NCrunch_* 122 | .*crunch*.local.xml 123 | nCrunchTemp_* 124 | 125 | # MightyMoose 126 | *.mm.* 127 | AutoTest.Net/ 128 | 129 | # Web workbench (sass) 130 | .sass-cache/ 131 | 132 | # Installshield output folder 133 | [Ee]xpress/ 134 | 135 | # DocProject is a documentation generator add-in 136 | DocProject/buildhelp/ 137 | DocProject/Help/*.HxT 138 | DocProject/Help/*.HxC 139 | DocProject/Help/*.hhc 140 | DocProject/Help/*.hhk 141 | DocProject/Help/*.hhp 142 | DocProject/Help/Html2 143 | DocProject/Help/html 144 | 145 | # Click-Once directory 146 | publish/ 147 | 148 | # Publish Web Output 149 | *.[Pp]ublish.xml 150 | *.azurePubxml 151 | # TODO: Comment the next line if you want to checkin your web deploy settings 152 | # but database connection strings (with potential passwords) will be unencrypted 153 | *.pubxml 154 | *.publishproj 155 | 156 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 157 | # checkin your Azure Web App publish settings, but sensitive information contained 158 | # in these scripts will be unencrypted 159 | PublishScripts/ 160 | 161 | # NuGet Packages 162 | *.nupkg 163 | # The packages folder can be ignored because of Package Restore 164 | **/packages/* 165 | # except build/, which is used as an MSBuild target. 166 | !**/packages/build/ 167 | # Uncomment if necessary however generally it will be regenerated when needed 168 | #!**/packages/repositories.config 169 | # NuGet v3's project.json files produces more ignorable files 170 | *.nuget.props 171 | *.nuget.targets 172 | 173 | # Microsoft Azure Build Output 174 | csx/ 175 | *.build.csdef 176 | 177 | # Microsoft Azure Emulator 178 | ecf/ 179 | rcf/ 180 | 181 | # Windows Store app package directories and files 182 | AppPackages/ 183 | BundleArtifacts/ 184 | Package.StoreAssociation.xml 185 | _pkginfo.txt 186 | 187 | # Visual Studio cache files 188 | # files ending in .cache can be ignored 189 | *.[Cc]ache 190 | # but keep track of directories ending in .cache 191 | !*.[Cc]ache/ 192 | 193 | # Others 194 | ClientBin/ 195 | ~$* 196 | *~ 197 | *.dbmdl 198 | *.dbproj.schemaview 199 | *.jfm 200 | *.pfx 201 | *.publishsettings 202 | orleans.codegen.cs 203 | 204 | # Since there are multiple workflows, uncomment next line to ignore bower_components 205 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 206 | #bower_components/ 207 | 208 | # RIA/Silverlight projects 209 | Generated_Code/ 210 | 211 | # Backup & report files from converting an old project file 212 | # to a newer Visual Studio version. Backup files are not needed, 213 | # because we have git ;-) 214 | _UpgradeReport_Files/ 215 | Backup*/ 216 | UpgradeLog*.XML 217 | UpgradeLog*.htm 218 | 219 | # SQL Server files 220 | *.mdf 221 | *.ldf 222 | *.ndf 223 | 224 | # Business Intelligence projects 225 | *.rdl.data 226 | *.bim.layout 227 | *.bim_*.settings 228 | 229 | # Microsoft Fakes 230 | FakesAssemblies/ 231 | 232 | # GhostDoc plugin setting file 233 | *.GhostDoc.xml 234 | 235 | # Node.js Tools for Visual Studio 236 | .ntvs_analysis.dat 237 | node_modules/ 238 | 239 | # Typescript v1 declaration files 240 | typings/ 241 | 242 | # Visual Studio 6 build log 243 | *.plg 244 | 245 | # Visual Studio 6 workspace options file 246 | *.opt 247 | 248 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 249 | *.vbw 250 | 251 | # Visual Studio LightSwitch build output 252 | **/*.HTMLClient/GeneratedArtifacts 253 | **/*.DesktopClient/GeneratedArtifacts 254 | **/*.DesktopClient/ModelManifest.xml 255 | **/*.Server/GeneratedArtifacts 256 | **/*.Server/ModelManifest.xml 257 | _Pvt_Extensions 258 | 259 | # Paket dependency manager 260 | .paket/paket.exe 261 | paket-files/ 262 | 263 | # FAKE - F# Make 264 | .fake/ 265 | 266 | # JetBrains Rider 267 | .idea/ 268 | *.sln.iml 269 | 270 | # CodeRush 271 | .cr/ 272 | 273 | # Python Tools for Visual Studio (PTVS) 274 | __pycache__/ 275 | *.pyc 276 | 277 | # Cake - Uncomment if you are using it 278 | # tools/** 279 | # !tools/packages.config 280 | 281 | # Telerik's JustMock configuration file 282 | *.jmconfig 283 | 284 | # BizTalk build output 285 | *.btp.cs 286 | *.btm.cs 287 | *.odx.cs 288 | *.xsd.cs 289 | --------------------------------------------------------------------------------