This commit is contained in:
2020-01-22 15:09:06 +00:00
parent 999577f9b6
commit 787fa72d85
8 changed files with 88 additions and 69 deletions

View File

@@ -46,15 +46,15 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Get full DataFilter object
/// Get full DataListTemplate object
///
/// Required roles:
/// Any (for public filter), owned only for private filter
/// </summary>
/// <param name="id"></param>
/// <returns>A single DataFilter</returns>
/// <returns>A single DataListTemplate</returns>
[HttpGet("{id}")]
public async Task<IActionResult> GetDataFilter([FromRoute] long id)
public async Task<IActionResult> GetDataListTemplate([FromRoute] long id)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -78,14 +78,14 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Get DataFilter pick list
/// Get DataListTemplate pick list
///
/// Required roles: Any
///
/// </summary>
/// <returns>List of public or owned data filters for listKey provided</returns>
[HttpGet("PickList", Name = nameof(DataFilterPickList))]
public async Task<IActionResult> DataFilterPickList([FromQuery] string ListKey)
[HttpGet("PickList", Name = nameof(DataListTemplatePickList))]
public async Task<IActionResult> DataListTemplatePickList([FromQuery] string ListKey)
{
if (serverState.IsClosed)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -103,7 +103,7 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Put (update) DataFilter
/// Put (update) DataListTemplate
///
/// Required roles:
/// Any (public filter) or owned only (private filter)
@@ -113,7 +113,7 @@ namespace AyaNova.Api.Controllers
/// <param name="inObj"></param>
/// <returns></returns>
[HttpPut("{id}")]
public async Task<IActionResult> PutDataFilter([FromRoute] long id, [FromBody] DataListTemplate inObj)
public async Task<IActionResult> PutDataListTemplate([FromRoute] long id, [FromBody] DataListTemplate inObj)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -148,7 +148,7 @@ namespace AyaNova.Api.Controllers
/// <summary>
/// Post DataFilter
/// Post DataListTemplate
///
/// Required roles:
/// BizAdminFull, InventoryFull, TechFull
@@ -157,7 +157,7 @@ namespace AyaNova.Api.Controllers
/// <param name="apiVersion">Automatically filled from route path, no need to specify in body</param>
/// <returns></returns>
[HttpPost]
public async Task<IActionResult> PostDataFilter([FromBody] DataListTemplate inObj, ApiVersion apiVersion)
public async Task<IActionResult> PostDataListTemplate([FromBody] DataListTemplate inObj, ApiVersion apiVersion)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -177,14 +177,14 @@ namespace AyaNova.Api.Controllers
if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors));
else
return CreatedAtAction(nameof(DataListTemplateController.GetDataFilter), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
return CreatedAtAction(nameof(DataListTemplateController.GetDataListTemplate), new { id = o.Id, version = apiVersion.ToString() }, new ApiCreatedResponse(o));
}
/// <summary>
/// Delete DataFilter
/// Delete DataListTemplate
///
/// Required roles:
/// Any if public otherwise creator only
@@ -193,7 +193,7 @@ namespace AyaNova.Api.Controllers
/// <param name="id"></param>
/// <returns>Ok</returns>
[HttpDelete("{id}")]
public async Task<IActionResult> DeleteDataFilter([FromRoute] long id)
public async Task<IActionResult> DeleteDataListTemplate([FromRoute] long id)
{
if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));

View File

@@ -32,8 +32,9 @@ namespace AyaNova.Biz
DEPRECATED_REUSELATER_15 = 15,
DEPRECATED_REUSELATER_16 = 16,
FileAttachment = 17,
DataFilter = 18,
FormCustom = 19
DataListFilter = 18,
FormCustom = 19,
DataListTemplate = 20
//NOTE: New objects added here need to also be added to the following classes:

View File

