private void downloadPayments(HttpContext context) { byte productId = 0; int accountId = 0; string accountName = string.Empty; string mobile = string.Empty; string email = string.Empty; string number = string.Empty; byte PaymentStatus = 0; byte billingMode = 1; DateTime fromDateTime = DateTime.Now.Date; DateTime toDateTime = DateTime.Now.AddDays(1).AddTicks(-1); int pageNumber = 1; byte limit = 20; if (context.Request["ProductId"] != null && !byte.TryParse(context.Request["productId"].ToString(), out productId)) { GenerateErrorResponse(400, string.Format("ProductId must be a number")); } if (context.Request["Number"] != null) { number = context.Request["Number"].ToString(); } if (context.Request["AccountName"] != null) { accountName = context.Request["AccountName"].ToString(); } if (context.Request["PaymentStatus"] != null && !byte.TryParse(context.Request["PaymentStatus"].ToString(), out PaymentStatus)) { GenerateErrorResponse(400, string.Format("OrderStatus must be a number")); } if (context.Request["BillingMode"] != null && !byte.TryParse(context.Request["BillingMode"].ToString(), out billingMode)) { GenerateErrorResponse(400, string.Format("BillingModeId must be a number")); } if (context.Request["mobile"] != null) { mobile = Convert.ToString(context.Request["mobile"]); } if (context.Request["email"] != null) { email = Convert.ToString(context.Request["email"]); } if (context.Request["FromDateTime"] != null) { fromDateTime = Convert.ToDateTime(context.Request["fromDateTime"]); } if (context.Request["ToDateTime"] != null) { toDateTime = Convert.ToDateTime(context.Request["ToDateTime"]); } TablePreferences paymentsTablePreferences = new TablePreferences("", "", true, false); Dictionary <string, TablePreferences> paymentsDictionary = new Dictionary <string, TablePreferences>(); paymentsDictionary.Add("Payments", paymentsTablePreferences); OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON); context.Response.Write(client.GetPayments(productId: productId, accountId: accountId, mobile: mobile, email: email, paymentStatus: PaymentStatus, number: number, billingMode: billingMode, fromDateTime: fromDateTime, toDateTime: toDateTime, accountName: accountName, pageNumber: pageNumber, limit: limit, tablePreferences: paymentsDictionary, isdownload: true)); }
private void Search(HttpContext context) { byte productId = 0; int accountId = 0; string accountName = string.Empty; string mobile = string.Empty; string email = string.Empty; string number = string.Empty; byte paymentStatus = 0; byte billingMode = 1; int pageNumber = 1; byte limit = 20; DateTime fromDateTime = DateTime.Now.Date; DateTime toDateTime = DateTime.Now.AddDays(1).AddTicks(-1); JObject searchData = new JObject(); searchData = JObject.Parse(context.Request["SearchData"].ToString()); if (searchData.SelectToken("ProductId") != null && !byte.TryParse(searchData.SelectToken("ProductId").ToString(), out productId)) { GenerateErrorResponse(400, string.Format("ProductId must be a number")); } if (searchData.SelectToken("Number") != null) { number = searchData.SelectToken("Number").ToString(); } if (searchData.SelectToken("AccountName") != null) { accountName = searchData.SelectToken("AccountName").ToString(); } if (searchData.SelectToken("AccountId") != null && !int.TryParse(searchData.SelectToken("AccountId").ToString(), out accountId)) { GenerateErrorResponse(400, string.Format("AccountId must be a number")); } if (searchData.SelectToken("Mobile") != null) { mobile = searchData.SelectToken("Mobile").ToString(); } if (searchData.SelectToken("Email") != null) { email = searchData.SelectToken("Email").ToString(); } if (searchData.SelectToken("PaymentStatus") != null && !byte.TryParse(searchData.SelectToken("PaymentStatus").ToString(), out paymentStatus)) { GenerateErrorResponse(400, string.Format("PaymentStatus must be a number")); } if (searchData.SelectToken("BillingMode") != null && !byte.TryParse(searchData.SelectToken("BillingMode").ToString(), out billingMode)) { GenerateErrorResponse(400, string.Format("BillingMode must be a number")); } if (searchData.SelectToken("FromDateTime") != null && !DateTime.TryParse(searchData.SelectToken("FromDateTime").ToString(), out fromDateTime)) { GenerateErrorResponse(400, string.Format("FromDateTime is not a valid datetime")); } if (searchData.SelectToken("ToDateTime") != null && !DateTime.TryParse(searchData.SelectToken("ToDateTime").ToString(), out toDateTime)) { GenerateErrorResponse(400, string.Format("ToDateTime is not a valid datetime")); } if (searchData.SelectToken("PageNumber") != null && !int.TryParse(searchData.SelectToken("PageNumber").ToString(), out pageNumber)) { GenerateErrorResponse(400, string.Format("PageNumber must be a number")); } if (searchData.SelectToken("Limit") != null && !byte.TryParse(searchData.SelectToken("Limit").ToString(), out limit)) { GenerateErrorResponse(400, string.Format("Limit must be a number")); } TablePreferences paymentsTablePreferences = new TablePreferences("", "", true, false); Dictionary <string, TablePreferences> paymentsDictionary = new Dictionary <string, TablePreferences>(); paymentsDictionary.Add("Payments", paymentsTablePreferences); OrdersManagement.Core.Client client = new OrdersManagement.Core.Client(responseFormat: OrdersManagement.ResponseFormat.JSON); context.Response.Write(client.GetPayments(productId: productId, accountId: accountId, mobile: mobile, email: email, paymentStatus: paymentStatus, number: number, billingMode: billingMode, fromDateTime: fromDateTime, toDateTime: toDateTime, accountName: accountName, pageNumber: pageNumber, limit: limit, tablePreferences: paymentsDictionary, isdownload: false)); }