-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement a basic user record, also improves integration test coverage
- Loading branch information
Showing
51 changed files
with
1,351 additions
and
190 deletions.
There are no files selected for viewing
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
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,4 +1,4 @@ | ||
FROM microsoft/dotnet:2.1-sdk AS base | ||
FROM microsoft/dotnet:2.2-sdk AS base | ||
WORKDIR /app | ||
COPY . . | ||
|
||
|
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
17 changes: 17 additions & 0 deletions
17
Socialite.Domain/AggregateModels/UserAggregate/IUserRepository.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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using Socialite.Domain.Interfaces; | ||
|
||
namespace Socialite.Domain.AggregateModels.UsersAggregate | ||
{ | ||
public interface IUserRepository : IRepository<User> | ||
{ | ||
List<User> FindAll(); | ||
|
||
Task<User> FindAsync(int userId); | ||
|
||
User Add(User user); | ||
|
||
void Delete(User user); | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
using System; | ||
using Socialite.Domain.Common; | ||
using Socialite.Domain.Events.Users; | ||
|
||
namespace Socialite.Domain.AggregateModels.UsersAggregate | ||
{ | ||
public class User : BaseEntity, IAggregateRoot | ||
{ | ||
public string Email { get; private set; } | ||
|
||
public string Name { get; private set; } | ||
|
||
public string PhoneNumber { get; private set; } | ||
|
||
public DateTime? BirthDate { get; private set; } | ||
|
||
public User(string email, string name) | ||
{ | ||
Email = !string.IsNullOrEmpty(email) ? email : throw new UserDomainException(nameof(email)); | ||
Name = !string.IsNullOrEmpty(name) ? name : throw new UserDomainException(nameof(name)); | ||
} | ||
|
||
public void UpdateName(string name) | ||
{ | ||
if(string.IsNullOrEmpty(name)) | ||
{ | ||
throw new UserDomainException(nameof(name)); | ||
} | ||
|
||
Name = name; | ||
|
||
AddEvent(new UserNameChangedEvent(this)); | ||
} | ||
|
||
public void UpdatePhoneNumber(string phoneNumber) | ||
{ | ||
if(string.IsNullOrEmpty(phoneNumber)) | ||
{ | ||
throw new UserDomainException(nameof(phoneNumber)); | ||
} | ||
|
||
PhoneNumber = phoneNumber; | ||
|
||
AddEvent(new UserPhoneNumberChangedEvent(this)); | ||
} | ||
|
||
public void UpdateBirthDate(DateTime birthDate) | ||
{ | ||
if(birthDate.Subtract(DateTime.Now).Milliseconds > 0) | ||
{ | ||
throw new UserDomainException(nameof(birthDate)); | ||
} | ||
|
||
BirthDate = birthDate; | ||
|
||
AddEvent(new UserBirthDateChangedEvent(this)); | ||
} | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
Socialite.Domain/AggregateModels/UserAggregate/UserDomainException.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 |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System; | ||
|
||
namespace Socialite.Domain.AggregateModels.UsersAggregate | ||
{ | ||
public class UserDomainException : Exception | ||
{ | ||
public UserDomainException(string message) : base(message) | ||
{ | ||
} | ||
} | ||
} |
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
2 changes: 1 addition & 1 deletion
2
Socialite.Domain/Events/PostDraftedEvent.cs → ...e.Domain/Events/Posts/PostDraftedEvent.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
2 changes: 1 addition & 1 deletion
2
...alite.Domain/Events/PostPublishedEvent.cs → ...Domain/Events/Posts/PostPublishedEvent.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
15 changes: 15 additions & 0 deletions
15
Socialite.Domain/Events/Users/UserBirthDateChangedEvent.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Socialite.Domain.AggregateModels.UsersAggregate; | ||
using Socialite.Domain.Common; | ||
|
||
namespace Socialite.Domain.Events.Users | ||
{ | ||
public class UserBirthDateChangedEvent : BaseEvent | ||
{ | ||
public User User { get; private set; } | ||
|
||
public UserBirthDateChangedEvent(User user) | ||
{ | ||
User = user; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Socialite.Domain.AggregateModels.UsersAggregate; | ||
using Socialite.Domain.Common; | ||
|
||
namespace Socialite.Domain.Events.Users | ||
{ | ||
public class UserEmailChangedEvent : BaseEvent | ||
{ | ||
public User User { get; private set; } | ||
|
||
public UserEmailChangedEvent(User user) | ||
{ | ||
User = user; | ||
} | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Socialite.Domain.AggregateModels.UsersAggregate; | ||
using Socialite.Domain.Common; | ||
|
||
namespace Socialite.Domain.Events.Users | ||
{ | ||
public class UserNameChangedEvent : BaseEvent | ||
{ | ||
public User User { get; private set; } | ||
|
||
public UserNameChangedEvent(User user) | ||
{ | ||
User = user; | ||
} | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
Socialite.Domain/Events/Users/UserPhoneNumberChangedEvent.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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using Socialite.Domain.AggregateModels.UsersAggregate; | ||
using Socialite.Domain.Common; | ||
|
||
namespace Socialite.Domain.Events.Users | ||
{ | ||
public class UserPhoneNumberChangedEvent : BaseEvent | ||
{ | ||
public User User { get; private set; } | ||
|
||
public UserPhoneNumberChangedEvent(User user) | ||
{ | ||
User = user; | ||
} | ||
} | ||
} |
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.