@@ -1,67 +1,70 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.JsonPatch;
using EnumsNET;
using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
using AyaNova.Models;
// using System.Linq;
// using System.Threading.Tasks;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.AspNetCore.Mvc;
// using Microsoft.AspNetCore.JsonPatch;
// using EnumsNET;
// using AyaNova.Util;
// using AyaNova.Api.ControllerHelpers;
// using AyaNova.Biz;
// using AyaNova.Models;
namespace AyaNova.Biz
{
// namespace AyaNova.Biz
// {
//TODO: UNTESTED, UNUSED (SO FAR)CODE
//This was just blocked out because I know I will need it in future
internal static class BizObjectExistsInDatabase
{
// //TODO: UNTESTED, UNUSED (SO FAR)CODE
// //This was just blocked out because I know I will need it in future
//REALLY? I"M BALLS DEEP IN THIS AND HAVEN'T SEEN A NEED FOR IT YET, not updating or maintaining until I see a need
// internal static class BizObjectExistsInDatabase
// {
internal static bool Exists(AyaTypeId tid)
{
return Exists(tid.ObjectType, tid.ObjectId);
}
// internal static bool Exists(AyaTypeId tid)
// {
// return Exists(tid.ObjectType, tid.ObjectId);
// }
//Returns existance status of object type and id specified in database
internal static bool Exists(AyaType aytype, long id, AyContext ct = null)
{
//new up a context??
if (ct == null)
{
ct = ServiceProviderProvider.DBContext;
}
switch (aytype)
{
case AyaType.User:
return ct.User.Any(m => m.Id == id);
case AyaType.Widget:
return ct.Widget.Any(m => m.Id == id);
case AyaType.FileAttachment:
return ct.FileAttachment.Any(m => m.Id == id);
case AyaType.DataFilter:
return ct.DataListFilter.Any(m => m.Id == id);
case AyaType.FormCustom:
return ct.FormCustom.Any(m => m.Id == id);
// //Returns existance status of object type and id specified in database
// internal static bool Exists(AyaType aytype, long id, AyContext ct = null)
// {
// //new up a context??
// if (ct == null)
// {
// ct = ServiceProviderProvider.DBContext;
// }
// switch (aytype)
// {
// case AyaType.User:
// return ct.User.Any(m => m.Id == id);
// case AyaType.Widget:
// return ct.Widget.Any(m => m.Id == id);
// case AyaType.FileAttachment:
// return ct.FileAttachment.Any(m => m.Id == id);
// case AyaType.DataListFilter:
// return ct.DataListFilter.Any(m => m.Id == id);
// case AyaType.DataListTemplate:
// return ct.DataListTemplate.Any(m => m.Id == id);
// case AyaType.FormCustom:
// return ct.FormCustom.Any(m => m.Id == id);
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
}
// default:
// throw new System.NotSupportedException($"AyaNova.BLL.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
// }
}
// }
/////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////
}//eoc
// }//eoc
}//eons
// }//eons

View File

@@ -35,8 +35,10 @@ namespace AyaNova.Biz
return new TrialBiz(dbcontext, userId, roles);
case AyaType.Locale:
return new LocaleBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
case AyaType.DataFilter:
case AyaType.DataListFilter:
return new DataListFilterBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
case AyaType.DataListTemplate:
return new DataListTemplateBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);
case AyaType.FormCustom:
return new FormCustomBiz(dbcontext, userId, ServerBootConfig.AYANOVA_DEFAULT_LANGUAGE_ID, roles);

View File

@@ -30,13 +30,17 @@ namespace AyaNova.Biz
TABLE = "afileattachment";
COLUMN = "displayfilename";
break;
case AyaType.DataFilter:
TABLE = "adatafilter";
case AyaType.DataListFilter:
TABLE = "adatalistfilter";
break;
case AyaType.FormCustom:
TABLE = "aformcustom";
COLUMN = "formkey";
break;
case AyaType.DataListTemplate:
TABLE = "adatalisttemplate";
COLUMN = "datalistkey";
break;
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
}

View File

@@ -133,9 +133,18 @@ namespace AyaNova.Biz
////////////////////////////////////////////////////////////
//DATAFILTER
//DATALISTFILTER
//
roles.Add(AyaType.DataFilter, new BizRoleSet()
roles.Add(AyaType.DataListFilter, new BizRoleSet()
{
Change = AuthorizationRoles.BizAdminFull,
ReadFullRecord = AuthorizationRoles.All
});
////////////////////////////////////////////////////////////
//DATALISTTEMPLATE
//
roles.Add(AyaType.DataListTemplate, new BizRoleSet()
{
Change = AuthorizationRoles.BizAdminFull,
ReadFullRecord = AuthorizationRoles.All

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Biz
UserId = currentUserId;
UserLocaleId = userLocaleId;
CurrentUserRoles = UserRoles;
BizType = AyaType.DataFilter;
BizType = AyaType.DataListFilter;
}
internal static DataListFilterBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)

View File

@@ -22,7 +22,7 @@ namespace AyaNova.Biz
UserId = currentUserId;
UserLocaleId = userLocaleId;
CurrentUserRoles = UserRoles;
BizType = AyaType.DataFilter;
BizType = AyaType.DataListFilter;
}
internal static DataListTemplateBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext)