-
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.
- Loading branch information
Showing
22 changed files
with
346 additions
and
368 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,11 @@ | ||
using System; | ||
using YuckQi.Domain.ValueObjects.Abstract; | ||
|
||
namespace YuckQi.Domain.Services.Models | ||
namespace YuckQi.Domain.Services.Models; | ||
|
||
public class TypeSearchCriteria : IPage | ||
{ | ||
public class TypeSearchCriteria : IPage | ||
{ | ||
public String Name { get; set; } | ||
public Int32 PageNumber { get; set; } | ||
public Int32 PageSize { get; set; } | ||
} | ||
public String Name { get; set; } | ||
public Int32 PageNumber { get; set; } | ||
public Int32 PageSize { get; set; } | ||
} |
53 changes: 26 additions & 27 deletions
53
src/YuckQi.Domain.Validation/Exceptions/DomainValidationException.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,48 +1,47 @@ | ||
using System; | ||
using System.Linq; | ||
|
||
namespace YuckQi.Domain.Validation.Exceptions | ||
{ | ||
public class DomainValidationException : ApplicationException | ||
{ | ||
#region Constants | ||
namespace YuckQi.Domain.Validation.Exceptions; | ||
|
||
private const String DefaultErrorMessage = "Something went wrong."; | ||
public class DomainValidationException : ApplicationException | ||
{ | ||
#region Constants | ||
|
||
#endregion | ||
private const String DefaultErrorMessage = "Something went wrong."; | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
public Result Result { get; } | ||
#region Properties | ||
|
||
#endregion | ||
public Result Result { get; } | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
public DomainValidationException(Result result) : base(GetErrorMessage(result)) | ||
{ | ||
Result = result; | ||
} | ||
#region Constructors | ||
|
||
#endregion | ||
public DomainValidationException(Result result) : base(GetErrorMessage(result)) | ||
{ | ||
Result = result; | ||
} | ||
|
||
#endregion | ||
|
||
#region Supporting Methods | ||
|
||
private static String GetErrorMessage(Result result) | ||
{ | ||
if (result == null) | ||
return DefaultErrorMessage; | ||
#region Supporting Methods | ||
|
||
var count = result.Detail.Count(t => t.Type == ResultType.Error); | ||
var noun = count == 1 ? "error" : "errors"; | ||
var message = $"Domain model has {count} {noun} after validation."; | ||
private static String GetErrorMessage(Result result) | ||
{ | ||
if (result == null) | ||
return DefaultErrorMessage; | ||
|
||
return message; | ||
} | ||
var count = result.Detail.Count(t => t.Type == ResultType.Error); | ||
var noun = count == 1 ? "error" : "errors"; | ||
var message = $"Domain model has {count} {noun} after validation."; | ||
|
||
#endregion | ||
return message; | ||
} | ||
|
||
#endregion | ||
} |
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,50 +1,49 @@ | ||
using System; | ||
|
||
namespace YuckQi.Domain.Validation | ||
namespace YuckQi.Domain.Validation; | ||
|
||
public readonly struct ResultCode | ||
{ | ||
public readonly struct ResultCode | ||
{ | ||
#region Private Members | ||
#region Private Members | ||
|
||
private readonly String _code; | ||
private readonly String _code; | ||
|
||
#endregion | ||
#endregion | ||
|
||
|
||
#region Implicit Operators | ||
#region Implicit Operators | ||
|
||
public static implicit operator String(ResultCode resultCode) => resultCode._code; | ||
public static implicit operator String(ResultCode resultCode) => resultCode._code; | ||
|
||
#endregion | ||
#endregion | ||
|
||
|
||
#region Constants | ||
#region Constants | ||
|
||
public static readonly ResultCode ConstraintViolation = new ResultCode(nameof(ConstraintViolation)); | ||
public static readonly ResultCode InvalidRequestDetail = new ResultCode(nameof(InvalidRequestDetail)); | ||
public static readonly ResultCode NotFound = new ResultCode(nameof(NotFound)); | ||
public static readonly ResultCode ConstraintViolation = new(nameof(ConstraintViolation)); | ||
public static readonly ResultCode InvalidRequestDetail = new(nameof(InvalidRequestDetail)); | ||
public static readonly ResultCode NotFound = new(nameof(NotFound)); | ||
|
||
#endregion | ||
#endregion | ||
|
||
|
||
#region Constructors | ||
#region Constructors | ||
|
||
public ResultCode(String code) | ||
{ | ||
_code = code; | ||
} | ||
public ResultCode(String code) | ||
{ | ||
_code = code; | ||
} | ||
|
||
#endregion | ||
#endregion | ||
|
||
|
||
#region Public Methods | ||
#region Public Methods | ||
|
||
public override Boolean Equals(Object obj) => obj != null && String.Equals(this, (ResultCode) obj); | ||
public override Boolean Equals(Object obj) => obj != null && String.Equals(this, (ResultCode) obj); | ||
|
||
public override Int32 GetHashCode() => _code.GetHashCode(); | ||
public override Int32 GetHashCode() => _code.GetHashCode(); | ||
|
||
public override String ToString() => _code; | ||
public override String ToString() => _code; | ||
|
||
#endregion | ||
} | ||
#endregion | ||
} |
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,46 +1,45 @@ | ||
using System; | ||
|
||
namespace YuckQi.Domain.Validation | ||
{ | ||
public class ResultDetail | ||
{ | ||
#region Private Members | ||
namespace YuckQi.Domain.Validation; | ||
|
||
private readonly ResultCode _code; | ||
public class ResultDetail | ||
{ | ||
#region Private Members | ||
|
||
#endregion | ||
private readonly ResultCode _code; | ||
|
||
#endregion | ||
|
||
#region Constants | ||
|
||
public static ResultDetail ConstraintViolation<T, TKey>(TKey key, String message = null) where TKey : struct => new ResultDetail(ResultCode.ConstraintViolation, ResultMessage.ConstraintConflict<T, TKey>(key, message)); | ||
public static ResultDetail NotFound<T, TKey>(TKey key, String message = null) where TKey : struct => new ResultDetail(ResultCode.NotFound, ResultMessage.NotFound<T, TKey>(key, message)); | ||
#region Constants | ||
|
||
#endregion | ||
public static ResultDetail ConstraintViolation<T, TKey>(TKey key, String message = null) where TKey : struct => new(ResultCode.ConstraintViolation, ResultMessage.ConstraintConflict<T, TKey>(key, message)); | ||
public static ResultDetail NotFound<T, TKey>(TKey key, String message = null) where TKey : struct => new(ResultCode.NotFound, ResultMessage.NotFound<T, TKey>(key, message)); | ||
|
||
#endregion | ||
|
||
#region Properties | ||
|
||
public ResultMessage Message { get; } | ||
public String Property { get; } | ||
public ResultType Type { get; } | ||
#region Properties | ||
|
||
public String Code => _code; | ||
public ResultMessage Message { get; } | ||
public String Property { get; } | ||
public ResultType Type { get; } | ||
|
||
#endregion | ||
public String Code => _code; | ||
|
||
#endregion | ||
|
||
#region Constructors | ||
|
||
public ResultDetail(ResultCode code, ResultMessage message, String property = null, ResultType type = ResultType.Error) | ||
{ | ||
_code = code; | ||
#region Constructors | ||
|
||
Message = message; | ||
Property = property; | ||
Type = type; | ||
} | ||
public ResultDetail(ResultCode code, ResultMessage message, String property = null, ResultType type = ResultType.Error) | ||
{ | ||
_code = code; | ||
|
||
#endregion | ||
Message = message; | ||
Property = property; | ||
Type = type; | ||
} | ||
|
||
#endregion | ||
} |
Oops, something went wrong.