public void Delete(string value) { var dataDelete = new TraderDataModel(); dataDelete.TraderId = int.Parse(value); TraderDataManager.Delete(dataDelete, SessionVariables.RequestProfile); }
public static int Create(TraderDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Create", requestProfile); var newId = DBDML.RunScalarSQL("Trader.Insert", sql, DataStoreKey); return(Convert.ToInt32(newId)); }
public static string Save(TraderDataModel data, string action, RequestProfile requestProfile) { var sql = "EXEC "; switch (action) { case "Create": sql += "dbo.TraderInsert " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId) + ", " + ToSQLParameter(BaseDataModel.BaseDataColumns.ApplicationId, requestProfile.ApplicationId); break; case "Update": sql += "dbo.TraderUpdate " + " " + ToSQLParameter(BaseDataModel.BaseDataColumns.AuditId, requestProfile.AuditId); break; default: break; } sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.TraderId); sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.FundId); sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.Name); sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.Description); sql = sql + ", " + ToSQLParameter(data, TraderDataModel.DataColumns.SortOrder); return(sql); }
public TraderDataModel GetById(string value) { var dataQuery = new TraderDataModel(); dataQuery.TraderId = int.Parse(value); var result = TraderDataManager.GetEntityDetails(dataQuery, SessionVariables.RequestProfile, 1); return(result[0]); }
public static bool DoesExist(TraderDataModel data, RequestProfile requestProfile) { var doesExistRequest = new TraderDataModel(); doesExistRequest.ApplicationId = data.ApplicationId; doesExistRequest.FundId = data.FundId; doesExistRequest.Name = data.Name; var list = GetEntityDetails(doesExistRequest, requestProfile, 0); return(list.Count > 0); }
public static void Delete(TraderDataModel data, RequestProfile requestProfile) { const string sql = @"dbo.TraderDelete "; var parameters = new { AuditId = requestProfile.AuditId , TraderId = data.TraderId }; using (var dataAccess = new DataAccessBase(DataStoreKey)) { dataAccess.Connection.Execute(sql, parameters, commandType: CommandType.StoredProcedure); } }
public static List <TraderDataModel> GetEntityDetails(TraderDataModel dataQuery, RequestProfile requestProfile, int returnAuditInfo = BaseDataManager.ReturnAuditInfoOnDetails) { const string sql = @"dbo.TraderSearch "; var parameters = new { AuditId = requestProfile.AuditId , ApplicationId = requestProfile.ApplicationId , ReturnAuditInfo = returnAuditInfo , TraderId = dataQuery.TraderId , FundId = dataQuery.FundId , Name = dataQuery.Name }; List <TraderDataModel> result; using (var dataAccess = new DataAccessBase(DataStoreKey)) { result = dataAccess.Connection.Query <TraderDataModel>(sql, parameters, commandType: CommandType.StoredProcedure).ToList(); } return(result); }
public static string ToSQLParameter(TraderDataModel data, string dataColumnName) { var returnValue = "NULL"; switch (dataColumnName) { case TraderDataModel.DataColumns.TraderId: if (data.TraderId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, TraderDataModel.DataColumns.TraderId, data.TraderId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.TraderId); } break; case TraderDataModel.DataColumns.FundId: if (data.FundId != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, TraderDataModel.DataColumns.FundId, data.FundId); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.FundId); } break; case TraderDataModel.DataColumns.Fund: if (!string.IsNullOrEmpty(data.Fund)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, TraderDataModel.DataColumns.Fund, data.Fund); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.Fund); } break; case TraderDataModel.DataColumns.Name: if (!string.IsNullOrEmpty(data.Name)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, TraderDataModel.DataColumns.Name, data.Name); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.Name); } break; case TraderDataModel.DataColumns.Description: if (!string.IsNullOrEmpty(data.Description)) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_STRING_OR_DATE, TraderDataModel.DataColumns.Description, data.Description); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.Description); } break; case TraderDataModel.DataColumns.SortOrder: if (data.SortOrder != null) { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NUMBER, TraderDataModel.DataColumns.SortOrder, data.SortOrder); } else { returnValue = string.Format(SQL_TEMPLATE_PARAMETER_NULL, TraderDataModel.DataColumns.SortOrder); } break; default: returnValue = BaseDataManager.ToSQLParameter(data, dataColumnName); break; } return(returnValue); }
public static void Update(TraderDataModel data, RequestProfile requestProfile) { var sql = Save(data, "Update", requestProfile); DBDML.RunSQL("Trader.Update", sql, DataStoreKey); }
public static DataTable Search(TraderDataModel data, RequestProfile requestProfile) { var list = GetEntityDetails(data, requestProfile, 0); return(list.ToDataTable()); }