Exemplo n.º 1
0
        /// <summary>
        /// Delete a payment profile for a donor
        /// </summary>
        /// <param name="paymentProfileTokenId">Payment profile token id</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse DeletePaymentProfile(string paymentProfileTokenId)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var           paymentProfile = db.PaymentProfiles.Where(x => x.TokenId == paymentProfileTokenId).SingleOrDefault();
                    DbEntityEntry dbEntityEntry  = db.Entry(paymentProfile);

                    if (dbEntityEntry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.PaymentProfiles.Attach(paymentProfile);
                    }

                    db.PaymentProfiles.Remove(paymentProfile);
                    db.SaveChanges();
                }

                response.Message   = "Payment profile successfully deleted";
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Update a record for transaction details
        /// </summary>
        /// <param name="transactionDetails">Transaction details</param>
        /// <returns>Response with success, message, and profile token</returns>
        public ProcessorResponse UpdateTransactionRecord(TransactionDetail transactionDetails)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    //save changes to database
                    db.Entry(transactionDetails).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                response.Message   = "Transaction successfully updated";
                response.AuthToken = transactionDetails.PaymentProfileTokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Update existing donor payment profile for a donor
        /// </summary>
        /// <param name="BankAccount">Donor payment profile details</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse UpdateBankAccount(BankAccount BankAccount)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    //save changes to database
                    db.Entry(BankAccount).State = System.Data.Entity.EntityState.Modified;
                    db.SaveChanges();
                }

                response.Message   = "Bank Account successfully updated";
                response.AuthToken = BankAccount.BankAccountTokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Update the Transaction List with the donation details
        /// </summary>
        /// <param name="donationTransList">Donation Transaction List</param>
        public void UpdateDonationTransactionList(IEnumerable <TransactionDetail> donationTransList)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    foreach (TransactionDetail trans in donationTransList)
                    {
                        try
                        {
                            db.Entry(trans).State = System.Data.Entity.EntityState.Modified;
                        }
                        catch (Exception ex)
                        {
                            //Common.Helper.LogException(ex);
                        }
                    }

                    db.SaveChanges(); //batching multiple updates
                }

                //create log entries for multiple transactions
                //CreateTransactionLogEntries(donationTransList);
            }
            catch (Exception ex)
            {
                //Common.Helper.LogException(ex);
            }
        }
        /// <summary>
        /// Create a payment batch for an organisatsion
        /// </summary>
        /// <param name="batch">Payment batch details</param>
        public void CreatePaymentToOrganisationBatch(PaymentToOrganisationBatch batch)
        {
            using (var db = new GenerousAPIEntities())
            {
                using (var trans = db.Database.BeginTransaction())
                {
                    try
                    {
                        db.PaymentToOrganisationBatches.Add(batch);

                        if (batch.PaymentToOrganisationBatchLineItems != null && batch.PaymentToOrganisationBatchLineItems.Count > 0)
                        {
                            db.PaymentToOrganisationBatchLineItems.AddRange(batch.PaymentToOrganisationBatchLineItems);
                        }

                        db.SaveChanges();

                        trans.Commit();
                    }
                    catch (Exception ex)
                    {
                        trans.Rollback();
                        throw ex;
                    }
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Delete a payment profile for a donor
        /// </summary>
        /// <param name="BankAccountTokenId">Payment profile token id</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse DeleteBankAccount(string BankAccountTokenId)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    var           BankAccount   = db.BankAccounts.Where(x => x.BankAccountTokenId == BankAccountTokenId).SingleOrDefault();
                    DbEntityEntry dbEntityEntry = db.Entry(BankAccount);

                    if (dbEntityEntry.State == System.Data.Entity.EntityState.Detached)
                    {
                        db.BankAccounts.Attach(BankAccount);
                    }

                    BankAccount.Active = false;
                    db.SaveChanges();
                }

                response.AuthToken = BankAccountTokenId;
                response.Message   = "Bank Account successfully deleted";
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
        /// <summary>
        /// Save new batch line items
        /// </summary>
        /// <param name="batchLineItemList">Collection of line items to save</param>
        public void CreatePaymentToOrganisationBatchLineItems(List <PaymentToOrganisationBatchLineItem> batchLineItemList)
        {
            using (var db = new GenerousAPIEntities())
            {
                db.PaymentToOrganisationBatchLineItems.AddRange(batchLineItemList);
                db.SaveChanges();
            }

            //create log entries for multiple transactions
            CreateTransactionLogEntries(batchLineItemList);
        }
Exemplo n.º 8
0
 /// <summary>
 /// Update the organisation fee processing record
 /// </summary>
 /// <param name="processedFee"></param>
 public void UpdateOrganisationFeeProces(OrganisationFeeProcessing processedFee)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.Entry(processedFee).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
        /// <summary>
        /// Updates the the batch line item list
        /// </summary>
        /// <param name="batchLineItemList">Line items</param>
        public void UpdatePaymentToOrganisationBatchLineItemList(List <PaymentToOrganisationBatchLineItem> batchLineItemList)
        {
            using (var db = new GenerousAPIEntities())
            {
                foreach (PaymentToOrganisationBatchLineItem lineItem in batchLineItemList)
                {
                    db.Entry(lineItem).State = System.Data.Entity.EntityState.Modified;
                }

                db.SaveChanges(); //batching multiple updates
            }

            //create log entries for multiple transactions
            CreateTransactionLogEntries(batchLineItemList);
        }
Exemplo n.º 10
0
 /// <summary>
 /// Save Expiring Credit Card Detais
 /// </summary>
 /// <param name="expiringCardDetails">Details of cards</param>
 public void SaveExpiringCreditCardDetais(ExpiringCreditCardsForOrganisation expiringCardDetails)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.ExpiringCreditCardsForOrganisations.Add(expiringCardDetails);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         return;
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// Update the organisation fee processing record
 /// </summary>
 /// <param name="processedFee"></param>
 public void UpdateOrganisationFeeStandardPrices(OrganisationStandardFee standFees)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.Entry(standFees).State = EntityState.Modified;
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
Exemplo n.º 12
0
 /// <summary>
 /// Create a new fee processing record
 /// </summary>
 /// <param name="processFee"></param>
 public void CreateOrganisationStandardFees(OrganisationStandardFee standFees)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.OrganisationStandardFees.Add(standFees);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
Exemplo n.º 13
0
 /// <summary>
 /// Create a new fee processing record
 /// </summary>
 /// <param name="processFee"></param>
 public void CreateOrganisationFeeProces(OrganisationFeeProcessing processFee)
 {
     try
     {
         using (var db = new GenerousAPIEntities())
         {
             db.OrganisationFeeProcessings.Add(processFee);
             db.SaveChanges();
         }
     }
     catch (Exception ex)
     {
         //Helper.LogException(ex);
     }
 }
        /// <summary>
        /// Creates the bin info for the payment profile for a credit card
        /// </summary>
        /// <param name="BinInfo">Bin info DTO details</param>
        /// <returns>True if successfully added, false otherwise</returns>
        public bool CreateBinInfo(PaymentProfileBinInfo BinInfo)
        {
            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    db.PaymentProfileBinInfoes.Add(BinInfo);
                    db.SaveChanges();
                }

                return(true);
            }
            catch (Exception)
            {
                return(false);
            }
        }
