public ActionResult <List <Payment> > AddPayment([FromBody] Bill bill) { try { var oResp = PaymentRepository.PayProcessResponse(); if (oResp.Item1 == 0) { var id = PaymentRepository.AddPayment(bill); if (id > 0) { return(Ok("Se ha registrado con exito el pago nro " + id.ToString())); } else { return(NotFound("Ocurrio un error insertando el pago")); } } else { return(StatusCode(StatusCodes.Status402PaymentRequired, oResp.Item2)); } } catch (DatabaseException e) { //Aqui va una excepcion personalizada return(StatusCode(StatusCodes.Status500InternalServerError, e)); } }
public void addPaymentToDb() { PaymentRepository newPayment = new PaymentRepository(); newPayment.AddPayment(payment.CustomerId, payment.PaymentType, payment.PaymentAccountNumber); IsComplete = true; }
//Вставка строки private void InsertRecord() { fmPaymentEdit fmEdit = new fmPaymentEdit(EnumFormMode.Insert, "Створення виплати"); Payment paymentSet = new Payment(); int month = SalaryHelper.GetMonthByIndex(cmbCalendar.SelectedIndex, true); if (month == 0) { paymentSet.Payment_Date = DateTime.MinValue.AddYears(DateTime.Today.Year - 1).AddMonths(DateTime.Today.Month - 1); } else { int year = SalaryHelper.GetYearByIndex(DateTime.Today.Year - SetupProgram.YearSalary, cmbCalendar.SelectedIndex, true); paymentSet.Payment_Date = DateTime.MinValue.AddYears(year - 1).AddMonths(month - 1); } paymentSet.Payment_Type = _typeId; fmEdit.SetData(paymentSet); if (fmEdit.ShowDialog() == DialogResult.OK) { string error; Payment paymentGet = fmEdit.GetData(); int id = _repoPayment.AddPayment(paymentGet, out error); if (id == 0) { MessageBox.Show("Помилка додавання рядка.\nТехнічна інформація: " + error, "Помилка"); return; } RefreshTablePayment(_typeId, _datBeg, _datEnd); dgvPayment.SetPositionRow <v_Payment>("Payment_Id", id.ToString()); } }
private void Button_Click(object sender, RoutedEventArgs e) { if (textBoxCardNum.Text.Length != 8 || string.IsNullOrWhiteSpace(textBoxCardNum.Text)) { MessageBox.Show("Please, enter 8-digit card number!"); textBoxCardNum.Clear(); textBoxCardNum.Focus(); return; } if (textBoxCardCVV.Text.Length != 3 || string.IsNullOrWhiteSpace(textBoxCardCVV.Text)) { MessageBox.Show("Please, enter 3-digit card CVV!"); textBoxCardCVV.Clear(); textBoxCardCVV.Focus(); return; } string s = textBoxCardDate.Text; string[] words = s.Split(new char[] { '.' }, StringSplitOptions.RemoveEmptyEntries); if (words[0].Length < 4 || string.IsNullOrWhiteSpace(textBoxCardDate.Text)) { MessageBox.Show("Please, enter Date in the right format(XXXX.XX.XX)!"); textBoxCardDate.Clear(); textBoxCardDate.Focus(); return; } if (string.IsNullOrWhiteSpace(textBoxCardHolder.Text)) { MessageBox.Show("Please, enter your name!"); textBoxCardHolder.Focus(); return; } else { CreditCard creditCard = new CreditCard(); creditCard.CardNumber = textBoxCardNum.Text; creditCard.CardHolder = textBoxCardHolder.Text; creditCard.Date = textBoxCardDate.Text; creditCard.CVV = textBoxCardCVV.Text; _card_rp.AddCreditCard(creditCard); Payment p = new Payment(); string st = _repositoryp.CurrentSum; string st2 = textBoxCardNum.Text; st2 = st2.Substring(0, 3); st = st.Substring(0, st.Length - 1); p.TotalSum = Convert.ToDouble(st); p.ID = Convert.ToInt32(st2); _repositoryp.AddPayment(p); NavigationService.Navigate(new BookingPage(_repository, _repositoryp)); } }
static void Main(string[] args) { while (true) { Console.WriteLine("*******************************************************"); Console.WriteLine("** WELCOME TO BANGAZON! Command Line Ordering System **"); Console.WriteLine("*******************************************************"); if (activeCustomer == null) { Console.WriteLine("1.create a customer account"); Console.WriteLine("2.choose active customer"); } Console.WriteLine("3.create a payment option"); Console.WriteLine("4.add product to shopping cart"); Console.WriteLine("5.complete an order"); Console.WriteLine("6.see product popularity"); Console.WriteLine("7.leave bangazon!"); string Command = Console.ReadLine(); if (Command == "1") { Console.Clear(); var customerRepository = new CustomerRepository(); Console.WriteLine("Enter your name"); var CustomerName = Console.ReadLine(); Console.WriteLine("Street address"); var CustomerAddress = Console.ReadLine(); Console.WriteLine("City"); var CustomerCity = Console.ReadLine(); Console.WriteLine("State"); var CustomerState = Console.ReadLine(); Console.WriteLine("Postal code"); var CustomerZip = int.Parse(Console.ReadLine()); Console.WriteLine("Phone number"); var CustomerPhone = int.Parse(Console.ReadLine()); customerRepository.AddCustomer(CustomerName, CustomerAddress, CustomerCity, CustomerState, CustomerZip, CustomerPhone); Console.WriteLine(activeCustomer.CustomerID); } else if (Command == "2") { var customerRepository = new CustomerRepository(); Console.Clear(); Console.WriteLine("Choose which customer will be active."); customerRepository.GetCustomers(); var customerCollection = customerRepository.GetCustomers(); var cursorIndex = 0; var continueLooping = true; ConsoleKeyInfo keyInfo = new ConsoleKeyInfo(); while (continueLooping) { int counter = 0; Console.Clear(); Console.WriteLine(!(keyInfo.KeyChar.Equals(ConsoleKey.Enter))); foreach (var bangazonner in customerCollection) { if (counter == cursorIndex) { Console.WriteLine(">" + bangazonner.Name); activeCustomer = bangazonner; } else { Console.WriteLine(" " + bangazonner.Name); } counter++; } keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.UpArrow) { cursorIndex--; } else if (keyInfo.Key == ConsoleKey.DownArrow) { cursorIndex++; } if (keyInfo.Key == ConsoleKey.Enter) { Console.Clear(); Console.WriteLine("Welcome, " + activeCustomer.Name + " Choose an option below!"); continueLooping = false; } } Console.WriteLine(" "); } else if (Command == "3") { //AddPayment(); Console.Clear(); var paymentRepository = new PaymentRepository(); Console.WriteLine("Enter your payment type (i.e. credit/debit card)"); var PaymentType = Console.ReadLine(); Console.WriteLine("Enter Account Number"); var AccountNumber = Console.ReadLine(); paymentRepository.AddPayment(PaymentType, AccountNumber, activeCustomer.CustomerID); new Customer(); Console.WriteLine("Payment method has been added!"); } else if (Command == "4") { //AddProductToOrder(); var productRepository = new ProductRepository(); Console.Clear(); Console.WriteLine("Choose which customer will be active."); productRepository.GetProducts(); var productCollection = productRepository.GetProducts(); var cursorIndex = 0; var continueLooping = true; ConsoleKeyInfo keyInfo = new ConsoleKeyInfo(); while (continueLooping) { int counter = 0; Console.Clear(); Console.WriteLine(!(keyInfo.KeyChar.Equals(ConsoleKey.Enter))); foreach (var product in productCollection) { if (counter == cursorIndex) { Console.WriteLine(">" + product.ProductName); //activeCustomer = product; } else { Console.WriteLine(" " + product.ProductName); } counter++; } keyInfo = Console.ReadKey(); if (keyInfo.Key == ConsoleKey.UpArrow) { cursorIndex--; } else if (keyInfo.Key == ConsoleKey.DownArrow) { cursorIndex++; } if (keyInfo.Key == ConsoleKey.Enter) { Console.Clear(); continueLooping = false; } } Console.WriteLine(" "); } else if (Command == "5") { //CompleteOrder(); } else if (Command == "6") { //DisplayProductAvailability(); } else if (Command == "7") { Environment.Exit(0); } } }
public bool AddPayment(int studentID, decimal payment, string type) { PaymentRepository paymentRepo = new PaymentRepository(); return(paymentRepo.AddPayment(studentID, payment, type)); }