This commit is contained in:
2020-02-12 17:55:47 +00:00
parent d71de81dd9
commit e531a913f8
6 changed files with 19 additions and 19 deletions

View File

@@ -103,7 +103,7 @@ namespace AyaNova.Api.Controllers
/// <param name="inObj"></param> /// <param name="inObj"></param>
/// <returns></returns> /// <returns></returns>
[HttpPut("{id}")] [HttpPut("{id}")]
public async Task<IActionResult> PutDataFilter([FromRoute] long id, [FromBody] DataListFilter inObj) public async Task<IActionResult> PutDataFilter([FromRoute] long id, [FromBody] DataListSortFilter inObj)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -144,7 +144,7 @@ namespace AyaNova.Api.Controllers
/// <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> PostDataFilter([FromBody] DataListFilter inObj, ApiVersion apiVersion) public async Task<IActionResult> PostDataFilter([FromBody] DataListSortFilter inObj, ApiVersion apiVersion)
{ {
if (!serverState.IsOpen) if (!serverState.IsOpen)
return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason)); return StatusCode(503, new ApiErrorResponse(ApiErrorCode.API_CLOSED, null, serverState.Reason));
@@ -160,7 +160,7 @@ namespace AyaNova.Api.Controllers
return BadRequest(new ApiErrorResponse(ModelState)); return BadRequest(new ApiErrorResponse(ModelState));
//Create and validate //Create and validate
DataListFilter o = await biz.CreateAsync(inObj); DataListSortFilter o = await biz.CreateAsync(inObj);
if (o == null) if (o == null)
return BadRequest(new ApiErrorResponse(biz.Errors)); return BadRequest(new ApiErrorResponse(biz.Errors));
else else

View File

@@ -37,7 +37,7 @@ namespace AyaNova.Biz
case AyaType.FileAttachment: case AyaType.FileAttachment:
return await ct.FileAttachment.AnyAsync(m => m.Id == id); return await ct.FileAttachment.AnyAsync(m => m.Id == id);
case AyaType.DataListFilter: case AyaType.DataListFilter:
return await ct.DataListFilter.AnyAsync(m => m.Id == id); return await ct.DataListSortFilter.AnyAsync(m => m.Id == id);
case AyaType.DataListTemplate: case AyaType.DataListTemplate:
return await ct.DataListTemplate.AnyAsync(m => m.Id == id); return await ct.DataListTemplate.AnyAsync(m => m.Id == id);
case AyaType.FormCustom: case AyaType.FormCustom:

View File

