Skip to content

Commit

Permalink
Merge pull request #325 from BoBoBaSs84/refactor/do-some-refactoring
Browse files Browse the repository at this point in the history
Refactor/do some refactoring
  • Loading branch information
BoBoBaSs84 authored Dec 19, 2023
2 parents c92ad6a + b49ef54 commit 3dee2f0
Show file tree
Hide file tree
Showing 14 changed files with 43 additions and 260 deletions.
6 changes: 3 additions & 3 deletions EF.Core.Database.Adapter.sln
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Presentation", "src\Present
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ApplicationTests", "tests\ApplicationTests\ApplicationTests.csproj", "{AE0855E2-9F01-466D-BAFD-59C4DD9A27D7}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{41C26948-0A82-496E-BACF-731564C24204}"
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{1989021F-F438-4654-98BC-445B5B0BD7EB}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
.filenesting.json = .filenesting.json
Expand Down Expand Up @@ -95,8 +95,8 @@ Global
{AE0855E2-9F01-466D-BAFD-59C4DD9A27D7} = {98B824A8-BA26-4E8E-A8F4-2BFF5E0B6DB8}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {8C2C98A4-09CD-4243-9E78-870E54AF080A}
RESX_SortFileContentOnSave = True
RESX_SaveFilesImmediatelyUponChange = True
RESX_SortFileContentOnSave = True
SolutionGuid = {8C2C98A4-09CD-4243-9E78-870E54AF080A}
EndGlobalSection
EndGlobal
30 changes: 10 additions & 20 deletions src/Application/Contracts/Responses/Base/EnumeratorResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,42 +7,32 @@ namespace Application.Contracts.Responses.Base;
/// <summary>
/// The <see langword="abstract"/> enumerator response class.
/// </summary>
public abstract class EnumeratorResponse<T> where T : struct, IComparable, IFormattable, IConvertible
/// <remarks>
/// Initilizes an instance of the enumerator response class.
/// </remarks>
/// <param name="enumValue">The enumerator value.</param>
public abstract class EnumeratorResponse<T>(T enumValue) where T : struct, IComparable, IFormattable, IConvertible
{
private readonly Type _type;
/// <summary>
/// Initilizes an instance of the enumerator response class.
/// </summary>
/// <param name="enumValue">The enumerator value.</param>
public EnumeratorResponse(T enumValue)
{
Value = enumValue;
Name = enumValue.GetName();
ShortName = enumValue.GetShortName();
Description = enumValue.GetDescription();
_type = enumValue.GetType();
}

/// <summary>
/// The enumerator value.
/// </summary>
public T Value { get; }
/// </summary>
public T Value { get; } = enumValue;

/// <summary>
/// The enumerator name.
/// </summary>
[DataType(DataType.Text)]
public string Name { get; }
public string Name { get; } = enumValue.GetName();

/// <summary>
/// The enumerator short name.
/// </summary>
[DataType(DataType.Text)]
public string ShortName { get; }
public string ShortName { get; } = enumValue.GetShortName();

/// <summary>
/// The enumerator description.
/// </summary>
[DataType(DataType.Text)]
public string Description { get; }
public string Description { get; } = enumValue.GetDescription();
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ namespace Application.Contracts.Responses.Enumerators;
/// <summary>
/// The attendance type response class.
/// </summary>
public sealed class AttendanceTypeResponse : EnumeratorResponse<AttendanceType>
{
/// <summary>
/// Initilizes an instance of the attendance type response class.
/// </summary>
/// <inheritdoc/>
public AttendanceTypeResponse(AttendanceType enumValue) : base(enumValue)
{ }
}
/// <remarks>
/// Initilizes an instance of the attendance type response class.
/// </remarks>
/// <inheritdoc/>
public sealed class AttendanceTypeResponse(AttendanceType enumValue) : EnumeratorResponse<AttendanceType>(enumValue)
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ namespace Application.Contracts.Responses.Enumerators;
/// <summary>
/// The card type response class.
/// </summary>
public sealed class CardTypeResponse : EnumeratorResponse<CardType>
{
/// <summary>
/// Initilizes an instance of the card type response class.
/// </summary>
/// <inheritdoc/>
public CardTypeResponse(CardType enumValue) : base(enumValue)
{ }
}
/// <remarks>
/// Initilizes an instance of the card type response class.
/// </remarks>
/// <inheritdoc/>
public sealed class CardTypeResponse(CardType enumValue) : EnumeratorResponse<CardType>(enumValue)
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ namespace Application.Contracts.Responses.Enumerators;
/// <summary>
/// The role type response class.
/// </summary>
public sealed class RoleTypeResponse : EnumeratorResponse<RoleType>
{
/// <summary>
/// Initilizes an instance of the role type response class.
/// </summary>
/// <inheritdoc/>
public RoleTypeResponse(RoleType enumValue) : base(enumValue)
{ }
}
/// <remarks>
/// Initilizes an instance of the role type response class.
/// </remarks>
/// <inheritdoc/>
public sealed class RoleTypeResponse(RoleType enumValue) : EnumeratorResponse<RoleType>(enumValue)
{ }
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ namespace Application.Contracts.Responses.Enumerators;
/// <summary>
/// The work day type response class.
/// </summary>
public sealed class WorkDayTypeResponse : EnumeratorResponse<WorkDayTypes>
{
/// <summary>
/// Initilizes an instance of the work day type response class.
/// </summary>
/// <inheritdoc/>
public WorkDayTypeResponse(WorkDayTypes enumValue) : base(enumValue)
{ }
}
/// <remarks>
/// Initilizes an instance of the work day type response class.
/// </remarks>
/// <inheritdoc/>
public sealed class WorkDayTypeResponse(WorkDayTypes enumValue) : EnumeratorResponse<WorkDayTypes>(enumValue)
{ }
27 changes: 0 additions & 27 deletions src/Domain/Enumerators/AttendanceType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,6 @@ public enum AttendanceType
Description = nameof(RESX.AttendanceType_Holiday_Description))]
HOLIDAY = 1,
/// <summary>
/// The week day attendance type.
/// </summary>
[Display(ResourceType = typeof(RESX),
Name = nameof(RESX.AttendanceType_Weekday_Name),
ShortName = nameof(RESX.AttendanceType_Weekday_ShortName),
Description = nameof(RESX.AttendanceType_Weekday_Description))]
[Obsolete("Do not use this one any more, will be removed in the future.")]
WEEKDAY,
/// <summary>
/// The week end day attendance type.
/// </summary>
[Display(ResourceType = typeof(RESX),
Name = nameof(RESX.AttendanceType_WeekendDay_Name),
ShortName = nameof(RESX.AttendanceType_WeekendDay_ShortName),
Description = nameof(RESX.AttendanceType_WeekendDay_Description))]
[Obsolete("Do not use this one any more, will be removed in the future.")]
WEEKENDDAY,
/// <summary>
/// The work day attendance type.
/// </summary>
[Display(ResourceType = typeof(RESX),
Expand All @@ -44,15 +26,6 @@ public enum AttendanceType
Description = nameof(RESX.AttendanceType_Workday_Description))]
WORKDAY,
/// <summary>
/// The week end work day attendance type.
/// </summary>
[Display(ResourceType = typeof(RESX),
Name = nameof(RESX.AttendanceType_WeekendWorkday_Name),
ShortName = nameof(RESX.AttendanceType_WeekendWorkday_ShortName),
Description = nameof(RESX.AttendanceType_WeekendWorkday_Description))]
[Obsolete("Do not use this one any more, will be removed in the future.")]
WEEKENDWORKDAY,
/// <summary>
/// The absence attendance type.
/// </summary>
[Display(ResourceType = typeof(RESX),
Expand Down
37 changes: 0 additions & 37 deletions src/Domain/Helpers/StringWriterWithEncoding.cs

This file was deleted.

81 changes: 0 additions & 81 deletions src/Domain/Properties/EnumeratorResources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

27 changes: 0 additions & 27 deletions src/Domain/Properties/EnumeratorResources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -225,33 +225,6 @@
<data name="AttendanceType.VacationBlock.ShortName" xml:space="preserve">
<value>VB</value>
</data>
<data name="AttendanceType.Weekday.Description" xml:space="preserve">
<value>A weekday day means any day except any Saturday, any Sunday, or any day which is a legal holiday.</value>
</data>
<data name="AttendanceType.Weekday.Name" xml:space="preserve">
<value>Weekday</value>
</data>
<data name="AttendanceType.Weekday.ShortName" xml:space="preserve">
<value>WD</value>
</data>
<data name="AttendanceType.WeekendDay.Description" xml:space="preserve">
<value>Generally refers to the period between the end of a usual work week and the beginning of the new work week.</value>
</data>
<data name="AttendanceType.WeekendDay.Name" xml:space="preserve">
<value>Weekend day</value>
</data>
<data name="AttendanceType.WeekendDay.ShortName" xml:space="preserve">
<value>WE</value>
</data>
<data name="AttendanceType.WeekendWorkday.Description" xml:space="preserve">
<value>Weekend work means working on days that are usually non-working days.</value>
</data>
<data name="AttendanceType.WeekendWorkday.Name" xml:space="preserve">
<value>Weekend workday</value>
</data>
<data name="AttendanceType.WeekendWorkday.ShortName" xml:space="preserve">
<value>WW</value>
</data>
<data name="AttendanceType.Workday.Description" xml:space="preserve">
<value>Day on which professional work is performed or is to be performed.</value>
</data>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ internal abstract class GenericRepository<TEntity> : IGenericRepository<TEntity>
/// Any context that inherits from <see cref="DbContext"/> should work.
/// </remarks>
/// <param name="dbContext">The database context to work with.</param>
public GenericRepository(DbContext dbContext)
protected GenericRepository(DbContext dbContext)
{
_dbContext = dbContext;
_dbSet = dbContext.Set<TEntity>();
Expand Down
2 changes: 1 addition & 1 deletion src/Infrastructure/Persistence/RepositoryContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public sealed partial class RepositoryContext : IdentityDbContext<UserModel, Rol
private readonly ILoggerService<RepositoryContext> _logger;

private static readonly Action<ILogger, Exception?> LogException =
LoggerMessage.Define(LogLevel.Error, 0, "Exception occured.");
LoggerMessage.Define(LogLevel.Error, 0, "Exception occured.");

/// <summary>
/// Initializes a new instance of the application repository context class.
Expand Down
4 changes: 4 additions & 0 deletions tests/ApplicationTests/ApplicationTestBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using Infrastructure.Installer;
using Infrastructure.Persistence;

using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

Expand All @@ -33,6 +34,9 @@ public static void AssemblyInitialize(TestContext context)
s_repositoryContext = host.Services.GetRequiredService<RepositoryContext>();

s_repositoryContext.Database.EnsureCreated();

var sqlScript = s_repositoryContext.Database.GenerateCreateScript();
File.WriteAllText("CreateScript.sql", sqlScript);

DataSeed();
}
Expand Down
Loading

0 comments on commit 3dee2f0

Please sign in to comment.