DomainDrivenDesign.Core.CQRS 0.2.0

This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.

Install-Package DomainDrivenDesign.Core.CQRS -Version 0.2.0
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.2.0
<PackageReference Include="DomainDrivenDesign.Core.CQRS" Version="0.2.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add DomainDrivenDesign.Core.CQRS --version 0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: DomainDrivenDesign.Core.CQRS, 0.2.0"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install DomainDrivenDesign.Core.CQRS as a Cake Addin
#addin nuget:?package=DomainDrivenDesign.Core.CQRS&version=0.2.0

// Install DomainDrivenDesign.Core.CQRS as a Cake Tool
#tool nuget:?package=DomainDrivenDesign.Core.CQRS&version=0.2.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

DDDCore

This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.

Articles about this Framework

How to Build a good one Value Object.

Installation

You can install using nuget Package Manager

Install-Package DomainDrivenDesign.Core -Version 0.1.3
Install-Package DomainDrivenDesign.Core.CQRS -Version 0.0.1

Or using .Net Cli

dotnet add package DomainDrivenDesign.Core --version 0.1.3
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.0.1

Technologies used:

  • Railway.NetCore

Usage

You can use Value Object like this one:

Money

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Money : ValueObject<Money>
    {

        protected Money(Decimal amount, string currencyCode)
        {
            this.CheckRule(new CurrencyShouldBeSpecified(currencyCode));

            this.Amount = amount;
            this.Currency = currency;
        }

        protected Money(Decimal amount, Currency currency)
        {
            this.CheckRule(new AmountShouldBePositive(amount));

            this.Amount = amount;
            this.Currency = currency;
        }

   
        public static Money FromDecimal(
            decimal amount,
            string currency)
            => new Money(amount, currency);


        public decimal ToDecimal()
         => Amount;

        protected override IEnumerable<object> GetEqualityComponents()
        {
            yield return Amount;
            yield return Currency;
        }

        public Decimal Amount { get; }

        public String Currency { get; }
    }

CurrencyShouldBeSpecified.cs

    using DomainDrivenDesign.Core.Interfaces;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class CurrencyShouldBeSpecified : IValidationRule
    {
        private readonly string _value;

        internal CurrencyShouldBeSpecified(string value)
        {
            this._value = value;
        }

        public string Message => "Currency code must be specified";

        public bool IsBroken()
        {
            return (string.IsNullOrEmpty(_value));
        }
    }

Also, you can use Entity Object.

Payment.cs Entity Sample

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;


    public class Payment : Entity
    {

        public Card Card { get; protected set; }

        public Money Amount { get; protected set; }

        public string BeneficiaryAlias { get; protected set; }


        public DateTime CreatedOn { get; protected set; }


        public static Result<Payment> CreateNewCardPayment(Card card, Money amount, string beneficiaryAlias)
        {
            return Result.Success(new Payment(card, amount, beneficiaryAlias));
        }


        private Payment(Card card, Money amount, string beneficiaryAlias) : base()
        {
            this.Card = card;
            this.Amount = amount;
            this.BeneficiaryAlias = beneficiaryAlias;
            this.CreatedOn = DateTime.Now;
        }
    }

Soon Mediator, Command, Query and Handlers samples.
If you wish you can see this samples on Sample Project.

License

MIT

DDDCore

This is a Framework designed to give us the Core of DDD to .Net. This Framework is using .Net Standard 2.

Articles about this Framework

How to Build a good one Value Object.

Installation

You can install using nuget Package Manager

Install-Package DomainDrivenDesign.Core -Version 0.1.3
Install-Package DomainDrivenDesign.Core.CQRS -Version 0.0.1

Or using .Net Cli

dotnet add package DomainDrivenDesign.Core --version 0.1.3
dotnet add package DomainDrivenDesign.Core.CQRS --version 0.0.1

Technologies used:

  • Railway.NetCore

Usage

You can use Value Object like this one:

Money

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class Money : ValueObject<Money>
    {

        protected Money(Decimal amount, string currencyCode)
        {
            this.CheckRule(new CurrencyShouldBeSpecified(currencyCode));

            this.Amount = amount;
            this.Currency = currency;
        }

        protected Money(Decimal amount, Currency currency)
        {
            this.CheckRule(new AmountShouldBePositive(amount));

            this.Amount = amount;
            this.Currency = currency;
        }

   
        public static Money FromDecimal(
            decimal amount,
            string currency)
            => new Money(amount, currency);


        public decimal ToDecimal()
         => Amount;

        protected override IEnumerable<object> GetEqualityComponents()
        {
            yield return Amount;
            yield return Currency;
        }

        public Decimal Amount { get; }

        public String Currency { get; }
    }

CurrencyShouldBeSpecified.cs

    using DomainDrivenDesign.Core.Interfaces;
    using System;
    using System.Collections.Generic;
    using System.Text;

    public class CurrencyShouldBeSpecified : IValidationRule
    {
        private readonly string _value;

        internal CurrencyShouldBeSpecified(string value)
        {
            this._value = value;
        }

        public string Message => "Currency code must be specified";

        public bool IsBroken()
        {
            return (string.IsNullOrEmpty(_value));
        }
    }

Also, you can use Entity Object.

Payment.cs Entity Sample

    using DomainDrivenDesign.Core.Models;
    using Railway.NetCore.Core;
    using System;
    using System.Collections.Generic;
    using System.Text;


    public class Payment : Entity
    {

        public Card Card { get; protected set; }

        public Money Amount { get; protected set; }

        public string BeneficiaryAlias { get; protected set; }


        public DateTime CreatedOn { get; protected set; }


        public static Result<Payment> CreateNewCardPayment(Card card, Money amount, string beneficiaryAlias)
        {
            return Result.Success(new Payment(card, amount, beneficiaryAlias));
        }


        private Payment(Card card, Money amount, string beneficiaryAlias) : base()
        {
            this.Card = card;
            this.Amount = amount;
            this.BeneficiaryAlias = beneficiaryAlias;
            this.CreatedOn = DateTime.Now;
        }
    }

Soon Mediator, Command, Query and Handlers samples.
If you wish you can see this samples on Sample Project.

License

MIT

Release Notes

Changed Mediator to MediatorCQRS to improve Raive Event

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
0.2.0 193 7/27/2020
0.0.1 205 7/23/2020