@@ -40,14 +40,14 @@ namespace AyaNova.Biz
//EXISTS //EXISTS
internal async Task<bool> ExistsAsync(long id) internal async Task<bool> ExistsAsync(long id)
{ {
return await ct.DataListFilter.AnyAsync(e => e.Id == id); return await ct.DataListSortFilter.AnyAsync(e => e.Id == id);
} }
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE //CREATE
internal async Task<DataListFilter> CreateAsync(DataListFilter inObj) internal async Task<DataListSortFilter> CreateAsync(DataListSortFilter inObj)
{ {
await ValidateAsync(inObj, true); await ValidateAsync(inObj, true);
if (HasErrors) if (HasErrors)
@@ -55,11 +55,11 @@ namespace AyaNova.Biz
else else
{ {
//do stuff with datafilter //do stuff with datafilter
DataListFilter outObj = inObj; DataListSortFilter outObj = inObj;
outObj.UserId = UserId; outObj.UserId = UserId;
await ct.DataListFilter.AddAsync(outObj); await ct.DataListSortFilter.AddAsync(outObj);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Handle child and associated items: //Handle child and associated items:
@@ -81,10 +81,10 @@ namespace AyaNova.Biz
/// GET /// GET
//Get one //Get one
internal async Task<DataListFilter> GetAsync(long fetchId, bool logTheGetEvent = true) internal async Task<DataListSortFilter> GetAsync(long fetchId, bool logTheGetEvent = true)
{ {
//This is simple so nothing more here, but often will be copying to a different output object or some other ops //This is simple so nothing more here, but often will be copying to a different output object or some other ops
var ret = await ct.DataListFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId)); var ret = await ct.DataListSortFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
if (logTheGetEvent && ret != null) if (logTheGetEvent && ret != null)
{ {
//Log //Log
@@ -102,7 +102,7 @@ namespace AyaNova.Biz
List<NameIdItem> items = new List<NameIdItem>(); List<NameIdItem> items = new List<NameIdItem>();
if (!string.IsNullOrWhiteSpace(listKey)) if (!string.IsNullOrWhiteSpace(listKey))
{ {
items = await ct.DataListFilter items = await ct.DataListSortFilter
.AsNoTracking() .AsNoTracking()
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId)) .Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
.OrderBy(m => m.Name) .OrderBy(m => m.Name)
@@ -124,7 +124,7 @@ namespace AyaNova.Biz
// //
//put //put
internal async Task<bool> PutAsync(DataListFilter dbObj, DataListFilter inObj) internal async Task<bool> PutAsync(DataListSortFilter dbObj, DataListSortFilter inObj)
{ {
//preserve the owner ID if none was specified //preserve the owner ID if none was specified
if (inObj.UserId == 0) if (inObj.UserId == 0)
@@ -154,7 +154,7 @@ namespace AyaNova.Biz
//////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////
//DELETE //DELETE
// //
internal async Task<bool> DeleteAsync(DataListFilter dbObj) internal async Task<bool> DeleteAsync(DataListSortFilter dbObj)
{ {
//Determine if the object can be deleted, do the deletion tentatively //Determine if the object can be deleted, do the deletion tentatively
//Probably also in here deal with tags and associated search text etc //Probably also in here deal with tags and associated search text etc
@@ -164,7 +164,7 @@ namespace AyaNova.Biz
if (HasErrors) if (HasErrors)
return false; return false;
ct.DataListFilter.Remove(dbObj); ct.DataListSortFilter.Remove(dbObj);
await ct.SaveChangesAsync(); await ct.SaveChangesAsync();
//Delete sibling objects //Delete sibling objects
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
// //
//Can save or update? //Can save or update?
private async Task ValidateAsync(DataListFilter inObj, bool isNew) private async Task ValidateAsync(DataListSortFilter inObj, bool isNew)
{ {
//UserId required //UserId required
@@ -209,7 +209,7 @@ namespace AyaNova.Biz
if (!PropertyHasErrors("Name")) if (!PropertyHasErrors("Name"))
{ {
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false //Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
if (await ct.DataListFilter.AnyAsync(m => m.Name == inObj.Name && m.Id != inObj.Id)) if (await ct.DataListSortFilter.AnyAsync(m => m.Name == inObj.Name && m.Id != inObj.Id))
{ {
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name"); AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
} }

View File

@@ -17,7 +17,7 @@ namespace AyaNova.Models
public virtual DbSet<OpsJobLog> OpsJobLog { get; set; } public virtual DbSet<OpsJobLog> OpsJobLog { get; set; }
public virtual DbSet<Locale> Locale { get; set; } public virtual DbSet<Locale> Locale { get; set; }
public virtual DbSet<LocaleItem> LocaleItem { get; set; } public virtual DbSet<LocaleItem> LocaleItem { get; set; }
public virtual DbSet<DataListFilter> DataListFilter { get; set; } public virtual DbSet<DataListSortFilter> DataListSortFilter { get; set; }
public virtual DbSet<Tag> Tag { get; set; } public virtual DbSet<Tag> Tag { get; set; }
public virtual DbSet<FormCustom> FormCustom { get; set; } public virtual DbSet<FormCustom> FormCustom { get; set; }
public virtual DbSet<DataListTemplate> DataListTemplate { get; set; } public virtual DbSet<DataListTemplate> DataListTemplate { get; set; }

View File

@@ -4,7 +4,7 @@ using System.ComponentModel.DataAnnotations;
namespace AyaNova.Models namespace AyaNova.Models
{ {
public partial class DataListFilter public partial class DataListSortFilter
{ {
public long Id { get; set; } public long Id { get; set; }
public uint ConcurrencyToken { get; set; } public uint ConcurrencyToken { get; set; }

View File

@@ -266,7 +266,7 @@ namespace AyaNova.Util
{ {
LogUpdateMessage(log); LogUpdateMessage(log);
await ExecQueryAsync("CREATE TABLE adatalistfilter (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," + await ExecQueryAsync("CREATE TABLE adatalistsortfilter (id BIGSERIAL PRIMARY KEY, userId bigint not null, name varchar(255) not null, public bool not null," +
"listkey varchar(255) not null, filter text, sort text, UNIQUE(name))"); "listkey varchar(255) not null, filter text, sort text, UNIQUE(name))");
await ExecQueryAsync("CREATE TABLE adatalisttemplate (id BIGSERIAL PRIMARY KEY, datalistkey text not null, template text, UNIQUE(datalistkey))"); await ExecQueryAsync("CREATE TABLE adatalisttemplate (id BIGSERIAL PRIMARY KEY, datalistkey text not null, template text, UNIQUE(datalistkey))");