This commit is contained in:
@@ -88,34 +88,6 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get filter and sort options
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited, TechFull, TechLimited, Accounting
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Filter options</returns>
|
||||
[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)
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get paged list of Users
|
||||
///
|
||||
@@ -316,7 +288,7 @@ namespace AyaNova.Api.Controllers
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="inObj"></param>
|
||||
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
|
||||
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
|
||||
/// <returns></returns>
|
||||
[HttpPost]
|
||||
public async Task<IActionResult> PostUser([FromBody] User inObj, ApiVersion apiVersion)
|
||||
|
||||
@@ -84,32 +84,6 @@ namespace AyaNova.Api.Controllers
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Get filter and sort options
|
||||
///
|
||||
/// Required roles:
|
||||
/// BizAdminFull, InventoryFull, BizAdminLimited, InventoryLimited
|
||||
///
|
||||
/// </summary>
|
||||
/// <returns>Filter options</returns>
|
||||
[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)
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get list for selection / viewing
|
||||
///
|
||||
|
||||
@@ -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<FilterField> Flds { get; set; }
|
||||
|
||||
public DEPRECATED_FilterOptions(string key)
|
||||
{
|
||||
Flds = new List<FilterField>();
|
||||
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<string> keysRequired = new List<string>();
|
||||
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;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -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<ObjectField> objectFields, string tableName)
|
||||
{
|
||||
|
||||
List<NameIdItem> listItems = new List<NameIdItem>();
|
||||
@@ -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);
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user