kreta/Kreta.WebApi/Naplo/Kreta.Naplo.Domain/V2/Model/ResponseWrapper.cs
2024-03-13 00:33:46 +01:00

30 lines
1.1 KiB
C#

using System;
using System.Net;
using Kreta.BusinessLogic.Classes.MobileApi.Naplo.V2.Co;
namespace Kreta.Naplo.Domain.V2.Model
{
public sealed class ResponseWrapper<T> where T : class, new()
{
public HttpStatusCode StatusCode { get; set; }
public DateTime UtolsoSzinkronDatumUtc { get; set; }
public string Hash { get; set; }
public T Adatcsomag { get; set; }
private ResponseWrapper() { }
/// <summary>
/// Returns an ResponseWrapper Instance that has been converted from ResponseWrapperCO
/// </summary>
/// <typeparam name="TIn">Co Type</typeparam>
/// <param name="modelConverter">The modelConverter for Adatcsomag prop</param>
public static ResponseWrapper<T> Create<TIn>(ResponseWrapperCo<TIn> co, Converter<TIn, T> modelConverter) where TIn : class, new()
=> new ResponseWrapper<T>
{
StatusCode = co.StatusCode,
UtolsoSzinkronDatumUtc = co.UtolsoSzinkronDatumUtc,
Hash = co.Hash,
Adatcsomag = co.Adatcsomag != null ? modelConverter(co.Adatcsomag) : null
};
}
}