private TransactionBdo MapTo(transaction t) { TransactionBdo transaction = null; if (t != null) { PaymentStatusIds paymentStatus = PaymentStatusIds.NotProcessed; PaymentSystems paymentSystem = PaymentSystems.None; int projectId = 0; int.TryParse(t.project_id, out projectId); Enum.TryParse(t.pay_system_id.ToString(), out paymentSystem); Enum.TryParse(t.payment_status_id.ToString(), out paymentStatus); transaction = new TransactionBdo { Id = t.id, IsPaymentProcessed = t.is_payment_processed, IsTestPayment = t.is_test_payment, RequestedAmount = t.requested_amount, RequestedCurrencyCode = t.requested_currency_code, PaidAmount = t.paid_amount, PaidCurrencyCode = t.paid_currency_code, PaidThrough = t.paid_through, PayerName = t.p_name, PayerLastName = t.p_lastname, PayerEmail = t.p_email, PayerPhone = t.p_phone, Remarks = t.remarks, ProjectId = projectId, PosId = t.pos_id, PosUserUid = t.pos_user_uid, PaySystemUid = t.pay_system_uid, ProductId = t.product_id, ProductUid = t.product_uid, OrderNr = t.order_nr, PaymentStatus = paymentStatus, PaymentSystem = paymentSystem, CreatedAt = t.created_at, PaySystemResponseAt = t.pay_system_response_at.HasValue ? t.pay_system_response_at.Value : DateTime.MinValue, ResponseFromPaymentSystem = t.response_from_payment }; } return(transaction); }
public IEnumerable <TransactionBdo> GetLastTransactions(int posId, int offset, int limit) { Logger.InfoFormat("Getting last transactions for POS ID: #{0}", posId); Logger.DebugFormat(" setting offset to: {0}", offset); Logger.DebugFormat(" setting limit to: {0}", limit); var list = new List <TransactionBdo>(); try { // TODO: validate offset and limit using (var db = new GiftServiceEntities()) { IQueryable <transaction> ts = db.transactions.OrderByDescending(x => x.id); if (posId > 0) { ts = ts.Where(x => x.pos_id == posId); } ts.Skip(offset).Take(limit); int projectId = 0; PaymentStatusIds paymentStatus = PaymentStatusIds.NotProcessed; PaymentSystems paymentSystem = PaymentSystems.None; foreach (var t in ts) { int.TryParse(t.project_id, out projectId); Enum.TryParse(t.pay_system_id.ToString(), out paymentSystem); Enum.TryParse(t.payment_status_id.ToString(), out paymentStatus); list.Add(new TransactionBdo { Id = t.id, IsPaymentProcessed = t.is_payment_processed, IsTestPayment = t.is_test_payment, RequestedAmount = t.requested_amount, RequestedCurrencyCode = t.requested_currency_code, PaidAmount = t.paid_amount, PaidCurrencyCode = t.paid_currency_code, PaidThrough = t.paid_through, PayerName = t.p_name, PayerLastName = t.p_lastname, PayerEmail = t.p_email, PayerPhone = t.p_phone, Remarks = t.remarks, ProjectId = projectId, PosId = t.pos_id, PosUserUid = t.pos_user_uid, PaySystemUid = t.pay_system_uid, OrderNr = t.order_nr, ProductId = t.product_id, ProductUid = t.product_uid, PaymentStatus = paymentStatus, PaymentSystem = paymentSystem, CreatedAt = t.created_at, PaySystemResponseAt = t.pay_system_response_at.HasValue ? t.pay_system_response_at.Value : DateTime.MinValue }); } } } catch (Exception ex) { Logger.Error("Erro getting last transactions", ex); throw; } return(list); }