Exemplo n.º 1
0
 private void Btn_Ok_Click(object sender, RoutedEventArgs e)
 {
     tc.AddTransaction(new Transaction()
     {
         Name    = txt_Name.Text,
         Details = txt_Details.Text,
         Person  = txt_Person.Text,
         Value   = Convert.ToDecimal(txt_Value.Text)
     });
     this.Close();
 }
Exemplo n.º 2
0
        public void AddTransaction()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var transactionId = Guid.NewGuid();
            var transaction   = new Aquisition()
            {
                Id = transactionId
            };

            var service = mockRepository.Create <IPortfolioTransactionService>();

            service.Setup(x => x.ApplyTransaction(transaction)).Returns(ServiceResult.Ok()).Verifiable();

            var controller = new TransactionController();
            var result     = controller.AddTransaction(service.Object, transaction);

            result.Should().BeOkResult();

            mockRepository.VerifyAll();
        }
Exemplo n.º 3
0
        public void AddTransactionValidationError()
        {
            var mockRepository = new MockRepository(MockBehavior.Strict);

            var transactionId = Guid.NewGuid();
            var transaction   = new Aquisition()
            {
                Id = transactionId
            };

            var service = mockRepository.Create <IPortfolioTransactionService>();

            service.Setup(x => x.ApplyTransaction(transaction)).Returns(ServiceResult.Error("Error message")).Verifiable();

            var controller = new TransactionController();
            var result     = controller.AddTransaction(service.Object, transaction);

            result.Should().BeBadRequestObjectResult().Error.Should().BeEquivalentTo(new[] { "Error message" });

            mockRepository.VerifyAll();
        }
Exemplo n.º 4
0
        private async void Transaction(string transtype)
        {
            var validate = new Validations();

            if (validate.ValidateDouble(txtAmount.Text) == false)
            {
                txtAmount.Focus();
                errorProvider1.SetError(txtAmount, "Invalid Amount");
                MessageBox.Show("Invalid Amount");
            }

            else
            {
                var tempTrans = new Transaction();
                var status    = false;
                tempTrans.Amount     = Convert.ToDecimal(txtAmount.Text);
                tempTrans.CustomerNo = lblCustomerNo.Text;
                tempTrans.TransType  = transactiontype;
                tempTrans.SenderName = txtFirstname.Text + " " + txtLastname.Text;
                tempTrans.TransDate  = Convert.ToDateTime(lblDate.Text);


                if (transtype != "transfer")
                {
                    tempTrans.ReceipientAccNo = customerDetail.AccountNumber;
                    if (transtype == "deposit")
                    {
                        lblBalance.Text = (Convert.ToDecimal(lblBalance.Text) + Convert.ToDecimal(txtAmount.Text)).ToString();
                    }
                    else
                    {
                        lblBalance.Text = (Convert.ToDecimal(lblBalance.Text) - Convert.ToDecimal(txtAmount.Text)).ToString();
                    }
                    customerDetail.Balance = Convert.ToDecimal(lblBalance.Text);
                }
                else
                {
                    tempTrans.ReceipientAccNo = txtAccountnumber.Text;
                    var Receiver    = new Customer();
                    var repo        = new CustomerController();
                    var NewCustomer = repo.GetCustomerDetails();


                    NewCustomer.ForEach(item =>
                    {
                        if (tempTrans.ReceipientAccNo == item.AccountNumber)
                        {
                            Receiver = item;
                            status   = true;
                        }
                    });

                    if (status == false)
                    {
                        MessageBox.Show("The Account Number does not Exist");
                    }
                    else
                    {
                        lblBalance.Text        = (Convert.ToDecimal(lblBalance.Text) - Convert.ToDecimal(txtAmount.Text)).ToString();
                        Receiver.Balance      += Convert.ToDecimal(txtAmount.Text);
                        customerDetail.Balance = Convert.ToDecimal(lblBalance.Text);
                        var newCustomer = new CustomerController();

                        newCustomer.EditCustomerDetail(await SubmitChanges(Receiver));
                    }
                }

                if ((transtype == "transfer" && status == true) || (transtype != "transfer"))
                {
                    var updateCustomer = new CustomerController();
                    updateCustomer.EditCustomerDetail(await SubmitChanges(customerDetail));


                    var Repo = new TransactionController();
                    Repo.AddTransaction(tempTrans);
                    if (transtype == "deposit")
                    {
                        MessageBox.Show("You have Deposited : " + tempTrans.Amount + " t0 " + tempTrans.ReceipientAccNo);
                    }
                    else if (transtype == "withdraw")
                    {
                        MessageBox.Show("You have Withdrawn : " + tempTrans.Amount + " from " + tempTrans.SenderName);
                    }
                    else if (transtype == "transfer")
                    {
                        MessageBox.Show("You have Transferd : " + tempTrans.Amount + " t0 " + tempTrans.ReceipientAccNo);
                    }
                    updateCustomer.GetCustomerDetails();
                    this.Close();
                }
            }
        }