Skip to content

Commit

Permalink
Merge pull request #16 from fluentcms/basic-structure
Browse files Browse the repository at this point in the history
add very basic structure
  • Loading branch information
MostafaTech authored Oct 23, 2023
2 parents 6b074a1 + fef5111 commit 689b862
Show file tree
Hide file tree
Showing 7 changed files with 127 additions and 0 deletions.
File renamed without changes.
30 changes: 30 additions & 0 deletions src/FluentCMS.Core/Entities/AuditEntity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
namespace FluentCMS.Core.Entities
{
public interface IAuditEntity<TKey> : IEntity<TKey> where TKey : IEquatable<TKey>
{
string CreatedBy { get; set; } // UserName
DateTime CreatedAt { get; set; }

string LastUpdatedBy { get; set; } // UserName
DateTime LastUpdatedAt { get; set; }
}

public interface IAuditEntity : IAuditEntity<Guid>, IEntity
{
}

public class AuditEntity<TKey> : IAuditEntity<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; } = default!;

public string CreatedBy { get; set; } = string.Empty; // UserName
public DateTime CreatedAt { get; set; }

public string LastUpdatedBy { get; set; } = string.Empty; // UserName
public DateTime LastUpdatedAt { get; set; }
}

public class AuditEntity : AuditEntity<Guid>, IAuditEntity
{
}
}
20 changes: 20 additions & 0 deletions src/FluentCMS.Core/Entities/Entity.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
namespace FluentCMS.Core.Entities
{
public interface IEntity<TKey> where TKey : IEquatable<TKey>
{
TKey Id { get; set; }
}

public interface IEntity : IEntity<Guid>
{
}

public class Entity<TKey> : IEntity<TKey> where TKey : IEquatable<TKey>
{
public TKey Id { get; set; } = default!;
}

public class Entity : Entity<Guid>, IEntity
{
}
}
9 changes: 9 additions & 0 deletions src/FluentCMS.Core/FluentCMS.Core.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\FluentCMS.Core\FluentCMS.Core.csproj" />
</ItemGroup>

</Project>
24 changes: 24 additions & 0 deletions src/FluentCMS.Repository.Abstractions/IGenericRepository.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
using FluentCMS.Core.Entities;
using System.Linq.Expressions;

namespace FluentCMS.Repository.Abstractions
{
public interface IGenericRepository<TKey, TEntity>
where TKey : IEquatable<TKey>
where TEntity : IEntity<TKey>
{
Task Create(TEntity entity, CancellationToken cancellationToken = default);
Task Update(TEntity entity, CancellationToken cancellationToken = default);
Task Delete(TKey id, CancellationToken cancellationToken = default);

Task<IEnumerable<TEntity>> GetAll(CancellationToken cancellationToken = default);
Task<IEnumerable<TEntity>> GetAll(Expression<Func<TEntity, bool>> filter, CancellationToken cancellationToken = default);
Task<TEntity> GetById(TKey id, CancellationToken cancellationToken = default);
Task<IEnumerable<TEntity>> GetByIds(IEnumerable<TKey> ids, CancellationToken cancellationToken = default);
}

public interface IGenericRepository<TEntity> : IGenericRepository<Guid, TEntity>
where TEntity : IEntity
{
}
}
31 changes: 31 additions & 0 deletions src/FluentCMS.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.7.34031.279
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCMS.Core", "FluentCMS.Core\FluentCMS.Core.csproj", "{4D5CE77A-A7C9-4B26-A9E3-0449DEB67F69}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FluentCMS.Repository.Abstractions", "FluentCMS.Repository.Abstractions\FluentCMS.Repository.Abstractions.csproj", "{39E3BFFD-44FD-4D18-92C4-EC324438933C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{4D5CE77A-A7C9-4B26-A9E3-0449DEB67F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{4D5CE77A-A7C9-4B26-A9E3-0449DEB67F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
{4D5CE77A-A7C9-4B26-A9E3-0449DEB67F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
{4D5CE77A-A7C9-4B26-A9E3-0449DEB67F69}.Release|Any CPU.Build.0 = Release|Any CPU
{39E3BFFD-44FD-4D18-92C4-EC324438933C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39E3BFFD-44FD-4D18-92C4-EC324438933C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{39E3BFFD-44FD-4D18-92C4-EC324438933C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{39E3BFFD-44FD-4D18-92C4-EC324438933C}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {2E9F4217-7A58-48A4-9850-84CD0CDA31DA}
EndGlobalSection
EndGlobal

0 comments on commit 689b862

Please sign in to comment.