public void Convert_collection_failed_transaction_entity_to_dto_should_work() { // Arrange List <FailedTransaction> entities = new List <FailedTransaction>(); for (int i = 0; i < 5; i++) { var entity = new FailedTransaction { TermsConsent = true, NewsletterOptin = true, CreatedDate = DateTimeOffset.UtcNow, ModifiedDate = DateTimeOffset.UtcNow }; entities.Add(entity); } // Act var dtos = _mapper.toDtos <FailedTransactionDto>(entities).ToList(); //Assert for (int i = 0; i < 5; i++) { Assert.AreEqual <bool>(dtos[i].TermsConsent, entities[i].TermsConsent); Assert.AreEqual <bool>(dtos[i].NewsletterOptin, entities[i].NewsletterOptin); } }
public virtual FailedTransaction InsertFailedTransaction(FailedTransaction entity) { FailedTransaction other = new FailedTransaction(); other = entity; if (entity.IsTransient()) { string sql = @"Insert into FailedTransaction ( [CustomerID] ,[OrderNumber] ,[OrderDate] ,[PaymentGateway] ,[PaymentMethod] ,[TransactionCommand] ,[TransactionResult] ,[ExtensionData] ,[MaxMindDetails] ,[IPAddress] ,[MaxMindFraudScore] ,[RecurringSubscriptionID] ,[CustomerEMailed] ) Values ( @CustomerID , @OrderNumber , @OrderDate , @PaymentGateway , @PaymentMethod , @TransactionCommand , @TransactionResult , @ExtensionData , @MaxMindDetails , @IPAddress , @MaxMindFraudScore , @RecurringSubscriptionID , @CustomerEMailed ); Select scope_identity()" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@DBRecNo", entity.DbRecNo) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@OrderNumber", entity.OrderNumber) , new SqlParameter("@OrderDate", entity.OrderDate) , new SqlParameter("@PaymentGateway", entity.PaymentGateway ?? (object)DBNull.Value) , new SqlParameter("@PaymentMethod", entity.PaymentMethod ?? (object)DBNull.Value) , new SqlParameter("@TransactionCommand", entity.TransactionCommand ?? (object)DBNull.Value) , new SqlParameter("@TransactionResult", entity.TransactionResult ?? (object)DBNull.Value) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , new SqlParameter("@MaxMindDetails", entity.MaxMindDetails ?? (object)DBNull.Value) , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value) , new SqlParameter("@MaxMindFraudScore", entity.MaxMindFraudScore ?? (object)DBNull.Value) , new SqlParameter("@RecurringSubscriptionID", entity.RecurringSubscriptionId) , new SqlParameter("@CustomerEMailed", entity.CustomerEmailed) }; var identity = SqlHelper.ExecuteScalar(this.ConnectionString, CommandType.Text, sql, parameterArray); if (identity == DBNull.Value) { throw new DataException("Identity column was null as a result of the insert operation."); } return(GetFailedTransaction(Convert.ToInt32(identity))); } return(entity); }
public void HandleFailedTransaction(FailedTransaction transaction) { if (transaction == null) { throw new ArgumentNullException(nameof(transaction)); } _failedTransactions.Add(transaction); SendTransactionsBatchIfNeeded(); }
public virtual FailedTransaction UpdateFailedTransaction(FailedTransaction entity) { if (entity.IsTransient()) { return(entity); } FailedTransaction other = GetFailedTransaction(entity.DbRecNo); if (entity.Equals(other)) { return(entity); } string sql = @"Update FailedTransaction set [CustomerID]=@CustomerID , [OrderNumber]=@OrderNumber , [OrderDate]=@OrderDate , [PaymentGateway]=@PaymentGateway , [PaymentMethod]=@PaymentMethod , [TransactionCommand]=@TransactionCommand , [TransactionResult]=@TransactionResult , [ExtensionData]=@ExtensionData , [MaxMindDetails]=@MaxMindDetails , [IPAddress]=@IPAddress , [MaxMindFraudScore]=@MaxMindFraudScore , [RecurringSubscriptionID]=@RecurringSubscriptionID , [CustomerEMailed]=@CustomerEMailed where DBRecNo=@DBRecNo" ; SqlParameter[] parameterArray = new SqlParameter[] { new SqlParameter("@DBRecNo", entity.DbRecNo) , new SqlParameter("@CustomerID", entity.CustomerId) , new SqlParameter("@OrderNumber", entity.OrderNumber) , new SqlParameter("@OrderDate", entity.OrderDate) , new SqlParameter("@PaymentGateway", entity.PaymentGateway ?? (object)DBNull.Value) , new SqlParameter("@PaymentMethod", entity.PaymentMethod ?? (object)DBNull.Value) , new SqlParameter("@TransactionCommand", entity.TransactionCommand ?? (object)DBNull.Value) , new SqlParameter("@TransactionResult", entity.TransactionResult ?? (object)DBNull.Value) , new SqlParameter("@ExtensionData", entity.ExtensionData ?? (object)DBNull.Value) , new SqlParameter("@MaxMindDetails", entity.MaxMindDetails ?? (object)DBNull.Value) , new SqlParameter("@IPAddress", entity.IpAddress ?? (object)DBNull.Value) , new SqlParameter("@MaxMindFraudScore", entity.MaxMindFraudScore ?? (object)DBNull.Value) , new SqlParameter("@RecurringSubscriptionID", entity.RecurringSubscriptionId) , new SqlParameter("@CustomerEMailed", entity.CustomerEmailed) }; SqlHelper.ExecuteNonQuery(this.ConnectionString, CommandType.Text, sql, parameterArray); return(GetFailedTransaction(entity.DbRecNo)); }
public void Convert_failed_transaction_entity_to_dto_should_work() { // Arrange var entity = new FailedTransaction { TermsConsent = true, NewsletterOptin = true, CreatedDate = DateTimeOffset.UtcNow, ModifiedDate = DateTimeOffset.UtcNow }; // Act var dto = _mapper.toDto <FailedTransactionDto>(entity); //Assert Assert.AreEqual <bool>(dto.TermsConsent, entity.TermsConsent); Assert.AreEqual <bool>(dto.NewsletterOptin, entity.NewsletterOptin); }
public virtual FailedTransaction FailedTransactionFromDataRow(DataRow dr) { if (dr == null) { return(null); } FailedTransaction entity = new FailedTransaction(); entity.DbRecNo = (System.Int32)dr["DBRecNo"]; entity.CustomerId = (System.Int32)dr["CustomerID"]; entity.OrderNumber = (System.Int32)dr["OrderNumber"]; entity.OrderDate = (System.DateTime)dr["OrderDate"]; entity.PaymentGateway = dr["PaymentGateway"].ToString(); entity.PaymentMethod = dr["PaymentMethod"].ToString(); entity.TransactionCommand = dr["TransactionCommand"].ToString(); entity.TransactionResult = dr["TransactionResult"].ToString(); entity.ExtensionData = dr["ExtensionData"].ToString(); entity.MaxMindDetails = dr["MaxMindDetails"].ToString(); entity.IpAddress = dr["IPAddress"].ToString(); entity.MaxMindFraudScore = dr["MaxMindFraudScore"] == DBNull.Value?(System.Decimal?)null : (System.Decimal?)dr["MaxMindFraudScore"]; entity.RecurringSubscriptionId = dr["RecurringSubscriptionID"].ToString(); entity.CustomerEmailed = (System.Byte)dr["CustomerEMailed"]; return(entity); }
public virtual FailedTransaction DeleteFailedTransaction(FailedTransaction entity) { this.DeleteFailedTransaction(entity.DbRecNo); return(entity); }
public FailedTransaction InsertFailedTransaction(FailedTransaction entity) { return(_iFailedTransactionRepository.InsertFailedTransaction(entity)); }
public FailedTransaction UpdateFailedTransaction(FailedTransaction entity) { return(_iFailedTransactionRepository.UpdateFailedTransaction(entity)); }
public static FailedTransactionDto toDto(this FailedTransaction failedTransaction) => AutoMapper.Mapper.Map <FailedTransaction, FailedTransactionDto>(failedTransaction);