Exemplo n.º 15
0
        /// <summary>
        /// Create a new record for transaction details
        /// </summary>
        /// <param name="transactionDetails">Transaction details</param>
        /// <returns>Response with success, message, and profile token</returns>
        public ProcessorResponse CreateTransactionRecord(TransactionDetail transactionDetails)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    db.TransactionDetails.Add(transactionDetails);
                    db.SaveChanges();
                }

                response.Message   = "Transaction successfully saved";
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }
Exemplo n.º 16
0
        /// <summary>
        /// Create a new donor payment profile for a donor
        /// </summary>
        /// <param name="PaymentProfile">Donor payment profile details</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse CreatePaymentProfile(PaymentProfile PaymentProfile)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    db.PaymentProfiles.Add(PaymentProfile);
                    db.SaveChanges();
                }

                response.Message   = "Payment profile successfully saved";
                response.AuthToken = PaymentProfile.TokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message + ex.InnerException;
            }

            return(response);
        }
Exemplo n.º 17
0
        /// <summary>
        /// Create a new donor payment profile for a donor
        /// </summary>
        /// <param name="BankAccount">Donor payment profile details</param>
        /// <returns>Payment Response with success, message, and profile token</returns>
        public ProcessorResponse CreateBankAccount(BankAccount BankAccount)
        {
            var response = new ProcessorResponse();

            try
            {
                using (var db = new GenerousAPIEntities())
                {
                    db.BankAccounts.Add(BankAccount);
                    db.SaveChanges();
                }

                response.Message   = "Bank Account successfully saved";
                response.AuthToken = BankAccount.BankAccountTokenId;
                response.IsSuccess = true;
            }
            catch (Exception ex)
            {
                response.IsSuccess = false;
                response.Message   = ex.Message;
            }

            return(response);
        }