2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2026-06-13 14:38:43 +00:00
This commit is contained in:
2026-06-08 16:15:57 +03:00
parent 8143da2eee
commit 340798a5fa
111 changed files with 20647 additions and 27 deletions
@@ -0,0 +1,87 @@
using System;
using Esiur.Resource;
using Esiur.Core;
using Esiur.Data;
using Esiur.Protocol;
namespace RPC.EsiurTest
{
[TypeId("f172196340298b8586fed434c72bc158")]
[Export]
public class Payment : IRecord
{
[Annotation("Double")]
public double Amount { get; set; }
[Annotation("Currency")]
public RPC.EsiurTest.Currency Currency { get; set; }
[Annotation("Nullable`1?")]
public double? Fee { get; set; }
[Annotation("PaymentMethod")]
public RPC.EsiurTest.PaymentMethod Method { get; set; }
[Annotation("String")]
public string Reference { get; set; }
[Annotation("DateTime")]
public DateTime Timestamp { get; set; }
public SharedModel.Payment ToShared()
{
return new SharedModel.Payment()
{
Amount = Amount,
Currency = Enum.Parse<SharedModel.Currency>(Currency.ToString(), true),
Method = Enum.Parse<SharedModel.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp,
Fee = Fee,
};
}
public Echo.ThriftModel.Payment ToThrift()
{
var rt= new Echo.ThriftModel.Payment()
{
Amount = Amount,
Currency = Enum.Parse<Echo.ThriftModel.Currency>(Currency.ToString(), true),
Method = Enum.Parse<Echo.ThriftModel.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp.Ticks,
};
if (Fee != null)
rt.Fee = Fee.Value;
return rt;
}
public Echo.Model.Grpc.Payment ToGrpc()
{
return new Echo.Model.Grpc.Payment()
{
Amount = Amount,
Currency = Enum.Parse<Echo.Model.Grpc.Currency>(Currency.ToString(), true),
Fee = Fee ?? 0,
Method = Enum.Parse<Echo.Model.Grpc.PaymentMethod>(Method.ToString(), true),
Reference = Reference,
Timestamp = Timestamp.Ticks,
};
}
public override bool Equals(object? obj)
{
var other = obj as Payment;
if (other == null) return false;
if (Method != other.Method) return false;
if (Amount != other.Amount) return false;
if (Reference != other.Reference) return false;
if (Fee != other.Fee) return false;
return true;
}
}
}