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
|
||||
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:
|
||||
- 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
|
||||
- Filter format:
|
||||
- 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
|
||||
DataFilter outObj = inObj;
|
||||
outObj.OwnerId = UserId;
|
||||
outObj.UserId = UserId;
|
||||
|
||||
|
||||
await ct.DataFilter.AddAsync(outObj);
|
||||
@@ -91,7 +91,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
//do stuff with datafilter
|
||||
DataFilter outObj = inObj;
|
||||
outObj.OwnerId = UserId;
|
||||
outObj.UserId = UserId;
|
||||
|
||||
|
||||
TempContext.DataFilter.Add(outObj);
|
||||
@@ -117,7 +117,7 @@ namespace AyaNova.Biz
|
||||
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
|
||||
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)
|
||||
{
|
||||
//Log
|
||||
@@ -135,7 +135,7 @@ namespace AyaNova.Biz
|
||||
{
|
||||
items = await ct.DataFilter
|
||||
.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)
|
||||
.Select(m => new NameIdItem()
|
||||
{
|
||||
@@ -158,8 +158,8 @@ namespace AyaNova.Biz
|
||||
internal bool Put(DataFilter dbObj, DataFilter inObj)
|
||||
{
|
||||
//preserve the owner ID if none was specified
|
||||
if (inObj.OwnerId == 0)
|
||||
inObj.OwnerId = dbObj.OwnerId;
|
||||
if (inObj.UserId == 0)
|
||||
inObj.UserId = dbObj.UserId;
|
||||
|
||||
//Replace the db object with the PUT object
|
||||
CopyObject.Copy(inObj, dbObj, "Id");
|
||||
@@ -216,16 +216,14 @@ namespace AyaNova.Biz
|
||||
private void Validate(DataFilter inObj, bool isNew)
|
||||
{
|
||||
|
||||
//OwnerId required
|
||||
//UserId required
|
||||
if (!isNew)
|
||||
{
|
||||
if (inObj.OwnerId == 0)
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "OwnerId");
|
||||
if (inObj.UserId == 0)
|
||||
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
|
||||
if (string.IsNullOrWhiteSpace(inObj.Name))
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace AyaNova.Models
|
||||
public uint ConcurrencyToken { get; set; }
|
||||
|
||||
[Required]
|
||||
public long OwnerId { get; set; }
|
||||
public long UserId { get; set; }
|
||||
[Required, MaxLength(255)]
|
||||
public string Name { get; set; }//max 255 characters ascii set
|
||||
[Required]
|
||||
|
||||
@@ -262,7 +262,7 @@ namespace AyaNova.Util
|
||||
{
|
||||
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))");
|
||||
setSchemaLevel(++currentSchema);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user