This commit is contained in:
2020-03-17 18:55:39 +00:00
parent 05bd6db5c6
commit f10ae6829e
3 changed files with 13 additions and 16 deletions

View File

@@ -7,10 +7,7 @@
//PICKLISTS:
todo: clean out unneeded leftovers from AyaPickListFieldDefinition
todo: add pickers for all CORE objects (User...?)
todo: write a guide in ayatype for what to do when making a new core object as there are a few things now
todo: rename datalistview controller and objects "PickList" to something non-clashy
todo: tests once it's all completed for server
- test regular, tags, non-text column, max-results, order, template routes etc
- test not authorized, not found

View File

@@ -101,7 +101,7 @@ namespace AyaNova.Api.Controllers
/// </summary>
/// <param name="ayaType"></param>
/// <returns>The current effective template, either a customized one or the default</returns>
[HttpGet("Template/{ayatype}")]
[HttpGet("Template/{ayaType}")]
public async Task<IActionResult> GetPickListTemplate([FromRoute] AyaType ayaType)
{
if (serverState.IsClosed)
@@ -154,12 +154,12 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// POST (replace) Pick List template
/// </summary>
/// <param name="ayaType"></param>
/// </summary>
/// <param name="template"></param>
/// <returns></returns>
[HttpPost("Template/{ayatype}")]
public async Task<IActionResult> ReplacePickListTemplate([FromRoute] AyaType ayaType, [FromBody] string template)
// [HttpPost("Template/{ayaType}")]
[HttpPost("Template")]
public async Task<IActionResult> ReplacePickListTemplate([FromBody] PickListTemplate template)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -179,7 +179,7 @@ namespace AyaNova.Api.Controllers
try
{
if (!await biz.ReplaceAsync(ayaType, template))
if (!await biz.ReplaceAsync(template))
return BadRequest(new ApiErrorResponse(biz.Errors));
}
catch (DbUpdateConcurrencyException)
@@ -197,7 +197,7 @@ namespace AyaNova.Api.Controllers
/// </summary>
/// <param name="ayaType"></param>
/// <returns>Ok</returns>
[HttpDelete("Template/{ayatype}")]
[HttpDelete("Template/{ayaType}")]
public async Task<IActionResult> DeletePickListTemplate([FromRoute] AyaType ayaType)
{
if (!serverState.IsOpen)
@@ -224,7 +224,7 @@ namespace AyaNova.Api.Controllers
/// List of all fields for pick list AyaType specified
/// </summary>
/// <returns>List of fields available for template</returns>
[HttpGet("Template/ListFields/{ayatype}")]
[HttpGet("Template/ListFields/{ayaType}")]
public ActionResult GetPickListFields([FromRoute] AyaType ayaType)
{
if (!serverState.IsOpen)

View File

@@ -152,15 +152,15 @@ namespace AyaNova.Biz
//
//put
internal async Task<bool> ReplaceAsync(AyaType ayaType, string template)
internal async Task<bool> ReplaceAsync(PickListTemplate template)
{
var o = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == (long)ayaType);
var o = await ct.PickListTemplate.FirstOrDefaultAsync(m => m.Id == (long)template.Id);
if (o == null)
{
o = new PickListTemplate();
}
o.Id = (long)ayaType;
o.Template = template;
o.Id = (long)template.Id;
o.Template = template.Template;
Validate(o);