You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
using CustomerOnlineRemit.Common.Configuration; using CustomerOnlineRemit.Common.Model.Customer; using Newtonsoft.Json; using System.Data; using System.Text.Json.Serialization;
namespace CustomerOnlineRemit.Common.Helper { public static class Utilities { public static string GetRowCellValue(object v) { try { if (v == DBNull.Value) return ""; else return v.ToString(); } catch (Exception) { return ""; } }
public static decimal TryParseDecimal(string amount) { decimal output; decimal.TryParse(amount, out output);
return output; }
public static dynamic ParseTableData(string flag, DataTable dt) { dynamic list = null; if (flag.ToLower().Equals("customertxn")) { List<CustomerTransaction> obj = new List<CustomerTransaction>(); foreach (DataRow item in dt.Rows) { obj.Add(new CustomerTransaction { Id = Convert.ToString(item["Id"]), Amount = Convert.ToString(item["Amount"]), Status = Convert.ToString(item["Status"]) }); } list = obj; } else if (flag.ToLower().Equals("customerreceiver")) { List<CustomerModel> obj = new List<CustomerModel>(); foreach (DataRow item in dt.Rows) { obj.Add(new CustomerModel { Id = Convert.ToString(item["Id"]), Name = Convert.ToString(item["Name"]), Country = Convert.ToString(item["Country"]), TransactionType = Convert.ToString(item["TransactionType"]) }); } list = obj; } return list; }
public static string ReadFromAppSettings(string key, string defValue = "") { return ConfigurationManager.AppSettings[key] ?? defValue; }
public static string SerializeObject(object obj) { return JsonConvert.SerializeObject(obj); } } }
|