public static PaymentReceiptDto ToDto(this PaymentReceipt e) { if (e == null) { return(null); } var res = new PaymentReceiptDto(); res.Id = e.Id; res.IdCustomer = e.IdCustomer; res.PaymentDate = e.PaymentDate; res.IssueDate = e.IssueDate; res.ReceiptPath = e.ReceiptPath; res.CostAmount = e.CostAmount; res.Name = e.Name; res.Description = e.Description; res.Customer = e.Customer.ToDto(false); res.InvoiceNumber = e.InvoiceNumber; res.PaymentReceiptDetails = e.PaymentReceiptDetails.OrderByDescending(x => x.XCreateDate).Select(x => x.ToDto()).ToArray(); res.CustomerAddress = e.CustomerAddress; res.CustomerFiscalCode = e.CustomerFiscalCode; res.CustomerName = e.CustomerName; res.CreditNote = e.CreditNotes.Count() > 0 ? e.CreditNotes.ToArray()[0].ToDto() : null; res.IssuedBy = e.IssuedBy; res.Owner = e.Owner != null?e.Owner.ToDto() : null; res.PaymentType = e.PaymentType; return(res); }
/// <summary> /// Map IServiceResult<OrderDto> into IServiceResult<PaymentReceiptDto> /// and return it in respone /// </summary> private static IServiceResult <PaymentReceiptDto> Map(IServiceResult <OrderDto> gatewayResponseResult) { PaymentReceiptDto dto = null; if (gatewayResponseResult.StatusCode == HttpStatusCode.OK) { dto = new PaymentReceiptDto() { Amount = gatewayResponseResult.Dto.Amount, Description = gatewayResponseResult.Dto.Description, OrderNumber = gatewayResponseResult.Dto.OrderNumber, PaymentDate = DateTime.UtcNow, UserId = gatewayResponseResult.Dto.UserId }; } return(new ServiceResult <PaymentReceiptDto>(dto, gatewayResponseResult.Error, gatewayResponseResult.StatusCode)); }