Пример #1
0
        public async Task <bool> SaveOfflineTopUpTransaction(string employeeEmail, decimal topUpAmount)
        {
            var employee = _context.Employees.Find(employeeEmail);

            employee.Balance = employee.Balance + topUpAmount;

            var newTransaction = new Transaction
            {
                DateTime        = DateTime.UtcNow,
                Amount          = topUpAmount,
                TransactionType = "OPEN",
                Employee        = employee
            };

            try
            {
                _context.Add(newTransaction);
                _context.Update(employee);
                await _context.SaveChangesAsync();

                return(true);
            }
            catch (SqlException error)
            {
                _logger.LogError("While running this error showed up:", error);
                return(false);
            }
        }
Пример #2
0
 public async Task EditTerminal(Terminal terminal)
 {
     try
     {
         _context.Update(terminal);
         await _context.SaveChangesAsync();
     }
     catch (Exception error)
     {
         _logger.LogError("While running this error showed up:", error);
     }
 }
Пример #3
0
        public async Task <string> ExecutePayment(string paymentId, string token, string payerId, string email)
        {
            var environment = new SandboxEnvironment("AV8B5CBqWFqiUEBdhbe2rBVqX0RwNjY74nORYSEI3P8WZ-rRzRxXd1H0pA_qrywn0MCZuXzg3x-WwDeY", "EL-1QQduQKljgE0uHFs6WKAM4JtYrbf8CzOisxNCczPvdnkQYQDT1-rCM1W1dYM3Dhu8L9AcwqwhKdZH");
            var client      = new PayPalHttpClient(environment);
            PaymentExecuteRequest request = new PaymentExecuteRequest(paymentId);

            request.RequestBody(new PaymentExecution()
            {
                PayerId = payerId
            });


            try
            {
                HttpResponse response = await client.Execute(request);

                var     statusCode = response.StatusCode;
                Payment result     = response.Result <Payment>();

                //PayerId en payment opslaan in DB
                var employee = _context.Employees.Find(email);
                employee.Balance = employee.Balance + 10;
                Models.Transaction transaction = new Models.Transaction()
                {
                    Amount                = 10,
                    DateTime              = DateTime.UtcNow,
                    Employee              = employee,
                    employeeEmail         = email,
                    ProviderName          = "PayPal",
                    ProviderTransactionId = paymentId,
                    TransactionType       = "ExternalTopUp"
                };
                try
                {
                    _context.Add(transaction);
                    _context.Update(employee);
                    await _context.SaveChangesAsync();

                    return("Complete");
                }
                catch (SqlException error)
                {
                    _logger.LogError("While running this error showed up:", error);
                    return("Failed");
                }
            }
            catch (HttpException httpException)
            {
                var statusCode = httpException.StatusCode;
                var debugId    = httpException.Headers.GetValues("PayPal-Debug-Id").FirstOrDefault();
                return("Failed");
            }
        }
Пример #4
0
 public async Task EditTransaction(int transactionId, string newType)
 {
     try
     {
         var transaction = _context.Find <Transaction>(transactionId);
         transaction.TransactionType = newType;
         _context.Update(transaction);
         await _context.SaveChangesAsync();
     }
     catch (Exception error)
     {
         _logger.LogError("While running this error showed up:", error);
     }
 }
 public async void SaveEmployeeEdits(Employee employee)
 {
     _context.Update(employee);
     await _context.SaveChangesAsync();
 }
Пример #6
0
 public async void SaveProductEdit(Product product)
 {
     _context.Update(product);
     await _context.SaveChangesAsync();
 }