-
-
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.
Merge pull request #36 from a-sharifov/develop
Develop
- Loading branch information
Showing
117 changed files
with
799 additions
and
385 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
17 changes: 0 additions & 17 deletions
17
crs/CommonComponents/Common/Application/Abstractions/IEmailService.cs
This file was deleted.
Oops, something went wrong.
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
31 changes: 21 additions & 10 deletions
31
crs/CommonComponents/Common/Domain/Primitives/Enumeration.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,35 +1,46 @@ | ||
namespace Common.Domain.Primitives; | ||
|
||
public abstract class Enumeration<TEnum>( | ||
int value, | ||
string name) | ||
|
||
public abstract class Enumeration<TEnum>(int value, string name) | ||
where TEnum : Enumeration<TEnum> | ||
{ | ||
public readonly int Value = value; | ||
public readonly string Name = name; | ||
private static readonly Dictionary<int, TEnum> _enumerations = GetEnumerations(); | ||
|
||
private static readonly Dictionary<int, TEnum> _enumerations = GetEnumerations(); | ||
|
||
public static TEnum? FromValue(int value) => | ||
_enumerations.TryGetValue(value, out var enumeration) | ||
_enumerations.TryGetValue(value, out var enumeration) | ||
? enumeration : null; | ||
|
||
public static TEnum? FromName(string name) => | ||
_enumerations.Values.SingleOrDefault(x => x.Name == name); | ||
public static TEnum FromName(string name) => | ||
_enumerations.Values.Single(x => x.Name == name); | ||
|
||
public static IEnumerable<string> GetNames() => | ||
_enumerations.Values.Select(x => x.Name); | ||
|
||
public static bool NameExists(string name) => | ||
_enumerations.Values.Any(x => x.Name == name); | ||
|
||
public static bool ValueExists(int value) => | ||
_enumerations.ContainsKey(value); | ||
|
||
private static Dictionary<int, TEnum> GetEnumerations() | ||
{ | ||
var enumerationType = typeof(TEnum); | ||
|
||
var fields = enumerationType.GetFields( | ||
BindingFlags.Public | | ||
BindingFlags.Static | | ||
BindingFlags.Public | | ||
BindingFlags.Static | | ||
BindingFlags.DeclaredOnly) | ||
.Where(fieldInfo => enumerationType.IsAssignableFrom(fieldInfo.FieldType)) | ||
.Select(fieldInfo => (TEnum)fieldInfo.GetValue(default)!); | ||
|
||
return fields.ToDictionary(field => field.Value); | ||
} | ||
|
||
public static implicit operator int(Enumeration<TEnum> @enum) => | ||
@enum.Value; | ||
|
||
public static implicit operator string(Enumeration<TEnum> @enum) => | ||
@enum.Name; | ||
} |
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 was deleted.
Oops, something went wrong.
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
8 changes: 8 additions & 0 deletions
8
crs/CommonComponents/Contracts/Abstractions/Abstractions.proto
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,8 @@ | ||
syntax = "proto3"; | ||
|
||
option csharp_namespace = "Contracts.Abstractions"; | ||
|
||
package abstractions; | ||
|
||
|
||
message NotFound {} |
20 changes: 20 additions & 0 deletions
20
crs/CommonComponents/Contracts/Attributes/RoleBasedAuthorizeFilter.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,20 @@ | ||
//using Contracts.Enumurations; | ||
//using Microsoft.AspNetCore.Authentication; | ||
//using Microsoft.AspNetCore.Mvc; | ||
//using Microsoft.AspNetCore.Mvc.Filters; | ||
|
||
//namespace Contracts.Attributes; | ||
|
||
//public class RoleBasedAuthorizeFilter(Role role) : IAuthorizationFilter | ||
//{ | ||
// private readonly Role role = role; | ||
|
||
// public void OnAuthorization(AuthorizationFilterContext context) | ||
// { | ||
// if (!context.HttpContext.User.Identity.IsAuthenticated) | ||
// { | ||
// context.Result = new ChallengeResult(); | ||
// return; | ||
// } | ||
// } | ||
//} |
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,9 +1,28 @@ | ||
<Project Sdk="Microsoft.NET.Sdk"> | ||
|
||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
<PropertyGroup> | ||
<TargetFramework>net8.0</TargetFramework> | ||
<ImplicitUsings>enable</ImplicitUsings> | ||
<Nullable>enable</Nullable> | ||
</PropertyGroup> | ||
|
||
<ItemGroup> | ||
<ProjectReference Include="..\Common\Common.csproj" /> | ||
<ProjectReference Include="..\EventBus\EventBus.Common\EventBus.Common.csproj" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<Protobuf Include="Abstractions\Abstractions.proto" GrpcServices="Both" /> | ||
<Protobuf Include="Services\Identity\Identity.proto" GrpcServices="Both" /> | ||
</ItemGroup> | ||
|
||
<ItemGroup> | ||
<PackageReference Include="Google.Protobuf" Version="3.25.2" /> | ||
<PackageReference Include="Grpc.Net.Client" Version="2.60.0" /> | ||
<PackageReference Include="Grpc.Tools" Version="2.61.0"> | ||
<PrivateAssets>all</PrivateAssets> | ||
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> | ||
</PackageReference> | ||
</ItemGroup> | ||
|
||
</Project> |
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,8 @@ | ||
namespace Contracts.Enumurations; | ||
|
||
public class Gender(int value, string name) : Enumeration<Gender>(value, name) | ||
{ | ||
public static readonly Gender Male = new(0, nameof(Male)); | ||
public static readonly Gender Female = new(1, nameof(Female)); | ||
public static readonly Gender Undefined = new(2, nameof(Undefined)); | ||
} |
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,8 @@ | ||
namespace Contracts.Enumurations; | ||
|
||
public class Role(int value, string name) | ||
: Enumeration<Role>(value, name) | ||
{ | ||
public static readonly Role User = new(0, nameof(User)); | ||
public static readonly Role Admin = new(1, nameof(Admin)); | ||
} |
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,2 @@ | ||
global using Common.Domain.Primitives; | ||
global using EventBus.Common.Messages; |
7 changes: 7 additions & 0 deletions
7
...omponents/Contracts/Services/Identity/Commands/UserCreatedConfirmationEmailSendCommand.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,7 @@ | ||
namespace Contracts.Services.Identity.Commands; | ||
|
||
public sealed record UserCreatedConfirmationEmailSendCommand( | ||
Guid Id, | ||
Guid UserId, | ||
string ConfirmationEmailToken, | ||
string ReturnUrl) : IntegrationCommand(Id); |
5 changes: 5 additions & 0 deletions
5
...CommonComponents/Contracts/Services/Identity/Events/IdentityVerificationConfirmedEvent.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,5 @@ | ||
namespace Contracts.Services.Identity.Events; | ||
|
||
public sealed record IdentityVerificationConfirmedEvent( | ||
Guid Id, | ||
Guid UserId) : IntegrationEvent(Id); |
34 changes: 34 additions & 0 deletions
34
crs/CommonComponents/Contracts/Services/Identity/Identity.proto
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,34 @@ | ||
syntax = "proto3"; | ||
|
||
option csharp_namespace = "Contracts.Services.Identity"; | ||
|
||
package identity; | ||
|
||
service IdentityService { | ||
rpc GetUser(GetUserRequest) returns (User); | ||
} | ||
|
||
message GetUserRequest { | ||
string id = 1; | ||
} | ||
|
||
message User { | ||
string user_id = 1; | ||
string email = 2; | ||
string first_name = 3; | ||
string last_name = 4; | ||
bool is_email_confirmed = 5; | ||
Role role = 6; | ||
Gender gender = 7; | ||
} | ||
|
||
enum Role { | ||
USER = 0; | ||
ADMIN = 1; | ||
} | ||
|
||
enum Gender { | ||
MALE = 0; | ||
FEMALE = 1; | ||
UNDEFINED = 2; | ||
} |
16 changes: 0 additions & 16 deletions
16
crs/CommonComponents/EventBus/EventBus.Common/Abstractions/IEventBus.cs
This file was deleted.
Oops, something went wrong.
8 changes: 8 additions & 0 deletions
8
crs/CommonComponents/EventBus/EventBus.Common/Abstractions/IIntegrationCommand.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,8 @@ | ||
namespace EventBus.Common.Abstractions; | ||
|
||
/// <summary> | ||
/// The integration command interface. | ||
/// </summary> | ||
public interface IIntegrationCommand : IMessage | ||
{ | ||
} |
15 changes: 3 additions & 12 deletions
15
crs/CommonComponents/EventBus/EventBus.Common/Abstractions/IIntegrationEvent.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,17 +1,8 @@ | ||
namespace EventBus.Common.Abstractions; | ||
|
||
/// <summary> | ||
/// Inteface for integration event. | ||
/// The integration command interface. | ||
/// </summary> | ||
public interface IIntegrationEvent: IEvent | ||
public interface IIntegrationEvent : IMessage | ||
{ | ||
/// <summary> | ||
/// The id event. | ||
/// </summary> | ||
Guid Id { get; } | ||
|
||
/// <summary> | ||
/// The creation date of the event. | ||
/// </summary> | ||
DateTime CreatedAt { get; } | ||
} | ||
} |
7 changes: 0 additions & 7 deletions
7
crs/CommonComponents/EventBus/EventBus.Common/Abstractions/IIntegrationEventHandler.cs
This file was deleted.
Oops, something went wrong.
17 changes: 17 additions & 0 deletions
17
crs/CommonComponents/EventBus/EventBus.Common/Abstractions/IMessage.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 @@ | ||
namespace EventBus.Common.Abstractions; | ||
|
||
/// <summary> | ||
/// The message interface. | ||
/// </summary> | ||
public interface IMessage | ||
{ | ||
/// <summary> | ||
/// The id message. | ||
/// </summary> | ||
Guid Id { get; } | ||
|
||
/// <summary> | ||
/// The creation date of the message. | ||
/// </summary> | ||
DateTime CreatedAt { get; } | ||
} |
Oops, something went wrong.