public void MultibuttonAddClick() { if (IngridValidate()) { emptyalltextboxes(); totaltransactions++; switch (TabStatus) { case 0: transaction.type = TransactionType.Credit; ActualStatus.Content = "Credit Transaction Added ... Total :" + totaltransactions.ToString(); break; case 1: transaction.type = TransactionType.Debit; ActualStatus.Content = "Debit Transaction Added ..." + totaltransactions.ToString(); break; case 2: transaction.type = TransactionType.Rate; ActualStatus.Content = "Rate Transaction Added ..." + totaltransactions.ToString(); break; } input.transactions.Add(transaction); transaction = new InputTransaction(); } else { System.Windows.MessageBox.Show("Enter Correct Details"); ActualStatus.Content = "Validation failed ..."; } }
public IOInputContinue(InputTransaction <TOriginalInput> transaction) : base(transaction) { }
private Input TestInput() { Input testinput = new Input(); testinput.transactions = new List<InputTransaction>(); testinput.endDate = new DateTime(2007, 11, 3); testinput.principal = 1240000; testinput.startDate = new DateTime(2007, 8, 1); testinput.startRate = 14.75; InputTransaction it = new InputTransaction(); it.type = TransactionType.Credit; it.amount = 10000; it.date = new DateTime(2007, 8, 10); testinput.transactions.Add(it); it = new InputTransaction(); it.type = TransactionType.Credit; it.amount = 10000; it.date = new DateTime(2007, 8, 18); testinput.transactions.Add(it); it = new InputTransaction(); it.type = TransactionType.Credit; it.amount = 10000; it.date = new DateTime(2007, 8, 27); testinput.transactions.Add(it); return testinput; }
public OutputVoidContinueExecute(InputTransaction <TOriginalInput> transaction) : base(transaction) { }
private void GlowNext_Click(object sender, RoutedEventArgs e) { transaction = new InputTransaction(); if (OutgridValidate()) { OutGridCHANGER(false); InGridCHANGER(true); GreenTabCHANGER(true); ActualStatus.Content = "Waiting for transaction details ..."; System.Windows.Controls.TabItem i =(System.Windows.Controls.TabItem)GreenTab.Items[0]; i.Focus(); } else System.Windows.MessageBox.Show("Enter Correct Details"); }
/// <inheritdoc /> public Transaction UpdateTransaction(int id, InputTransaction input) { this.validator.Description(input.Description); var date = this.validator.DateString(input.DateString, "date"); var type = this.GetTransactionType(input.CategoryId, input.ReceivingAccountId, input.Amount); this.validator.Splits(this.splitwiseContext, input.PaymentRequests, input.SplitwiseSplits, type, input.Amount); return(this.ConcurrentInvoke(() => { var processor = new TransactionProcessor(this.Context, this.splitwiseContext); var entity = this.Context.Transactions.GetEntity(id); if (!entity.FullyEditable) { throw new ValidationException("This transaction should be updated in Splitwise."); } this.validator.AccountType(entity.Account.Type); if (entity.ReceivingAccount != null) { this.validator.AccountType(entity.ReceivingAccount.Type); } if (type != entity.Type) { throw new ValidationException("Changing the type of transaction is not possible."); } var account = this.Context.Accounts.GetEntity(input.AccountId, false); this.validator.AccountType(account.Type); var category = input.CategoryId.Select(cId => this.Context.Categories.GetEntity(cId, false)); var receivingAccount = input.ReceivingAccountId.Select(aId => this.Context.Accounts.GetEntity(aId, false)); if (receivingAccount.IsSome) { this.validator.AccountType(receivingAccount.Value.Type); if (receivingAccount.Value.Id == account.Id) { throw new ValidationException("Sender account can not be the same as receiver account."); } } // Verify a Splitwise account exists when adding providing splits. if (input.SplitwiseSplits.Any()) { this.Context.Accounts.GetSplitwiseEntity(); } processor.RevertIfProcessed(entity); entity.AccountId = input.AccountId; entity.Account = account; entity.Description = input.Description; entity.Date = date; entity.Amount = input.Amount; entity.CategoryId = input.CategoryId.ToNullable(); entity.Category = category.ToNullIfNone(); entity.ReceivingAccountId = input.ReceivingAccountId.ToNullable(); entity.ReceivingAccount = receivingAccount.ToNullIfNone(); entity.SplitDetails = input.SplitwiseSplits.Select(s => s.ToSplitDetailEntity()).ToList(); var existingPaymentRequestIds = input.PaymentRequests .SelectSome(pr => pr.Id) .ToSet(); var existingPaymentRequests = entity.PaymentRequests .Where(pr => existingPaymentRequestIds.Contains(pr.Id)) .ToDictionary(pr => pr.Id); var updatedPaymentRequests = new List <PaymentRequestEntity>(); foreach (var inputPr in input.PaymentRequests) { var updatedPr = inputPr.Id .Select(prId => existingPaymentRequests[prId]) .ValueOrElse(new PaymentRequestEntity()); if (updatedPr.PaidCount > inputPr.Count) { throw new ValidationException("A payment request can not be updated resulting in more payments than requested."); } updatedPr.Amount = inputPr.Amount; updatedPr.Count = inputPr.Count; updatedPr.Name = inputPr.Name; updatedPaymentRequests.Add(updatedPr); } var updatedPaymentRequestIds = updatedPaymentRequests.Select(pr => pr.Id).ToSet(); var removedPaymentRequests = entity.PaymentRequests.Where(pr => !updatedPaymentRequestIds.Contains(pr.Id)); this.Context.PaymentRequests.RemoveRange(removedPaymentRequests); entity.PaymentRequests = updatedPaymentRequests; processor.ProcessIfNeeded(entity); this.Context.SaveChanges(); return entity.AsTransaction(); })); }
/// <inheritdoc /> public Transaction CreateTransaction(InputTransaction input) { this.validator.Description(input.Description); var date = this.validator.DateString(input.DateString, "date"); var type = this.GetTransactionType(input.CategoryId, input.ReceivingAccountId, input.Amount); this.validator.Splits(this.splitwiseContext, input.PaymentRequests, input.SplitwiseSplits, type, input.Amount); return(this.ConcurrentInvoke(() => { var processor = new TransactionProcessor(this.Context, this.splitwiseContext); var account = this.Context.Accounts.GetEntity(input.AccountId, false); this.validator.AccountType(account.Type); var category = input.CategoryId.Select(cId => this.Context.Categories.GetEntity(cId, false)); var receivingAccount = input.ReceivingAccountId.Select(aId => this.Context.Accounts.GetEntity(aId, false)); if (receivingAccount.IsSome) { this.validator.AccountType(receivingAccount.Value.Type); if (receivingAccount.Value.Id == account.Id) { throw new ValidationException("Sender account can not be the same as receiver account."); } } // Verify a Splitwise account exists when adding providing splits. if (input.SplitwiseSplits.Any()) { this.Context.Accounts.GetSplitwiseEntity(); } var entity = new TransactionEntity { Description = input.Description, Type = type, Amount = input.Amount, Date = date, AccountId = input.AccountId, Account = account, Processed = false, CategoryId = input.CategoryId.ToNullable(), Category = category.ToNullIfNone(), ReceivingAccountId = input.ReceivingAccountId.ToNullable(), ReceivingAccount = receivingAccount.ToNullIfNone(), NeedsConfirmation = input.NeedsConfirmation, IsConfirmed = input.NeedsConfirmation ? false : (bool?)null, PaymentRequests = input.PaymentRequests.Select(pr => pr.ToPaymentRequestEntity()).ToList(), SplitDetails = input.SplitwiseSplits.Select(s => s.ToSplitDetailEntity()).ToList(), }; processor.ProcessIfNeeded(entity); this.Context.Transactions.Add(entity); this.Context.SaveChanges(); return entity.AsTransaction(); })); }
public Transaction CreateTransaction(InputTransaction input) { return(this.manager.CreateTransaction(input)); }
public Transaction UpdateTransaction(int id, InputTransaction input) { return(this.manager.UpdateTransaction(id, input)); }
protected ContinueBase(InputTransaction <TOriginalInput> transaction) { Transaction = transaction; }