forked from ardalis/pluralsight-ddd-fundamentals
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updating version.
- Loading branch information
Showing
20 changed files
with
328 additions
and
328 deletions.
There are no files selected for viewing
16 changes: 8 additions & 8 deletions
16
SharedKernel/src/PluralsightDdd.SharedKernel/BaseDomainEvent.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
using MediatR; | ||
using System; | ||
using System; | ||
using MediatR; | ||
|
||
namespace PluralsightDdd.SharedKernel | ||
{ | ||
public abstract class BaseDomainEvent : INotification | ||
{ | ||
public DateTime DateOccurred { get; protected set; } = DateTime.UtcNow; | ||
} | ||
} | ||
{ | ||
public abstract class BaseDomainEvent : INotification | ||
{ | ||
public DateTime DateOccurred { get; protected set; } = DateTime.UtcNow; | ||
} | ||
} |
This file contains 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
100 changes: 50 additions & 50 deletions
100
SharedKernel/src/PluralsightDdd.SharedKernel/DateTimeRange.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,66 @@ | ||
using Ardalis.GuardClauses; | ||
using System; | ||
using System; | ||
using System.Collections.Generic; | ||
using Ardalis.GuardClauses; | ||
|
||
namespace PluralsightDdd.SharedKernel | ||
{ | ||
public class DateTimeRange : ValueObject | ||
{ | ||
public DateTime Start { get; private set; } | ||
public DateTime End { get; private set; } | ||
public class DateTimeRange : ValueObject | ||
{ | ||
public DateTime Start { get; private set; } | ||
public DateTime End { get; private set; } | ||
|
||
public DateTimeRange(DateTime start, DateTime end) | ||
{ | ||
// Ardalis.GuardClauses supports extensions with custom guards per project | ||
Guard.Against.OutOfRange(start, nameof(start), start, end); | ||
Start = start; | ||
End = end; | ||
} | ||
public DateTimeRange(DateTime start, DateTime end) | ||
{ | ||
// Ardalis.GuardClauses supports extensions with custom guards per project | ||
Guard.Against.OutOfRange(start, nameof(start), start, end); | ||
Start = start; | ||
End = end; | ||
} | ||
|
||
public DateTimeRange(DateTime start, TimeSpan duration) : this(start, start.Add(duration)) | ||
{ | ||
} | ||
public DateTimeRange(DateTime start, TimeSpan duration) : this(start, start.Add(duration)) | ||
{ | ||
} | ||
|
||
public int DurationInMinutes() | ||
{ | ||
return (int)Math.Round((End - Start).TotalMinutes, 0); | ||
} | ||
public int DurationInMinutes() | ||
{ | ||
return (int)Math.Round((End - Start).TotalMinutes, 0); | ||
} | ||
|
||
public DateTimeRange NewDuration(TimeSpan newDuration) | ||
{ | ||
return new DateTimeRange(this.Start, newDuration); | ||
} | ||
public DateTimeRange NewDuration(TimeSpan newDuration) | ||
{ | ||
return new DateTimeRange(this.Start, newDuration); | ||
} | ||
|
||
public DateTimeRange NewEnd(DateTime newEnd) | ||
{ | ||
return new DateTimeRange(this.Start, newEnd); | ||
} | ||
public DateTimeRange NewEnd(DateTime newEnd) | ||
{ | ||
return new DateTimeRange(this.Start, newEnd); | ||
} | ||
|
||
public DateTimeRange NewStart(DateTime newStart) | ||
{ | ||
return new DateTimeRange(newStart, this.End); | ||
} | ||
public DateTimeRange NewStart(DateTime newStart) | ||
{ | ||
return new DateTimeRange(newStart, this.End); | ||
} | ||
|
||
public static DateTimeRange CreateOneDayRange(DateTime day) | ||
{ | ||
return new DateTimeRange(day, day.AddDays(1)); | ||
} | ||
public static DateTimeRange CreateOneDayRange(DateTime day) | ||
{ | ||
return new DateTimeRange(day, day.AddDays(1)); | ||
} | ||
|
||
public static DateTimeRange CreateOneWeekRange(DateTime startDay) | ||
{ | ||
return new DateTimeRange(startDay, startDay.AddDays(7)); | ||
} | ||
public static DateTimeRange CreateOneWeekRange(DateTime startDay) | ||
{ | ||
return new DateTimeRange(startDay, startDay.AddDays(7)); | ||
} | ||
|
||
public bool Overlaps(DateTimeRange dateTimeRange) | ||
{ | ||
return this.Start < dateTimeRange.End && | ||
this.End > dateTimeRange.Start; | ||
} | ||
public bool Overlaps(DateTimeRange dateTimeRange) | ||
{ | ||
return this.Start < dateTimeRange.End && | ||
this.End > dateTimeRange.Start; | ||
} | ||
|
||
protected override IEnumerable<object> GetEqualityComponents() | ||
{ | ||
yield return Start; | ||
yield return End; | ||
} | ||
protected override IEnumerable<object> GetEqualityComponents() | ||
{ | ||
yield return Start; | ||
yield return End; | ||
} | ||
} | ||
} |
8 changes: 4 additions & 4 deletions
8
SharedKernel/src/PluralsightDdd.SharedKernel/Interfaces/IAggregateRoot.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
namespace PluralsightDdd.SharedKernel.Interfaces | ||
{ | ||
// Apply this marker interface only to aggregate root entities | ||
// Repositories will only work with aggregate roots, not their children | ||
public interface IAggregateRoot { } | ||
} | ||
// Apply this marker interface only to aggregate root entities | ||
// Repositories will only work with aggregate roots, not their children | ||
public interface IAggregateRoot { } | ||
} |
8 changes: 4 additions & 4 deletions
8
SharedKernel/src/PluralsightDdd.SharedKernel/Interfaces/IApplicationEvent.cs
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
namespace PluralsightDdd.SharedKernel.Interfaces | ||
{ | ||
public interface IApplicationEvent | ||
{ | ||
string EventType { get; } | ||
} | ||
public interface IApplicationEvent | ||
{ | ||
string EventType { get; } | ||
} | ||
} |
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.