示例#1
0
        public int BuildPaganationTransactionList(TransactionSearchModel model)
        {
            int             NOP = 0;
            ShomaRMEntities db  = new ShomaRMEntities();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetTransactionPaginationAndSearchData";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter param0 = cmd.CreateParameter();
                    param0.ParameterName = "FromDate";
                    param0.Value         = model.FromDate;
                    cmd.Parameters.Add(param0);

                    DbParameter param1 = cmd.CreateParameter();
                    param1.ParameterName = "ToDate";
                    param1.Value         = model.ToDate;
                    cmd.Parameters.Add(param1);

                    DbParameter param3 = cmd.CreateParameter();
                    param3.ParameterName = "PageNumber";
                    param3.Value         = model.PageNumber;
                    cmd.Parameters.Add(param3);

                    DbParameter param4 = cmd.CreateParameter();
                    param4.ParameterName = "NumberOfRows";
                    param4.Value         = model.NumberOfRows;
                    cmd.Parameters.Add(param4);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                if (dtTable.Rows.Count > 0)
                {
                    NOP = int.Parse(dtTable.Rows[0]["NumberOfPages"].ToString());
                }
                db.Dispose();
                return(NOP);
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
        private void buttonSync_Click(object sender, EventArgs e)
        {
            try
            {
                newList = new List <TransactionSearchModel>();
                SqlConnection  con = new SqlConnection(textBoxConnectionString.Text);
                SqlDataAdapter da  = new SqlDataAdapter();
                DataSet        ds  = new DataSet();
                DataTable      dt  = new DataTable();

                da.SelectCommand = new SqlCommand(@"select * from Output", con);
                da.Fill(ds, "Output");
                dt = ds.Tables["Output"];
                foreach (DataRow dr in dt.Rows)
                {
                    TransactionSearchModel newModel = new TransactionSearchModel();
                    string tx, rx = string.Empty;
                    tx = dr["Output_Tran_Code"].ToString();
                    rx = dr["Output_Tran_Stream"].ToString();
                    if (tx.Length > 6)
                    {
                        newModel.Name = tx.Substring(0, 6);
                        newModel.TX   = tx.Substring(0, 6);
                    }
                    if (rx.Length > 62)
                    {
                        newModel.RX = rx.Substring(56, 6);
                    }
                    newList.Add(newModel);
                }

                TransactionEnquiry parent = (TransactionEnquiry)this.Owner;
                parent.updateModel(newList);
                this.Close();
            }
            catch { }
        }
示例#3
0
        public List <TransactionSearchModel> GetTransactionList(TransactionSearchModel model)
        {
            ShomaRMEntities db = new ShomaRMEntities();
            List <TransactionSearchModel> lstTransaction = new List <TransactionSearchModel>();

            try
            {
                DataTable dtTable = new DataTable();
                using (var cmd = db.Database.Connection.CreateCommand())
                {
                    db.Database.Connection.Open();
                    cmd.CommandText = "usp_GetTransactionPaginationAndSearchData";
                    cmd.CommandType = CommandType.StoredProcedure;

                    DbParameter param0 = cmd.CreateParameter();
                    param0.ParameterName = "FromDate";
                    param0.Value         = model.FromDate;
                    cmd.Parameters.Add(param0);

                    DbParameter param1 = cmd.CreateParameter();
                    param1.ParameterName = "ToDate";
                    param1.Value         = model.ToDate;
                    cmd.Parameters.Add(param1);

                    DbParameter param3 = cmd.CreateParameter();
                    param3.ParameterName = "PageNumber";
                    param3.Value         = model.PageNumber;
                    cmd.Parameters.Add(param3);

                    DbParameter param4 = cmd.CreateParameter();
                    param4.ParameterName = "NumberOfRows";
                    param4.Value         = model.NumberOfRows;
                    cmd.Parameters.Add(param4);

                    DbDataAdapter da = DbProviderFactories.GetFactory("System.Data.SqlClient").CreateDataAdapter();
                    da.SelectCommand = cmd;
                    da.Fill(dtTable);
                    db.Database.Connection.Close();
                }
                foreach (DataRow dr in dtTable.Rows)
                {
                    TransactionSearchModel searchmodel = new TransactionSearchModel();
                    DateTime?dtTransDate   = null;
                    DateTime?dtCreatedDate = null;
                    DateTime?dtChargeDate  = null;
                    try
                    {
                        dtTransDate = Convert.ToDateTime(dr["Transaction_Date"].ToString());
                    }
                    catch
                    {
                    }
                    try
                    {
                        dtCreatedDate = Convert.ToDateTime(dr["CreatedDate"].ToString());
                    }
                    catch
                    {
                    }
                    try
                    {
                        dtChargeDate = Convert.ToDateTime(dr["Charge_Date"].ToString());
                    }
                    catch
                    {
                    }
                    DateTime?accounting_DateString = null;
                    try
                    {
                        accounting_DateString = Convert.ToDateTime(dr["Accounting_Date"].ToString());
                    }
                    catch
                    {
                    }
                    searchmodel.TransID        = Convert.ToInt32(dr["TransID"].ToString());
                    searchmodel.TenantIDString = dr["TenantID"].ToString();

                    searchmodel.TransactionDate = dtTransDate.HasValue ? dtTransDate.Value.ToString("MM/dd/yyyy") : "";
                    searchmodel.CreatedDate     = dtCreatedDate.HasValue ? dtCreatedDate.Value.ToString("MM/dd/yyyy") : "";
                    searchmodel.ChargeDate      = dtChargeDate.HasValue ? dtChargeDate.Value.ToString("MM/dd/yyyy") : "";
                    searchmodel.Credit_Amount   = Convert.ToDecimal(dr["Credit_Amount"].ToString());
                    searchmodel.Description     = dr["Description"].ToString();
                    searchmodel.Charge_Type     = dr["Charge_Type"].ToString();
                    searchmodel.Charge_Amount   = Convert.ToDecimal(dr["Charge_Amount"].ToString());
                    searchmodel.CreatedByText   = dr["CreatedByText"].ToString();
                    lstTransaction.Add(searchmodel);
                }
                db.Dispose();
                return(lstTransaction.ToList());
            }
            catch (Exception ex)
            {
                db.Database.Connection.Close();
                throw ex;
            }
        }
        public IHttpActionResult GetTransactions([FromUri] TransactionSearchModel searchModel)
        {
            var transactions = db.Transactions.AsQueryable();

            if (searchModel != null)
            {
                if (!string.IsNullOrEmpty(searchModel.Description))
                {
                    transactions = transactions.Where(x => x.Description.Contains(searchModel.Description));
                }
                if (!string.IsNullOrEmpty(searchModel.PaymentType))
                {
                    transactions = transactions.Where(x => x.PaymentType == searchModel.PaymentType);
                }
                if (searchModel.AmountFrom.HasValue)
                {
                    transactions = transactions.Where(x => x.Amount >= searchModel.AmountFrom);
                }
                if (searchModel.AmountTo.HasValue)
                {
                    transactions = transactions.Where(x => x.Amount <= searchModel.AmountTo);
                }
                if (searchModel.DateFrom.HasValue)
                {
                    transactions = transactions.Where(x => x.Date >= searchModel.DateFrom);
                }
                if (searchModel.DateTo.HasValue)
                {
                    transactions = transactions.Where(x => x.Date <= searchModel.DateTo);
                }

                if (searchModel.DescriptionSort == "asc")
                {
                    transactions = transactions.OrderBy(t => t.Description);
                }
                else if (searchModel.DescriptionSort == "desc")
                {
                    transactions = transactions.OrderByDescending(t => t.Description);
                }

                if (searchModel.AmountSort == "asc")
                {
                    transactions = transactions.OrderBy(t => t.Amount);
                }
                else if (searchModel.AmountSort == "desc")
                {
                    transactions = transactions.OrderByDescending(t => t.Amount);
                }

                if (searchModel.PaymentTypeSort == "asc")
                {
                    transactions = transactions.OrderBy(t => t.PaymentType);
                }
                else if (searchModel.PaymentTypeSort == "desc")
                {
                    transactions = transactions.OrderByDescending(t => t.PaymentType);
                }

                if (searchModel.DateSort == "asc")
                {
                    transactions = transactions.OrderBy(t => t.Date);
                }
                else if (searchModel.DateSort == "desc")
                {
                    transactions = transactions.OrderByDescending(t => t.Date);
                }
            }

            int count       = transactions.Count();
            int currentPage = searchModel.PageNumber;
            int pageSize    = searchModel.PageSize;
            int totalCount  = count;
            int totalPages  = (int)Math.Ceiling(count / (double)pageSize);

            var previousPage = currentPage > 1 ? "1" : "0";
            var nextPage     = currentPage < totalPages ? "1" : "0";

            List <Transaction> finalList = transactions.ToList().Skip((currentPage - 1) * pageSize).Take(pageSize).ToList();

            var paginationMetadata = new
            {
                totalCount  = totalCount,
                pageSize    = pageSize,
                currentPage = currentPage,
                totalPages  = totalPages,
                previousPage,
                nextPage
            };

            if (HttpContext.Current != null)
            {
                HttpContext.Current.Response.Headers.Add("Paging-Headers", JsonConvert.SerializeObject(paginationMetadata));
            }

            return(Ok(finalList));
        }
示例#5
0
        public async Task <PaystackTransactionList> GetTransactionList(PaystackSetting paystackSettings, TransactionSearchModel searchModel)
        {
            Guard.NotNull(paystackSettings, nameof(paystackSettings));


            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string      apiEndPoint = paystackSettings.ListTransactionEndPoint;
            RestRequest request     = new RestRequest(apiEndPoint, Method.GET);

            request.AddHeader(paystackSettings.APIAcceptHeaderKey, paystackSettings.APIAcceptHeaderValue);
            request.AddHeader(paystackSettings.APIAuthorizationHeaderKey, paystackSettings.APIAuthorizationHeaderValue + " " + paystackSettings.Key);

            if (searchModel != null)
            {
                request.AddQueryParameter(paystackSettings.APIStatusQueryParameterKey, searchModel.TransactionStatus);

                if (searchModel.From > DateTime.MinValue)
                {
                    request.AddQueryParameter(paystackSettings.APIFromQueryParameterKey, searchModel.From.ToString(paystackSettings.TransactionSearchDateFormat));
                }
                if (searchModel.To > DateTime.MinValue)
                {
                    request.AddQueryParameter(paystackSettings.APIToQueryParameterKey, searchModel.To.AddDays(1).ToString(paystackSettings.TransactionSearchDateFormat));
                }
                if (searchModel.Amount > 0)
                {
                    request.AddQueryParameter(paystackSettings.APIAmountQueryParameterKey, searchModel.Amount.ToString());
                }
            }

            //RestClient client = new RestClient(paystackSettings.ApiBaseUrl);
            //var transactionResponse = client.Execute(request);
            //return JsonConvert.DeserializeObject<PaystackTransactionList>(transactionResponse.Content);

            return(await PostRequest(paystackSettings, request));
        }
示例#6
0
        public async Task <PaystackTransactionList> FetchSettlements(PaystackSetting paystackSettings, TransactionSearchModel searchModel)
        {
            Guard.NotNull(paystackSettings, nameof(paystackSettings));

            //ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
            string apiEndPoint = paystackSettings.FetchSettlementsEndPoint;

            RestRequest request = new RestRequest(apiEndPoint, Method.GET);

            request.AddHeader(paystackSettings.APIAcceptHeaderKey, paystackSettings.APIAcceptHeaderValue);
            request.AddHeader(paystackSettings.APIAuthorizationHeaderKey, paystackSettings.APIAuthorizationHeaderValue + " " + paystackSettings.Key);

            if (searchModel != null)
            {
                if (searchModel.DateFrom > DateTime.MinValue)
                {
                    request.AddQueryParameter(paystackSettings.APIFromQueryParameterKey, searchModel.DateFrom.ToString(paystackSettings.TransactionSearchDateFormat));
                }
                if (searchModel.DateTo > DateTime.MinValue)
                {
                    request.AddQueryParameter(paystackSettings.APIToQueryParameterKey, searchModel.DateTo.AddDays(1).ToString(paystackSettings.TransactionSearchDateFormat));
                }
            }

            //TaskCompletionSource<IRestResponse> taskCompletion = new TaskCompletionSource<IRestResponse>();
            //RestRequestAsyncHandle handle = restClient.ExecuteAsync(request, r => taskCompletion.SetResult(r));
            //RestResponse response = (RestResponse)(await taskCompletion.Task);
            //return JsonConvert.DeserializeObject<SomeObject>(response.Content);

            return(await PostRequest(paystackSettings, request));
        }