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>
|
/// <summary>
|
||||||
/// Get paged list of Users
|
/// Get paged list of Users
|
||||||
///
|
///
|
||||||
@@ -316,7 +288,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="inObj"></param>
|
/// <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>
|
/// <returns></returns>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
public async Task<IActionResult> PostUser([FromBody] User inObj, ApiVersion apiVersion)
|
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>
|
/// <summary>
|
||||||
/// Get list for selection / viewing
|
/// 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 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>();
|
List<NameIdItem> listItems = new List<NameIdItem>();
|
||||||
@@ -40,7 +40,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//BUILD WHERE AND APPEND IT
|
//BUILD WHERE AND APPEND IT
|
||||||
//qCriteria = FilterSqlCriteriaBuilder.DataFilterToSQLCriteria(TheFilter, WidgetBiz.FilterOptions(), userId);
|
//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
|
//BUILD ORDER BY AND APPEND IT
|
||||||
qSort = FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
qSort = FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||||
|
|||||||
@@ -153,24 +153,24 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
public static FilterOptions FilterOptions(long localizeToLocaleId = 0)
|
// 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
|
// //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
|
// //Also all list keys are lower case for consistency
|
||||||
FilterOptions f = new FilterOptions("user");
|
// FilterOptions f = new FilterOptions("user");
|
||||||
f.
|
// f.
|
||||||
AddField("id", "ID", AyDataType.Integer).
|
// AddField("id", "ID", AyDataType.Integer).
|
||||||
AddField("name", "Name", AyDataType.Text).
|
// AddField("name", "Name", AyDataType.Text).
|
||||||
AddField("active", "Active", AyDataType.Bool).
|
// AddField("active", "Active", AyDataType.Bool).
|
||||||
AddField("tags", "Tags", AyDataType.Tags).
|
// AddField("tags", "Tags", AyDataType.Tags).
|
||||||
AddField("EmployeeNumber", "UserEmployeeNumber", AyDataType.Text).
|
// AddField("EmployeeNumber", "UserEmployeeNumber", AyDataType.Text).
|
||||||
AddField("usertype", "UserUserType", AyDataType.Enum).
|
// AddField("usertype", "UserUserType", AyDataType.Enum).
|
||||||
AddField("notes", "UserNotes", AyDataType.Text);
|
// AddField("notes", "UserNotes", AyDataType.Text);
|
||||||
|
|
||||||
if (localizeToLocaleId != 0)
|
// if (localizeToLocaleId != 0)
|
||||||
f.Localize(localizeToLocaleId);
|
// f.Localize(localizeToLocaleId);
|
||||||
return f;
|
// return f;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//get many (paged)
|
//get many (paged)
|
||||||
@@ -191,7 +191,7 @@ namespace AyaNova.Biz
|
|||||||
var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId);
|
var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId);
|
||||||
|
|
||||||
//BUILD WHERE AND APPEND IT
|
//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
|
//BUILD ORDER BY AND APPEND IT
|
||||||
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||||
@@ -252,7 +252,7 @@ namespace AyaNova.Biz
|
|||||||
pagingOptions.Limit = pagingOptions.Limit ?? ListOptions.DefaultLimit;
|
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();
|
var pageLinks = new PaginationLinkBuilder(Url, routeName, null, pagingOptions, ret.TotalRecordCount).PagingLinksObject();
|
||||||
|
|
||||||
|
|||||||
@@ -266,27 +266,27 @@ namespace AyaNova.Biz
|
|||||||
// LISTS
|
// LISTS
|
||||||
//
|
//
|
||||||
|
|
||||||
public static FilterOptions FilterOptions(long localizeToLocaleId = 0)
|
// 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
|
// //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
|
// //Also all list keys are lower case for consistency
|
||||||
FilterOptions f = new FilterOptions("widget");
|
// FilterOptions f = new FilterOptions("widget");
|
||||||
f.
|
// f.
|
||||||
AddField("id", "ID", AyDataType.Integer).
|
// AddField("id", "ID", AyDataType.Integer).
|
||||||
AddField("name", "WidgetName", AyDataType.Text).
|
// AddField("name", "WidgetName", AyDataType.Text).
|
||||||
AddField("serial", "WidgetSerial", AyDataType.Integer).
|
// AddField("serial", "WidgetSerial", AyDataType.Integer).
|
||||||
AddField("notes", "WidgetNotes", AyDataType.Text).
|
// AddField("notes", "WidgetNotes", AyDataType.Text).
|
||||||
AddField("dollaramount", "WidgetDollarAmount", AyDataType.Decimal).
|
// AddField("dollaramount", "WidgetDollarAmount", AyDataType.Decimal).
|
||||||
AddField("active", "Active", AyDataType.Bool).
|
// AddField("active", "Active", AyDataType.Bool).
|
||||||
AddField("startdate", "WidgetStartDate", AyDataType.Date).
|
// AddField("startdate", "WidgetStartDate", AyDataType.Date).
|
||||||
AddField("count", "WidgetCount", AyDataType.Integer).
|
// AddField("count", "WidgetCount", AyDataType.Integer).
|
||||||
AddField("tags", "Tags", AyDataType.Tags).
|
// AddField("tags", "Tags", AyDataType.Tags).
|
||||||
AddField("enddate", "WidgetEndDate", AyDataType.Date);
|
// AddField("enddate", "WidgetEndDate", AyDataType.Date);
|
||||||
|
|
||||||
if (localizeToLocaleId != 0)
|
// if (localizeToLocaleId != 0)
|
||||||
f.Localize(localizeToLocaleId);
|
// f.Localize(localizeToLocaleId);
|
||||||
return f;
|
// return f;
|
||||||
}
|
// }
|
||||||
|
|
||||||
|
|
||||||
//get many (paged)
|
//get many (paged)
|
||||||
@@ -305,7 +305,7 @@ namespace AyaNova.Biz
|
|||||||
var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId);
|
var TheFilter = await ct.DataFilter.FirstOrDefaultAsync(x => x.Id == pagingOptions.DataFilterId);
|
||||||
|
|
||||||
//BUILD WHERE AND APPEND IT
|
//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
|
//BUILD ORDER BY AND APPEND IT
|
||||||
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
q = q + FilterSqlOrderByBuilder.DataFilterToSQLOrderBy(TheFilter);
|
||||||
|
|||||||
Reference in New Issue
Block a user