This commit is contained in:
@@ -15,7 +15,7 @@ and also lists all the fields filterable, their type and the locale key to displ
|
|||||||
- List key
|
- List key
|
||||||
Certain types have extended abilities, for example dates have the classic floating AyaNova date ranges pre-defined or specific dates
|
Certain types have extended abilities, for example dates have the classic floating AyaNova date ranges pre-defined or specific dates
|
||||||
Filters are saved to the database:
|
Filters are saved to the database:
|
||||||
- Filter: Name, OwnerId, Public, ListKey, Filter (Json string)
|
- Filter: Name, UserId, Public, ListKey, Filter (Json string)
|
||||||
- ListKey is always lower case to match biz object list key name
|
- ListKey is always lower case to match biz object list key name
|
||||||
- Filter format:
|
- Filter format:
|
||||||
- Array [{fld:"fieldname",op:"See filtercomparisonoperator class",value:"compareValue"},...] these are all AND in sql, no OR
|
- Array [{fld:"fieldname",op:"See filtercomparisonoperator class",value:"compareValue"},...] these are all AND in sql, no OR
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
//do stuff with datafilter
|
//do stuff with datafilter
|
||||||
DataFilter outObj = inObj;
|
DataFilter outObj = inObj;
|
||||||
outObj.OwnerId = UserId;
|
outObj.UserId = UserId;
|
||||||
|
|
||||||
|
|
||||||
await ct.DataFilter.AddAsync(outObj);
|
await ct.DataFilter.AddAsync(outObj);
|
||||||
@@ -91,7 +91,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
//do stuff with datafilter
|
//do stuff with datafilter
|
||||||
DataFilter outObj = inObj;
|
DataFilter outObj = inObj;
|
||||||
outObj.OwnerId = UserId;
|
outObj.UserId = UserId;
|
||||||
|
|
||||||
|
|
||||||
TempContext.DataFilter.Add(outObj);
|
TempContext.DataFilter.Add(outObj);
|
||||||
@@ -117,7 +117,7 @@ namespace AyaNova.Biz
|
|||||||
internal async Task<DataFilter> GetAsync(long fetchId)
|
internal async Task<DataFilter> GetAsync(long fetchId)
|
||||||
{
|
{
|
||||||
//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.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.OwnerId == UserId));
|
var ret = await ct.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
|
||||||
if (ret != null)
|
if (ret != null)
|
||||||
{
|
{
|
||||||
//Log
|
//Log
|
||||||
@@ -135,7 +135,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
items = await ct.DataFilter
|
items = await ct.DataFilter
|
||||||
.AsNoTracking()
|
.AsNoTracking()
|
||||||
.Where(m => m.ListKey == listKey && (m.Public == true || m.OwnerId == UserId))
|
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
|
||||||
.OrderBy(m => m.Name)
|
.OrderBy(m => m.Name)
|
||||||
.Select(m => new NameIdItem()
|
.Select(m => new NameIdItem()
|
||||||
{
|
{
|
||||||
@@ -158,8 +158,8 @@ namespace AyaNova.Biz
|
|||||||
internal bool Put(DataFilter dbObj, DataFilter inObj)
|
internal bool Put(DataFilter dbObj, DataFilter inObj)
|
||||||
{
|
{
|
||||||
//preserve the owner ID if none was specified
|
//preserve the owner ID if none was specified
|
||||||
if (inObj.OwnerId == 0)
|
if (inObj.UserId == 0)
|
||||||
inObj.OwnerId = dbObj.OwnerId;
|
inObj.UserId = dbObj.UserId;
|
||||||
|
|
||||||
//Replace the db object with the PUT object
|
//Replace the db object with the PUT object
|
||||||
CopyObject.Copy(inObj, dbObj, "Id");
|
CopyObject.Copy(inObj, dbObj, "Id");
|
||||||
@@ -216,16 +216,14 @@ namespace AyaNova.Biz
|
|||||||
private void Validate(DataFilter inObj, bool isNew)
|
private void Validate(DataFilter inObj, bool isNew)
|
||||||
{
|
{
|
||||||
|
|
||||||
//OwnerId required
|
//UserId required
|
||||||
if (!isNew)
|
if (!isNew)
|
||||||
{
|
{
|
||||||
if (inObj.OwnerId == 0)
|
if (inObj.UserId == 0)
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "UserId");
|
||||||
}
|
}
|
||||||
|
|
||||||
// //Owner must be current user, there are no exceptions
|
|
||||||
// if (inObj.OwnerId != UserId)
|
|
||||||
// AddError(ApiErrorCode.VALIDATION_INVALID_VALUE, "OwnerId", "OwnerId must be current user Id");
|
|
||||||
|
|
||||||
//Name required
|
//Name required
|
||||||
if (string.IsNullOrWhiteSpace(inObj.Name))
|
if (string.IsNullOrWhiteSpace(inObj.Name))
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace AyaNova.Models
|
|||||||
public uint ConcurrencyToken { get; set; }
|
public uint ConcurrencyToken { get; set; }
|
||||||
|
|
||||||
[Required]
|
[Required]
|
||||||
public long OwnerId { get; set; }
|
public long UserId { get; set; }
|
||||||
[Required, MaxLength(255)]
|
[Required, MaxLength(255)]
|
||||||
public string Name { get; set; }//max 255 characters ascii set
|
public string Name { get; set; }//max 255 characters ascii set
|
||||||
[Required]
|
[Required]
|
||||||
|
|||||||
@@ -262,7 +262,7 @@ namespace AyaNova.Util
|
|||||||
{
|
{
|
||||||
LogUpdateMessage(log);
|
LogUpdateMessage(log);
|
||||||
|
|
||||||
exec("CREATE TABLE adatafilter (id BIGSERIAL PRIMARY KEY, ownerid bigint not null, name varchar(255) not null, public bool not null," +
|
exec("CREATE TABLE adatafilter (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))");
|
||||||
setSchemaLevel(++currentSchema);
|
setSchemaLevel(++currentSchema);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user