This commit is contained in:
@@ -16,8 +16,21 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
Data = pr.items;
|
Data = pr.items;
|
||||||
Paging = pr.PageLinks;
|
Paging = pr.PageLinks;
|
||||||
|
|
||||||
}
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|
||||||
|
public class ApiOkWithPagingResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
public object Data { get; }
|
||||||
|
public object Paging { get; }
|
||||||
|
|
||||||
|
public ApiOkWithPagingResponse(ApiPagedResponse pr)
|
||||||
|
{
|
||||||
|
Data = pr.items;
|
||||||
|
Paging = pr.PageLinks;
|
||||||
|
|
||||||
|
}
|
||||||
|
}//eoc
|
||||||
|
|
||||||
}//eons
|
}//eons
|
||||||
@@ -11,11 +11,29 @@ namespace AyaNova.Api.ControllerHelpers
|
|||||||
|
|
||||||
public T[] items { get; }
|
public T[] items { get; }
|
||||||
public object PageLinks { get; }
|
public object PageLinks { get; }
|
||||||
|
public object Columns { get; }
|
||||||
|
|
||||||
public ApiPagedResponse(T[] returnItems, object pageLinks)
|
public ApiPagedResponse(T[] returnItems, object pageLinks, object columns = null)
|
||||||
{
|
{
|
||||||
items = returnItems;
|
items = returnItems;
|
||||||
PageLinks = pageLinks;
|
PageLinks = pageLinks;
|
||||||
|
Columns = Columns;
|
||||||
|
|
||||||
|
}
|
||||||
|
}//eoc
|
||||||
|
|
||||||
|
public class ApiPagedResponse
|
||||||
|
{
|
||||||
|
|
||||||
|
public object items { get; }
|
||||||
|
public object PageLinks { get; }
|
||||||
|
public object Columns { get; }
|
||||||
|
|
||||||
|
public ApiPagedResponse(object returnItems, object pageLinks, object columns = null)
|
||||||
|
{
|
||||||
|
items = returnItems;
|
||||||
|
PageLinks = pageLinks;
|
||||||
|
Columns = Columns;
|
||||||
|
|
||||||
}
|
}
|
||||||
}//eoc
|
}//eoc
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace AyaNova.Api.Controllers
|
|||||||
Enum.GetName(t, AyaDataType.NoType);
|
Enum.GetName(t, AyaDataType.NoType);
|
||||||
foreach (var dt in Enum.GetValues(t))
|
foreach (var dt in Enum.GetValues(t))
|
||||||
{
|
{
|
||||||
ReturnList.Add(new NameIdItem() { Name = Enum.GetName(t, dt), Id = (long) dt });
|
ReturnList.Add(new NameIdItem() { Name = Enum.GetName(t, dt), Id = (int) dt });
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -104,10 +104,10 @@ namespace AyaNova.Api.Controllers
|
|||||||
//Instantiate the business object handler
|
//Instantiate the business object handler
|
||||||
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
WidgetBiz biz = WidgetBiz.GetBiz(ct, HttpContext);
|
||||||
|
|
||||||
// ApiPagedResponse<NameIdItem> pr = biz.GetList(Url, nameof(WidgetList), pagingOptions);
|
ApiPagedResponse pr = biz.GetList(Url, nameof(List), pagingOptions).Result;
|
||||||
// return Ok(new ApiOkWithPagingResponse<NameIdItem>(pr));
|
return Ok(new ApiOkWithPagingResponse(pr));
|
||||||
string ret= biz.GetList(Url, nameof(List), pagingOptions).Result;
|
// string ret= biz.GetList(Url, nameof(List), pagingOptions).Result;
|
||||||
return Ok(ret);
|
// return Ok(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -270,7 +270,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
//get many (paged)
|
//get many (paged)
|
||||||
internal async Task<string> GetList(IUrlHelper Url, string routeName, ListOptions listOptions)
|
internal async Task<ApiPagedResponse> GetList(IUrlHelper Url, string routeName, ListOptions listOptions)
|
||||||
{
|
{
|
||||||
listOptions.Offset = listOptions.Offset ?? ListOptions.DefaultOffset;
|
listOptions.Offset = listOptions.Offset ?? ListOptions.DefaultOffset;
|
||||||
listOptions.Limit = listOptions.Limit ?? ListOptions.DefaultLimit;
|
listOptions.Limit = listOptions.Limit ?? ListOptions.DefaultLimit;
|
||||||
@@ -347,14 +347,14 @@ namespace AyaNova.Biz
|
|||||||
//TODO: Genericize the above block of building return when it's working as this code needs to be central and optimized as much as possible
|
//TODO: Genericize the above block of building return when it's working as this code needs to be central and optimized as much as possible
|
||||||
|
|
||||||
//New return code
|
//New return code
|
||||||
dynamic ret = new JObject();
|
// dynamic ret = new JObject();
|
||||||
ret.items = items;
|
// ret.items = new JArray.fromobj(items);
|
||||||
ret.pageLinks = pageLinks;
|
// ret.pageLinks = pageLinks;
|
||||||
ret.columns=ColumnsJSON;
|
// ret.columns=ColumnsJSON;
|
||||||
|
|
||||||
return ret.ToString();
|
// return ret.ToString();
|
||||||
// ApiPagedResponse<Widget> pr = new ApiPagedResponse<Widget>(items, pageLinks);
|
ApiPagedResponse pr = new ApiPagedResponse(items, pageLinks, ColumnsJSON);
|
||||||
// return pr;
|
return pr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user