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