Skip to content

Instantly share code, notes, and snippets.

View JoseGonzalez321's full-sized avatar
💭
GraphQL is interesting

Jose Gonzalez JoseGonzalez321

💭
GraphQL is interesting
View GitHub Profile
var Person = (name, nickname) => {
return {
getFullName: () => name + ' (' + nickname + ')',
getName: () => 'Your name is: ' + name,
getNickname: () => 'People call you: ' + nickname,
};
};
var me = Person("Jose", "El Jefe");
public DataTable GetData(DateTime valueDate,
string branch,
string levelName,
string subLevelName,
string finalLevelName)
{
if (valueDate.equals(DateTime.Min) ||
string.IsNullOrEmpty(branch) ||
string.IsNullOrEmpty(levelName) ||
string.IsNullOrEmpty(subLevelName) ||
@JoseGonzalez321
JoseGonzalez321 / Are-Params-Valid.cs
Last active January 19, 2016 19:33
Simple validation for parameter types
private static bool AreParamsValid(object[] parameters)
{
if (parameters == null || parameters.Length == 0)
return false;
var result = true;
parameters.ForEach(p =>
{
if (p is string)
public DataTable GetData(DateTime valueDate,
string branch,
string levelName,
string subLevelName,
string finalLevelName)
{
var parameters = new object[] { valueDate, branch, levelName, subLevelName, finalLevelName};
var paramsValid = AreParamsValid(parameters);
if (!paramsValid)
public DataTable GetTopLevel(DateTime valueDate, string branch)
{
const string storedProc = "GetTopLevel";
var parameters = new Dictionary<string, object>
{
{ParamConstant.ValueDate, valueDate},
{ParamConstant.Branch, branch}
};
public DataTable GetFirstLevel(DateTime valueDate, string branch, string levelName)
{
const string storedProc = "GetLevelOne";
var parameters = new Dictionary<string, object>
{
{ParamConstant.ValueDate, valueDate},
{ParamConstant.Branch, branch},
{ParamConstant.LevelName, levelName},
};
public DataTable GetSecondLevel(DateTime valueDate,
string branch,
string levelName,
string subLevelName)
{
const string storedProc = "GetLevelTwo";
var parameters = new Dictionary<string, object>
{
{ParamConstant.ValueDate, valueDate},
public Enum Level
{
Top,
One,
Two
}
public class StoredProcParam
{
public const string ValueDate = "ValueDate";
private static Dictionary<string, object> SetupStoredProcParameters(Level level,
DateTime valueDate,
string branch,
string levelName,
string subLevelName)
{
var parameters = new Dictionary<string, object>();
switch(level)
{
case Level.Top:
public DataTable GetTopLevel(DateTime valueDate, string branch)
{
var parameters = SetupStoredProcParameters(Level.Top, valueDate, branch);
const string storedProc = "GetTopLevel";
var result = storedProc.ToDataTable(dbConnection, parameters);
return result;
}