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