Users page and users service

This commit is contained in:
Andre Beging
2022-01-24 10:15:33 +01:00
parent 3cfac1a12d
commit 33c631aaf6
10 changed files with 380 additions and 30 deletions

View File

@@ -0,0 +1,138 @@
namespace FoodsharingSiegen.Contracts
{
#region OperationResult<T>
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Encapsulates the result of an operation. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
///
/// <typeparam name="T"> Generic type parameter. </typeparam>
////////////////////////////////////////////////////////////////////////////////////////////////////
public class OperationResult<T>
{
#region Public Properties
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Gets or sets the exception. </summary>
///
/// <value> The exception. </value>
////////////////////////////////////////////////////////////////////////////////////////////////////
public Exception? Exception { get; set; }
/// <summary> Returns an error message if the exception is set </summary>
public string ErrorMessage
{
get
{
if (Success) return string.Empty;
return Exception != null ? Exception.GetBaseException().Message : "Fehler";
}
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Gets or sets a value indicating whether the success. </summary>
///
/// <value> True if success, false if not. </value>
////////////////////////////////////////////////////////////////////////////////////////////////////
public bool Success { get; set; } = true;
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Gets or sets the data. </summary>
///
/// <value> The data. </value>
////////////////////////////////////////////////////////////////////////////////////////////////////
public T? Data { get; set; }
#endregion Public Properties
#region Constructors
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Constructor. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
///
/// <param name="exception"> The exception. </param>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult(Exception exception)
{
Success = false;
Exception = exception;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Constructor. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
///
/// <param name="data"> The data. </param>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult(T data)
{
Data = data;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Default constructor. </summary>
///
/// <remarks> A Beging, 22.10.2021. </remarks>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult()
{
}
#endregion Constructors
}
#endregion OperationResult<T>
#region OperationResult
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Encapsulates the result of an operation. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
////////////////////////////////////////////////////////////////////////////////////////////////////
public class OperationResult : OperationResult<object>
{
#region Constructors
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Constructor. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
///
/// <param name="exception"> The exception. </param>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult(Exception exception) : base(exception)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Constructor. </summary>
///
/// <remarks> A Beging, 20.10.2021. </remarks>
///
/// <param name="data"> True to data. </param>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult(bool data) : base(data)
{
}
////////////////////////////////////////////////////////////////////////////////////////////////////
/// <summary> Default constructor. </summary>
///
/// <remarks> A Beging, 22.10.2021. </remarks>
////////////////////////////////////////////////////////////////////////////////////////////////////
public OperationResult()
{
}
#endregion Constructors
}
#endregion OperationResult
}