This commit is contained in:
2018-12-12 23:26:51 +00:00
parent fa3eab11c2
commit 4060d8900f
8 changed files with 83 additions and 58 deletions

View File

@@ -6,13 +6,16 @@ namespace AyaNova.Biz
{
if (string.IsNullOrWhiteSpace(listKey))
return null;
switch (listKey)
{
//All listkeys are always lower case
case "widget":
return WidgetBiz.FilterOptions();
case "user":
return UserBiz.FilterOptions();
default:
return null;//not found

View File

@@ -151,6 +151,7 @@ namespace AyaNova.Biz
//Also all list keys are lower case for consistency
FilterOptions f = new FilterOptions("user");
f.
AddField("id", "ID", AyDataType.Integer).
AddField("name", "CommonName", AyDataType.Text).
AddField("active", "CommonActive", AyDataType.Bool).
AddField("tags", "Tags", AyDataType.Tags).
@@ -219,11 +220,11 @@ namespace AyaNova.Biz
.CountAsync();
#pragma warning restore EF1000
var cleanedItems = new System.Object[] { };
foreach (User item in items)
int itemCount = items.Count();//totalRecordCount doesn't skip and take so not usable here
var cleanedItems = new System.Object[itemCount];
for (int i = 0; i < itemCount; i++)
{
cleanedItems.Append(CleanUserForReturn(item));
cleanedItems[i] = CleanUserForReturn(items[i]);
}
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, totalRecordCount).PagingLinksObject();
@@ -421,12 +422,7 @@ namespace AyaNova.Biz
if (isNew) //Yes, no currentObj
{
//Not sure why we would care about this particular rule or why I added it? Maybe it's from widget?
// //NEW Users must be active
// if (((bool)proposedObj.Active) == false)
// {
// AddError(ValidationErrorType.InvalidValue, "Active", "New User must be active");
// }
}
//OwnerId required

View File

@@ -17,27 +17,6 @@ namespace AyaNova.Biz
internal class WidgetBiz : BizObject, IJobObject
{
public static FilterOptions FilterOptions(long localizeToLocaleId = 0)
{
//NOTE: All column names are lowercase to conform with Postgres AyaNova DB which uses lowercase for all identifiers
//Also all list keys are lower case for consistency
FilterOptions f = new FilterOptions("widget");
f.
AddField("name", "WidgetName", AyDataType.Text).
AddField("serial", "WidgetSerial", AyDataType.Integer).
AddField("notes", "WidgetNotes", AyDataType.Text).
AddField("dollaramount", "WidgetDollarAmount", AyDataType.Decimal).
AddField("active", "CommonActive", AyDataType.Bool).
AddField("startdate", "WidgetStartDate", AyDataType.Date).
AddField("count", "WidgetCount", AyDataType.Integer).
AddField("tags", "Tags", AyDataType.Tags).
AddField("enddate", "WidgetEndDate", AyDataType.Date);
if (localizeToLocaleId != 0)
f.Localize(localizeToLocaleId);
return f;
}
internal WidgetBiz(AyContext dbcontext, long currentUserId, long userLocaleId, AuthorizationRoles UserRoles)
{
@@ -162,13 +141,34 @@ namespace AyaNova.Biz
public static FilterOptions FilterOptions(long localizeToLocaleId = 0)
{
//NOTE: All column names are lowercase to conform with Postgres AyaNova DB which uses lowercase for all identifiers
//Also all list keys are lower case for consistency
FilterOptions f = new FilterOptions("widget");
f.
AddField("id", "ID", AyDataType.Integer).
AddField("name", "WidgetName", AyDataType.Text).
AddField("serial", "WidgetSerial", AyDataType.Integer).
AddField("notes", "WidgetNotes", AyDataType.Text).
AddField("dollaramount", "WidgetDollarAmount", AyDataType.Decimal).
AddField("active", "CommonActive", AyDataType.Bool).
AddField("startdate", "WidgetStartDate", AyDataType.Date).
AddField("count", "WidgetCount", AyDataType.Integer).
AddField("tags", "Tags", AyDataType.Tags).
AddField("enddate", "WidgetEndDate", AyDataType.Date);
if (localizeToLocaleId != 0)
f.Localize(localizeToLocaleId);
return f;
}
//get many (paged)
internal async Task<ApiPagedResponse<Widget>> GetManyAsync(IUrlHelper Url, string routeName, PagingOptions pagingOptions)
{
pagingOptions.Offset = pagingOptions.Offset ?? PagingOptions.DefaultOffset;
pagingOptions.Limit = pagingOptions.Limit ?? PagingOptions.DefaultLimit;
//BUILD THE QUERY
//base query
var q = "SELECT *, xmin FROM AWIDGET ";
@@ -182,7 +182,7 @@ namespace AyaNova.Biz
q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), UserId);
//BUILD ORDER BY AND APPEND IT
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
}
else
{

View File

@@ -1441,5 +1441,6 @@
"WidgetEndDate":"Enddatum",
"WidgetNotes":"Notizen",
"RowsPerPage":"Zeilen pro Seite",
"Tags":"Kategorien"
"Tags":"Kategorien",
"ID":"ID"
}

View File

@@ -1440,7 +1440,8 @@
"WidgetEndDate":"End",
"WidgetNotes":"Notes",
"RowsPerPage":"Rows per page",
"Tags":"Tags"
"Tags":"Tags",
"ID":"ID"
}

View File

@@ -1441,5 +1441,6 @@
"WidgetEndDate":"Fecha de fin",
"WidgetNotes":"Notas",
"RowsPerPage":"Filas por página",
"Tags":"Etiquetas"
"Tags":"Etiquetas",
"ID":"ID"
}

View File

@@ -1440,5 +1440,6 @@
"WidgetEndDate":"Date de fin",
"WidgetNotes":"Notes",
"RowsPerPage":"Lignes par page",
"Tags":"Balises"
"Tags":"Balises",
"ID":"ID"
}