Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,24 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v6.4.0](https://github.com/Genocs/genocs-library/compare/v6.3.0...v6.4.0)

> 10 November 2024

- Refactor MongoDB repository structure and base classes [`98e24b1`](https://github.com/Genocs/genocs-library/commit/98e24b1aab96ca4276924a822e0b5ffec50c3e9b)
- Update package references to version 6.4.0 across multiple projects [`6fdf470`](https://github.com/Genocs/genocs-library/commit/6fdf470b2234bf8a08e70deb251bef4f2cbd4edc)
- Refactor: Replace IIdentifiable with IEntity [`a21e330`](https://github.com/Genocs/genocs-library/commit/a21e33004ff115b383556835096ee02bd94c9f0f)
- Update packages, refactor code, and improve readability [`0a2d5be`](https://github.com/Genocs/genocs-library/commit/0a2d5be49e6e3d28e56da01aea2b72c21fa83568)
- Remove project refs and add using directive [`a5f189b`](https://github.com/Genocs/genocs-library/commit/a5f189be8c47d0294ca93dea5804a11b67bcc84d)
- Update to version 6.3.0 and refactor codebase [`713fb84`](https://github.com/Genocs/genocs-library/commit/713fb847400afccc205061d854db1ee22159d62d)
- Standardize property names and update audit fields [`c10e995`](https://github.com/Genocs/genocs-library/commit/c10e995b229fa8958e7f0585679562c711a56c22)
- Refactor MongoDB repository structure and update usings [`c3a8bac`](https://github.com/Genocs/genocs-library/commit/c3a8baca5d49ee7999be1e59384fea5c8b2d36d2)
- Refactor AzureInitializer and update MongoDB.Driver [`42dfe53`](https://github.com/Genocs/genocs-library/commit/42dfe53d120dbd53fe8018bdd418f1d2d9208c0f)
- Refactor null checks and exception handling [`7da092d`](https://github.com/Genocs/genocs-library/commit/7da092d0fecec393297dac85cf0a11e6fe6df95c)
- Update CHANGELOG for v6.3.0 release [`2e5eb47`](https://github.com/Genocs/genocs-library/commit/2e5eb47693439d55f9974402bab3f923993f117c)
- Update package versions in multiple project files [`106fc31`](https://github.com/Genocs/genocs-library/commit/106fc319c0411d90a6499bb4477b6f80cbe585f2)
- Refactor Entity and IAggregateRoot for simplicity [`3ccf665`](https://github.com/Genocs/genocs-library/commit/3ccf665db0c7e8eaceb50fa13d14c1ff4faa22e6)

#### [v6.3.0](https://github.com/Genocs/genocs-library/compare/v6.2.0...v6.3.0)

> 3 November 2024
Expand Down
14 changes: 10 additions & 4 deletions Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<Project>

<!--
This Directory.Build.props files sets default properties that apply to all projects found in
this folder or subfolders, recursively.
-->
<PropertyGroup>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
Expand Down Expand Up @@ -51,10 +55,12 @@
</None>
</ItemGroup>

<!--
This Directory.Build.props files sets default properties that apply to all projects found in
this folder or subfolders, recursively.
-->
<ItemGroup>
<!-- Define the global DefaultIdType here. -->
<Using Include="System.Guid" Alias="DefaultIdType" />
</ItemGroup>


<PropertyGroup>
<!-- Enable Build Acceleration in Visual Studio. -->
<AccelerateBuildsInVisualStudio>true</AccelerateBuildsInVisualStudio>
Expand Down
4 changes: 2 additions & 2 deletions src/Genocs.Auth/Genocs.Auth.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="6.3.0" />
<PackageReference Include="Genocs.Security" Version="6.3.0" />
<PackageReference Include="Genocs.Core" Version="6.4.0" />
<PackageReference Include="Genocs.Security" Version="6.4.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
Expand Down
6 changes: 0 additions & 6 deletions src/Genocs.Common/Types/IIdentifiable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,4 @@ public interface IIdentifiable<out T>
/// The Id getter.
/// </summary>
T Id { get; }

/// <summary>
/// Checks if this entity is transient (not persisted to database and it has not an <see cref="Id"/>).
/// </summary>
/// <returns>True, if this entity is transient, otherwise false.</returns>
bool IsTransient();
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Core" Version="6.3.0" />
<PackageReference Include="Genocs.Core" Version="6.4.0" />
</ItemGroup>

</Project>
14 changes: 12 additions & 2 deletions src/Genocs.Core.Demo.Domain/Aggregates/BaseAggregate.cs
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
using Genocs.Core.Domain.Entities;
using Genocs.Core.Domain.Entities.Auditing;
using Genocs.Persistence.MongoDb.Repositories.Clean;
using Genocs.Persistence.MongoDb.Domain.Entities;
using MongoDB.Bson;

namespace Genocs.Core.Demo.Domain.Aggregates;

/// <summary>
/// Base aggregate class used for all entities.
/// This class is used to define some common properties for all entities.
/// </summary>
public class BaseAggregate : AggregateRoot<ObjectId>, IMongoDbEntity, IHasCreationTime
{
public DateTime CreationTime { get; set; } = DateTime.UtcNow;
public BaseAggregate()
{
// Set the unique identifier for the entity generates a new ObjectId.
Id = ObjectId.GenerateNewId();
}

/// <summary>
/// Creation time of this entity.
/// </summary>
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
}
8 changes: 2 additions & 6 deletions src/Genocs.Core.Demo.Domain/Aggregates/Order.cs
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
using Genocs.Core.Domain.Entities;
using Genocs.Core.Domain.Entities.Auditing;
using Genocs.Core.Domain.Repositories;
using Genocs.Persistence.MongoDb.Repositories.Clean;
using Genocs.Core.Domain.Repositories;
using MongoDB.Bson;

namespace Genocs.Core.Demo.Domain.Aggregates;

[TableMapping("Orders")]
public class Order : AggregateRoot<ObjectId>, IMongoDbEntity, IHasCreationTime
public class Order : BaseAggregate
{
public Order(string orderId, string userId, decimal amount, string currency)
{
Expand All @@ -19,7 +16,6 @@ public Order(string orderId, string userId, decimal amount, string currency)

public string OrderId { get; set; } = ObjectId.GenerateNewId().ToString();
public string UserId { get; set; } = default!;
public DateTime CreationTime { get; set; } = DateTime.UtcNow;
public decimal Amount { get; set; }
public string Currency { get; set; } = default!;
}
16 changes: 2 additions & 14 deletions src/Genocs.Core.Demo.Domain/Aggregates/User.cs
Original file line number Diff line number Diff line change
@@ -1,32 +1,20 @@
using Genocs.Common.Types;
using Genocs.Core.Domain.Entities.Auditing;
using Genocs.Core.Domain.Repositories;
using MongoDB.Bson;
using Genocs.Core.Domain.Repositories;

namespace Genocs.Core.Demo.Domain.Aggregates;

[TableMapping("Users")]
public class User : IIdentifiable<ObjectId>, IHasCreationTime
public class User : BaseAggregate
{

public ObjectId Id { get; set; }
public string UserId { get; set; } = default!;
public DateTime CreationTime { get; set; } = DateTime.UtcNow;
public string Username { get; set; } = default!;
public decimal Age { get; set; }
public string Country { get; set; } = default!;

public User(string userId, string username, decimal age, string country)
{
Id = ObjectId.GenerateNewId();
UserId = userId;
Username = username;
Age = age;
Country = country;
}

public bool IsTransient()
{
return true;
}
}
4 changes: 2 additions & 2 deletions src/Genocs.Core.Demo.Domain/Genocs.Core.Demo.Domain.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.Persistence.MongoDb" Version="6.3.0" />
<PackageReference Include="Genocs.Core" Version="6.3.0" />
<PackageReference Include="Genocs.Persistence.MongoDb" Version="6.4.0" />
<PackageReference Include="Genocs.Core" Version="6.4.0" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
using Genocs.Core.Demo.Domain.Aggregates;
using Genocs.Persistence.MongoDb.Repositories;
using Genocs.Persistence.MongoDb.Domain.Repositories;
using Microsoft.AspNetCore.Mvc;

namespace Genocs.Core.Demo.WebApi.Controllers;
Expand Down
23 changes: 11 additions & 12 deletions src/Genocs.Core.Demo.WebApi/Genocs.Core.Demo.WebApi.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,20 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.3.0" />
<PackageReference Include="Genocs.Auth" Version="6.3.0" />
<PackageReference Include="Genocs.Logging" Version="6.3.0" />
<PackageReference Include="Genocs.Tracing" Version="6.3.0" />
<PackageReference Include="Genocs.HTTP" Version="6.3.0" />
<PackageReference Include="Genocs.Security" Version="6.3.0" />
<PackageReference Include="Genocs.WebApi" Version="6.3.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="6.3.0" />
<PackageReference Include="Genocs.Secrets.AzureKeyVault" Version="6.3.0" />

<PackageReference Include="Genocs.ServiceBusAzure" Version="6.4.0" />
<PackageReference Include="Genocs.Auth" Version="6.4.0" />
<PackageReference Include="Genocs.Logging" Version="6.4.0" />
<PackageReference Include="Genocs.Tracing" Version="6.4.0" />
<PackageReference Include="Genocs.HTTP" Version="6.4.0" />
<PackageReference Include="Genocs.Security" Version="6.4.0" />
<PackageReference Include="Genocs.WebApi" Version="6.4.0" />
<PackageReference Include="Genocs.WebApi.Security" Version="6.4.0" />
<PackageReference Include="Genocs.Secrets.AzureKeyVault" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.8.1" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.1" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.9.0" />
</ItemGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
using Genocs.Core.Demo.Contracts;
using Genocs.Core.Demo.Domain.Aggregates;
using Genocs.Persistence.MongoDb.Repositories;
using Genocs.Persistence.MongoDb.Domain.Repositories;
using MassTransit;

namespace Genocs.Core.Demo.Worker.Consumers;
Expand Down
8 changes: 4 additions & 4 deletions src/Genocs.Core.Demo.Worker/Genocs.Core.Demo.Worker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.3.0" />
<PackageReference Include="Genocs.Logging" Version="6.3.0" />
<PackageReference Include="Genocs.Tracing" Version="6.3.0" />
<PackageReference Include="Genocs.ServiceBusAzure" Version="6.4.0" />
<PackageReference Include="Genocs.Logging" Version="6.4.0" />
<PackageReference Include="Genocs.Tracing" Version="6.4.0" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="MassTransit.Extensions.DependencyInjection" Version="7.3.1" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.0" />
<PackageReference Include="MassTransit.RabbitMQ" Version="8.3.1" />
<PackageReference Include="Microsoft.VisualStudio.Azure.Containers.Tools.Targets" Version="1.21.0" />
<PackageReference Include="Serilog.Sinks.ApplicationInsights" Version="4.0.0" />
</ItemGroup>
Expand Down
3 changes: 1 addition & 2 deletions src/Genocs.Core.Demo.Worker/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
using Genocs.Core.Demo.Worker.Consumers;
using Genocs.Core.Demo.Worker.Handlers;
using Genocs.Logging;
using Genocs.Persistence.MongoDb.Domain.Repositories;
using Genocs.Persistence.MongoDb.Extensions;
using Genocs.Persistence.MongoDb.Repositories;
using Genocs.Persistence.MongoDb.Repositories.Clean;
using Genocs.ServiceBusAzure.Configurations;
using Genocs.ServiceBusAzure.Queues;
using Genocs.ServiceBusAzure.Queues.Interfaces;
Expand Down
4 changes: 2 additions & 2 deletions src/Genocs.Core/Builders/Extensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ public static class Extensions
/// <summary>
/// The Builder.
/// </summary>
/// <param name="services"></param>
/// <param name="configuration"></param>
/// <param name="services">The service collection.</param>
/// <param name="configuration">The configuration.</param>
/// <returns>The builder.</returns>
public static IGenocsBuilder AddGenocs(this IServiceCollection services, IConfiguration? configuration = null)
{
Expand Down
6 changes: 3 additions & 3 deletions src/Genocs.Core/Collections/Extensions/ListExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@
public static class ListExtensions
{
/// <summary>
/// Sort a list by a topological sorting, which consider their dependencies
/// Sort a list by a topological sorting, which consider their dependencies.
/// </summary>
/// <typeparam name="T">The type of the members of values.</typeparam>
/// <param name="source">A list of objects to sort</param>
/// <param name="getDependencies">Function to resolve the dependencies</param>
/// <param name="source">A list of objects to sort.</param>
/// <param name="getDependencies">Function to resolve the dependencies.</param>
/// <returns></returns>
public static List<T> SortByDependencies<T>(this IEnumerable<T> source, Func<T, IEnumerable<T>> getDependencies)
{
Expand Down
8 changes: 7 additions & 1 deletion src/Genocs.Core/Collections/TypeList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@ public class TypeList<TBaseType> : ITypeList<TBaseType>
/// Gets the count.
/// </summary>
/// <value>The count.</value>
public int Count { get { return _typeList.Count; } }
public int Count
{
get
{
return _typeList.Count;
}
}

/// <summary>
/// Gets a value indicating whether this instance is read only.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public abstract class AuditedAggregateRoot<TPrimaryKey> : CreationAuditedAggrega
/// <summary>
/// Last modification date of this entity.
/// </summary>
public virtual DateTime? LastModificationTime { get; set; }
public virtual DateTime? LastUpdate { get; set; }

/// <summary>
/// Last modifier user of this entity.
/// </summary>
public virtual long? LastModifierUserId { get; set; }
public virtual long? UpdatedBy { get; set; }
}

/// <summary>
Expand All @@ -48,5 +48,5 @@ public abstract class AuditedAggregateRoot<TPrimaryKey, TUser> : AuditedAggregat
/// Reference to the last modifier user of this entity.
/// </summary>
[ForeignKey("LastModifierUserId")]
public virtual TUser? LastModifierUser { get; set; }
public virtual TUser? UpdatedByUser { get; set; }
}
6 changes: 3 additions & 3 deletions src/Genocs.Core/Domain/Entities/Auditing/AuditedEntity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ public abstract class AuditedEntity<TPrimaryKey> : CreationAuditedEntity<TPrimar
/// <summary>
/// Last modification date of this entity.
/// </summary>
public virtual DateTime? LastModificationTime { get; set; }
public virtual DateTime? LastUpdate { get; set; }

/// <summary>
/// Last modifier user of this entity.
/// </summary>
public virtual long? LastModifierUserId { get; set; }
public virtual long? UpdatedBy { get; set; }
}

/// <summary>
Expand All @@ -48,5 +48,5 @@ public abstract class AuditedEntity<TPrimaryKey, TUser> : AuditedEntity<TPrimary
/// Reference to the last modifier user of this entity.
/// </summary>
[ForeignKey("LastModifierUserId")]
public virtual TUser? LastModifierUser { get; set; }
public virtual TUser? UpdatedByUser { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ public abstract class CreationAuditedAggregateRoot<TPrimaryKey> : AggregateRoot<
/// <summary>
/// Creation time of this entity.
/// </summary>
public virtual DateTime CreationTime { get; set; }
public virtual DateTime CreatedAt { get; set; }

/// <summary>
/// Creator of this entity.
/// </summary>
public virtual long? CreatorUserId { get; set; }
public virtual long CreatorUserId { get; set; }

/// <summary>
/// Constructor.
/// </summary>
protected CreationAuditedAggregateRoot()
{
// CreationTime = Clock.Now; // Manage time zone
CreationTime = DateTime.Now;
CreatedAt = DateTime.Now;
}
}

Expand Down
Loading