This commit is contained in:
2021-02-04 14:43:30 +00:00
parent 4d852e2320
commit 9f0c111d3d
4 changed files with 54 additions and 172 deletions

View File

@@ -80,7 +80,7 @@ namespace AyaNova.Api.Controllers
if (tableRequest.FilterId != 0)
{
DataListSavedFilterBiz filterbiz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
SavedFilter = await filterbiz.GetAsync(tableRequest.FilterId, false);
SavedFilter = await filterbiz.GetAsync(tableRequest.FilterId);
}
var DataList = DataListFactory.GetAyaDataList(tableRequest.DataListKey);
if (DataList == null)

View File

@@ -59,8 +59,8 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
// return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
@@ -113,12 +113,12 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(inObj.Id, false);
var o = await biz.GetAsync(inObj.Id);
if (o == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// if (!Authorized.HasModifyRole(HttpContext.Items, biz.BizType))
// return StatusCode(403, new ApiNotAuthorizedResponse());
try
{
@@ -151,9 +151,9 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
//check roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// //check roles
// if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
// return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
@@ -174,40 +174,6 @@ namespace AyaNova.Api.Controllers
}
/// <summary>
/// Duplicate DataListSavedFilter
/// </summary>
/// <param name="id">Create a duplicate of this items id</param>
/// <param name="apiVersion">From route path</param>
/// <returns></returns>
[HttpPost("duplicate/{id}")]
public async Task<IActionResult> Duplicate([FromRoute] long id, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
//If a user has change roles
if (!Authorized.HasCreateRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
var oSrc = await biz.GetAsync(id, false);
if (oSrc == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
//Create and validate
DataListSavedFilter o = await biz.DuplicateAsync(oSrc);
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return CreatedAtAction(nameof(DataListSavedFilterController.GetDataListSavedFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
}
/// <summary>
/// Delete DataListSavedFilter
@@ -226,12 +192,12 @@ namespace AyaNova.Api.Controllers
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
var o = await biz.GetAsync(id, false);
var o = await biz.GetAsync(id);
if (o == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// if (!Authorized.HasDeleteRole(HttpContext.Items, biz.BizType))
// return StatusCode(403, new ApiNotAuthorizedResponse());
if (!await biz.DeleteAsync(o))
return BadRequest(new ApiErrorResponse(biz.Errors));
@@ -239,32 +205,32 @@ namespace AyaNova.Api.Controllers
return NoContent();
}
/// <summary>
/// Get default Columns and Sort for DataList
/// </summary>
/// <param name="dataListKey">Key of an existing DataList</param>
/// <returns>Columns and Sort</returns>
[HttpGet("default/{dataListKey}")]
public ActionResult GetDefaultDataListSavedFilter([FromRoute] string dataListKey)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
// /// <summary>
// /// Get default Columns and Sort for DataList
// /// </summary>
// /// <param name="dataListKey">Key of an existing DataList</param>
// /// <returns>Columns and Sort</returns>
// [HttpGet("default/{dataListKey}")]
// public ActionResult GetDefaultDataListSavedFilter([FromRoute] string dataListKey)
// {
// if (!serverState.IsOpen)
// return StatusCode(503, new ApiErrorResponse(serverState.ApiErrorCode, null, serverState.Reason));
//Instantiate the business object handler
DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
// //Instantiate the business object handler
// DataListSavedFilterBiz biz = DataListSavedFilterBiz.GetBiz(ct, HttpContext);
if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
return StatusCode(403, new ApiNotAuthorizedResponse());
// if (!Authorized.HasReadFullRole(HttpContext.Items, biz.BizType))
// return StatusCode(403, new ApiNotAuthorizedResponse());
if (!ModelState.IsValid)
return BadRequest(new ApiErrorResponse(ModelState));
// if (!ModelState.IsValid)
// return BadRequest(new ApiErrorResponse(ModelState));
var o = AyaNova.DataList.DataListFactory.GetAyaDataList(dataListKey); ;
if (o == null)
return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
// var o = AyaNova.DataList.DataListFactory.GetAyaDataList(dataListKey); ;
// if (o == null)
// return NotFound(new ApiErrorResponse(ApiErrorCode.NOT_FOUND));
return Ok(ApiOkResponse.Response(new { Columns = o.DefaultColumns, SortBy = o.DefaultSortBy }));
}
// return Ok(ApiOkResponse.Response(new { Columns = o.DefaultColumns, SortBy = o.DefaultSortBy }));
// }
//------------