From d4324949b2e61f10075b979a21a2f2d222419d27 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Tue, 14 Jan 2020 19:17:26 +0000 Subject: [PATCH] --- server/AyaNova/Controllers/UserController.cs | 30 +---------- .../AyaNova/Controllers/WidgetController.cs | 26 --------- server/AyaNova/biz/FilterOptions.cs | 54 ------------------- .../AyaNova/biz/FilterOptionsFromListKey.cs | 33 ------------ server/AyaNova/biz/PickListFetcher.cs | 4 +- server/AyaNova/biz/UserBiz.cs | 38 ++++++------- server/AyaNova/biz/WidgetBiz.cs | 42 +++++++-------- 7 files changed, 43 insertions(+), 184 deletions(-) delete mode 100644 server/AyaNova/biz/FilterOptions.cs delete mode 100644 server/AyaNova/biz/FilterOptionsFromListKey.cs diff --git a/server/AyaNova/Controllers/UserController.cs b/server/AyaNova/Controllers/UserController.cs index 4e01023e..9ce56a69 100644 --- a/server/AyaNova/Controllers/UserController.cs +++ b/server/AyaNova/Controllers/UserController.cs @@ -88,34 +88,6 @@ namespace AyaNova.Api.Controllers } - - /// - /// Get filter and sort options - /// - /// Required roles: - /// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting - /// - /// - /// Filter options - [HttpGet("FilterOptions")] - public ActionResult FilterOptions() - { - if (serverState.IsClosed) - return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); - - //Instantiate the business object handler - UserBiz biz = UserBiz.GetBiz(ct, HttpContext); - - if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) - return StatusCode(403, new ApiNotAuthorizedResponse()); - - return Ok(new - { - data = UserBiz.FilterOptions(biz.UserLocaleId) - }); - } - - /// /// Get paged list of Users /// @@ -316,7 +288,7 @@ namespace AyaNova.Api.Controllers /// /// /// - /// Automatically filled from route path, no need to specify in body + /// Automatically filled from route path, no need to specify in body /// [HttpPost] public async Task PostUser([FromBody] User inObj, ApiVersion apiVersion) diff --git a/server/AyaNova/Controllers/WidgetController.cs b/server/AyaNova/Controllers/WidgetController.cs index 19861310..6e8b0314 100644 --- a/server/AyaNova/Controllers/WidgetController.cs +++ b/server/AyaNova/Controllers/WidgetController.cs @@ -84,32 +84,6 @@ namespace AyaNova.Api.Controllers } - /// - /// Get filter and sort options - /// - /// Required roles: - /// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited - /// - /// - /// Filter options - [HttpGet("FilterOptions")] - public ActionResult FilterOptions() - { - if (serverState.IsClosed) - return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); - - //Instantiate the business object handler - WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext); - - if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType)) - return StatusCode(403, new ApiNotAuthorizedResponse()); - - return Ok(new - { - data = WidgetBiz.FilterOptions(biz.UserLocaleId) - }); - } - /// /// Get list for selection / viewing /// diff --git a/server/AyaNova/biz/FilterOptions.cs b/server/AyaNova/biz/FilterOptions.cs deleted file mode 100644 index 0730fcf7..00000000 --- a/server/AyaNova/biz/FilterOptions.cs +++ /dev/null @@ -1,54 +0,0 @@ -using System; -using System.Collections.Generic; -using AyaNova.Biz; - - -namespace AyaNova.Biz -{ - - public class DEPRECATED_FilterOptions - { - public string Key { get; set; } - public List Flds { get; set; } - - public DEPRECATED_FilterOptions(string key) - { - Flds = new List(); - Key = key; - } - - public DEPRECATED_FilterOptions AddField(string FieldName, string LocaleKey, string DataType) - { - Flds.Add(new FilterField(FieldName, LocaleKey, DataType)); - return this; - } - - internal void Localize(long userLocaleId) - { - List keysRequired = new List(); - foreach (FilterField f in Flds) - { - keysRequired.Add(f.Lt); - } - var trans = LocaleBiz.GetSubsetStatic(keysRequired, userLocaleId).Result; - foreach (FilterField f in Flds) - { - f.Lt = trans[f.Lt]; - } - } - } - - public class FilterField - { - public string Fld { get; set; } - public string Lt { get; set; } - public string Type { get; set; } - public FilterField(string fld, string lt, string type) - { - Fld = fld; - Lt = lt; - Type = type; - - } - } -} diff --git a/server/AyaNova/biz/FilterOptionsFromListKey.cs b/server/AyaNova/biz/FilterOptionsFromListKey.cs deleted file mode 100644 index 076be49e..00000000 --- a/server/AyaNova/biz/FilterOptionsFromListKey.cs +++ /dev/null @@ -1,33 +0,0 @@ -namespace AyaNova.Biz -{ - internal static class DEPRECATED_FilterOptionsFromObjectKey - { - internal static DEPRECATED_FilterOptions Get(string listKey) - { - 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 - } - - } - - - ///////////////////////////////////////////////////////////////////// - - }//eoc - - -}//eons - diff --git a/server/AyaNova/biz/PickListFetcher.cs b/server/AyaNova/biz/PickListFetcher.cs index 25ad6cb8..5e6c9700 100644 --- a/server/AyaNova/biz/PickListFetcher.cs +++ b/server/AyaNova/biz/PickListFetcher.cs @@ -10,7 +10,7 @@ namespace AyaNova.Biz internal static class PickListFetcher { - internal static PickListResult GetPickList(AyContext ct, long userId, ListOptions pagingOptions, FilterOptions filterOptions, string tableName) + internal static PickListResult GetPickList(AyContext ct, long userId, ListOptions pagingOptions, List objectFields, string tableName) { List listItems = new List(); @@ -40,7 +40,7 @@ namespace AyaNova.Biz //BUILD WHERE AND APPEND IT //qCriteria = FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), userId); - qCriteria = FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, filterOptions, userId); + qCriteria = FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, objectFields, userId); //BUILD ORDER BY AND APPEND IT qSort = FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter); diff --git a/server/AyaNova/biz/UserBiz.cs b/server/AyaNova/biz/UserBiz.cs index 01c3b484..a4706e9d 100644 --- a/server/AyaNova/biz/UserBiz.cs +++ b/server/AyaNova/biz/UserBiz.cs @@ -153,24 +153,24 @@ 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("user"); - f. - AddField("id", "ID", AyDataType.Integer). - AddField("name", "Name", AyDataType.Text). - AddField("active", "Active", AyDataType.Bool). - AddField("tags", "Tags", AyDataType.Tags). - AddField("EmployeeNumber", "UserEmployeeNumber", AyDataType.Text). - AddField("usertype", "UserUserType", AyDataType.Enum). - AddField("notes", "UserNotes", AyDataType.Text); + // 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("user"); + // f. + // AddField("id", "ID", AyDataType.Integer). + // AddField("name", "Name", AyDataType.Text). + // AddField("active", "Active", AyDataType.Bool). + // AddField("tags", "Tags", AyDataType.Tags). + // AddField("EmployeeNumber", "UserEmployeeNumber", AyDataType.Text). + // AddField("usertype", "UserUserType", AyDataType.Enum). + // AddField("notes", "UserNotes", AyDataType.Text); - if (localizeToLocaleId != 0) - f.Localize(localizeToLocaleId); - return f; - } + // if (localizeToLocaleId != 0) + // f.Localize(localizeToLocaleId); + // return f; + // } //get many (paged) @@ -191,7 +191,7 @@ namespace AyaNova.Biz var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId); //BUILD WHERE AND APPEND IT - q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, UserBiz.FilterOptions(), UserId); + q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, ObjectFields.ObjectFieldsList("user"), UserId); //BUILD ORDER BY AND APPEND IT q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter); @@ -252,7 +252,7 @@ namespace AyaNova.Biz pagingOptions.Limit = pagingOptions.Limit ?? ListOptions.DefaultLimit; - var ret = PickListFetcher.GetPickList(ct, UserId, pagingOptions, FilterOptions(), "auser"); + var ret = PickListFetcher.GetPickList(ct, UserId, pagingOptions, ObjectFields.ObjectFieldsList("user"), "auser"); var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, ret.TotalRecordCount).PagingLinksObject(); diff --git a/server/AyaNova/biz/WidgetBiz.cs b/server/AyaNova/biz/WidgetBiz.cs index b36cae54..45a9125f 100644 --- a/server/AyaNova/biz/WidgetBiz.cs +++ b/server/AyaNova/biz/WidgetBiz.cs @@ -266,27 +266,27 @@ namespace AyaNova.Biz // LISTS // - 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", "Active", AyDataType.Bool). - AddField("startdate", "WidgetStartDate", AyDataType.Date). - AddField("count", "WidgetCount", AyDataType.Integer). - AddField("tags", "Tags", AyDataType.Tags). - AddField("enddate", "WidgetEndDate", AyDataType.Date); + // 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", "Active", 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; - } + // if (localizeToLocaleId != 0) + // f.Localize(localizeToLocaleId); + // return f; + // } //get many (paged) @@ -305,7 +305,7 @@ namespace AyaNova.Biz var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId); //BUILD WHERE AND APPEND IT - q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), UserId); + q = q + FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, ObjectFields.ObjectFieldsList("widget"), UserId); //BUILD ORDER BY AND APPEND IT q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);