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