public Transaction CreateTransaction(CMSDataContext Db, decimal?amount = null) { if (!amount.HasValue) { amount = AmtToPay; } decimal?amtdue = null; if (Amtdue > 0) { amtdue = Amtdue - (amount ?? 0); } // var ss = m.ProcessType; var ti = new Transaction { First = First, MiddleInitial = MiddleInitial.Truncate(1) ?? "", Last = Last, Suffix = Suffix, Donate = Donate, Regfees = AmtToPay, Amt = amount, Amtdue = Math.Max((amtdue ?? 0), 0), Emails = Email, Testing = testing, Description = Description, OrgId = OrgId, Url = URL, TransactionGateway = OnlineRegModel.GetTransactionGateway(ProcessType)?.GatewayAccountName, Address = Address.Truncate(50), Address2 = Address2.Truncate(50), City = City, State = State, Country = Country, Zip = Zip, DatumId = DatumId, Phone = Phone.Truncate(20), OriginalId = OriginalId, Financeonly = FinanceOnly, TransactionDate = Util.Now, PaymentType = Type, LastFourCC = Type == PaymentType.CreditCard ? CreditCard.Last(4) : null, LastFourACH = Type == PaymentType.Ach ? Account.Last(4) : null }; CurrentDatabase.Transactions.InsertOnSubmit(ti); CurrentDatabase.SubmitChanges(); if (OriginalId == null) // first transaction { ti.OriginalId = ti.Id; } return(ti); }
public static Transaction CreateTransaction(CMSDataContext db, Transaction t, decimal?amount) { var amtdue = t.Amtdue - (amount ?? 0); var ti = new Transaction { Name = t.Name, First = t.First, MiddleInitial = t.MiddleInitial, Last = t.Last, Suffix = t.Suffix, Donate = t.Donate, Amtdue = amtdue, Amt = amount, Emails = Util.FirstAddress(t.Emails).Address, Testing = t.Testing, Description = t.Description, OrgId = t.OrgId, Url = t.Url, Address = t.Address, TransactionGateway = OnlineRegModel.GetTransactionGateway()?.GatewayAccountName, City = t.City, State = t.State, Zip = t.Zip, DatumId = t.DatumId, Phone = t.Phone, OriginalId = t.OriginalId ?? t.Id, Financeonly = t.Financeonly, TransactionDate = Util.Now, PaymentType = t.PaymentType, LastFourCC = t.LastFourCC, LastFourACH = t.LastFourACH }; db.Transactions.InsertOnSubmit(ti); db.SubmitChanges(); return(ti); }