示例#1
0
        public int GetKey(PayoutMethod model)
        {
            var entity = _context.PayoutMethods.Where(x => x.PayoutMethodId == model.PayoutMethodId)
                         .OrderBy(x => x.PayoutMethodName)
                         .FirstOrDefault();

            return(entity != null ? entity.PayoutMethodId : 0);
        }
示例#2
0
        public JsonResult Update(string model) // parameter must be the same json object defined in parameterMap in kendo's datasource
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var clientModel = JsonConvert.DeserializeObject <PayoutMethodViewModel>(model);

            try
            {
                var          dataProvider = new PayoutMethodProvider(_dbContext);
                PayoutMethod entity       = dataProvider.Retrieve(clientModel.PayoutMethodId);
                dataProvider.MapData(clientModel, ref entity);
                dataProvider.Update(entity.PayoutMethodId, entity);

                // update properties if changed
                var propertyToUpdate = dataProvider.PropertyToUpdate(entity.PayoutMethodId, clientModel.SelectedPropertyCodes);
                if (propertyToUpdate != null)
                {
                    _dbContext.PropertyPayoutMethods.RemoveRange(propertyToUpdate);
                    foreach (var newProperty in clientModel.SelectedPropertyCodes)
                    {
                        _dbContext.PropertyPayoutMethods.Add(new PropertyPayoutMethod
                        {
                            PropertyCode   = newProperty.Value,
                            PayoutMethodId = entity.PayoutMethodId
                        });
                    }
                }

                dataProvider.Commit();

                return(Json(clientModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Expense {0:d} fails. {1} - {2}", 0, ex.Message, innerErrorMessage);
                return(InternalError(message, "fail", ex));
            }
        }
示例#3
0
        public JsonResult Create(string model)
        {
            if (!AuthorizationProvider.IsStatementAdmin())
            {
                return(Forbidden());
            }

            var payoutMethodModel = JsonConvert.DeserializeObject <PayoutMethodViewModel>(model);

            try
            {
                var          dataProvider = new PayoutMethodProvider(_dbContext);
                PayoutMethod entity       = new PayoutMethod();
                dataProvider.MapData(payoutMethodModel, ref entity);
                dataProvider.Create(entity);
                dataProvider.Commit();

                payoutMethodModel.PayoutMethodId = entity.PayoutMethodId; // set the created Id to return to kendo grid

                foreach (var m in payoutMethodModel.SelectedPropertyCodes)
                {
                    _dbContext.PropertyPayoutMethods.Add(new PropertyPayoutMethod
                    {
                        PayoutMethodId = entity.PayoutMethodId,
                        PropertyCode   = m.Value,
                    });
                }
                dataProvider.Commit();

                return(Json(payoutMethodModel, JsonRequestBehavior.AllowGet));
            }
            catch (Exception ex)
            {
                var    innerErrorMessage = ex.InnerException != null ? ex.InnerException.Message : string.Empty;
                string message           = string.Format("Saving Expense {0:d} fails. {1} - {2}", 0, ex.Message, innerErrorMessage);
                return(InternalError(message, string.Empty));
            }
        }
示例#4
0
        static Guid?CreateTransactionExample(Configuration configuration)
        {
            TransactionsApi api = new TransactionsApi(configuration);

            // Please check our documentation at https://docs.transferzero.com/docs/transaction-flow/
            // for details on how transactions work

            // When adding a sender to transaction, please use either an id or external_id. Providing both will result in a validation error.
            // Please see our documentation at https://docs.transferzero.com/docs/transaction-flow/#sender

            Sender sender = new Sender(id: Guid.Parse("058de445-ffff-ffff-ffff-da9c751d14bf"));

            // You can find the various payout options at https://docs.transferzero.com/docs/transaction-flow/#payout-details

            PayoutMethodDetails ngnBankDetails = new PayoutMethodDetails(
                bankAccount: "123456789",
                bankAccountType: PayoutMethodBankAccountTypeEnum._20,
                bankCode: "082",
                firstName: "First",
                lastName: "Last"
                );

            PayoutMethod payoutMethod = new PayoutMethod(
                type: "NGN::Bank",
                details: ngnBankDetails
                );

            // Please see https://docs.transferzero.com/docs/transaction-flow/#requested-amount-and-currency
            // on what the request amount and currencies do

            Recipient recipient = new Recipient(
                requestedAmount: 10000,
                requestedCurrency: "NGN",
                payoutMethod: payoutMethod
                );

            // Similarly you can check https://docs.transferzero.com/docs/transaction-flow/#requested-amount-and-currency
            // on details about the input currency parameter

            // Find more details on external IDs at https://docs.transferzero.com/docs/transaction-flow/#external-id

            Transaction transaction = new Transaction(
                inputCurrency: "USD",
                sender: sender,
                recipients: new List <Recipient>()
            {
                recipient
            },
                externalId: "TRANSACTION-00001"
                );

            try
            {
                TransactionRequest transactionRequest = new TransactionRequest(
                    transaction: transaction
                    );
                TransactionResponse transactionResponse = api.PostTransactions(transactionRequest);
                System.Console.WriteLine("Transaction created! ID" + transactionResponse.Object.Id);
                System.Console.WriteLine(transactionResponse.Object);
                return(transactionResponse.Object.Id);
            }
            catch (ApiException e)
            {
                if (e.IsValidationError)
                {
                    TransactionResponse transactionResponse = e.ParseObject <TransactionResponse>();
                    System.Console.WriteLine("Validation Error" + transactionResponse.Object.Errors);
                }
                else
                {
                    throw e;
                }
                return(null);
            }
        }