This file contains hidden or 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
public class Industry : Entity | |
{ | |
public const string CarsIndustry = "Cars"; | |
public const string PharmacyIndustry = "Pharmacy"; | |
public const string MediaIndustry = "Media"; | |
public string Name { get; private set; } | |
} | |
public class Customer : Entity |
This file contains hidden or 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
[Fact] | |
public void SnackMachineRepository_NewSnackMachine_IsSaved() | |
{ | |
SessionFactory.Init(@"Server=VLADIMIR-PC\SQL2014;Database=DddInPractice;Trusted_Connection=true"); | |
var repository = new SnackMachineRepository(); | |
var snackMachine = new SnackMachine(); | |
snackMachine.LoadSnacks(1, new SnackPile(Chocolate, 1, 1m)); | |
snackMachine.LoadSnacks(2, new SnackPile(Chocolate, 1, 1m)); | |
snackMachine.LoadSnacks(3, new SnackPile(Chocolate, 1, 1m)); |
This file contains hidden or 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
[HttpPost] | |
[Route("customers/{id}/promotion")] | |
public HttpResponseMessage Promote(long id) | |
{ | |
return _customerRepository.GetById(id) | |
.ToResult("Customer with such Id is not found: " + id) | |
.Ensure(customer => customer.CanBePromoted(), "The customer has the highest status possible") | |
.OnSuccess(customer => customer.Promote()) | |
.OnSuccess(customer => _unitOfWork.Flush().Map(() => customer)) | |
.OnSuccess(customer => _emailGateway.SendPromotionNotification(customer.PrimaryEmail, customer.Status) |
This file contains hidden or 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
public class Fabric : AggregateRootWithLinkedObjects | |
{ | |
public bool PreOrder { get; protected set; } | |
private string _Due { get; set; } | |
public Maybe<string> Due | |
{ | |
get => _Due; | |
protected set => _Due = value.Unwrap(); | |
} |
This file contains hidden or 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
public class Fabric : AggregateRootWithLinkedObjects | |
{ | |
public bool PreOrder { get; protected set; } | |
private string _Due { get; set; } | |
public Maybe<string> Due | |
{ | |
get => _Due; | |
protected set => _Due = value.Unwrap(); | |
} |
This file contains hidden or 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
public class FurnitureEntity : Entity { /* ... */ } |
This file contains hidden or 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
public struct DecimalGreaterThanZero : IEquatable<DecimalGreaterThanZero> | |
{ | |
private readonly decimal _value; | |
public DecimalGreaterThanZero(decimal value) | |
{ | |
if (CanCreate(value) == false) | |
throw new ArgumentException("Value must be greater than zero.", nameof(value)); | |
_value = value; |
This file contains hidden or 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
export class Vector { | |
private _x: number; | |
private _y: number; | |
public getX(): number { | |
return this._x; | |
} | |
public getY(): number { | |
return this._y; |
This file contains hidden or 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
public class Company | |
{ | |
public void AssignDelivery(Delivery delivery) | |
{ | |
if (!delivery.IsValid()) | |
throw new Exception(); | |
_deliveries.Add(delivery); | |
} |
This file contains hidden or 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
public abstract class ValueObject<T> | |
where T : ValueObject<T> | |
{ | |
public override bool Equals(object obj) | |
{ | |
var valueObject = obj as T; | |
if (ReferenceEquals(valueObject, null)) | |
return false; | |