This commit is contained in:
@@ -38,12 +38,12 @@ namespace AyaNova.Biz
|
||||
case AyaType.User:
|
||||
return ct.User.Any(m => m.Id == id);
|
||||
case AyaType.Widget:
|
||||
return ct.Widget.Any(m => m.Id == id);
|
||||
return ct.Widget.Any(m => m.Id == id);
|
||||
case AyaType.FileAttachment:
|
||||
return ct.FileAttachment.Any(m => m.Id == id);
|
||||
case AyaType.DataFilter:
|
||||
return ct.DataFilter.Any(m => m.Id == id);
|
||||
case AyaType.FormCustom:
|
||||
return ct.DataListFilter.Any(m => m.Id == id);
|
||||
case AyaType.FormCustom:
|
||||
return ct.FormCustom.Any(m => m.Id == id);
|
||||
|
||||
|
||||
|
||||
@@ -40,20 +40,20 @@ namespace AyaNova.Biz
|
||||
//EXISTS
|
||||
internal async Task<bool> ExistsAsync(long id)
|
||||
{
|
||||
return await ct.DataFilter.AnyAsync(e => e.Id == id);
|
||||
return await ct.DataListFilter.AnyAsync(e => e.Id == id);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/// GET
|
||||
internal async Task<DataFilter> GetNoLogAsync(long fetchId)
|
||||
internal async Task<DataListFilter> GetNoLogAsync(long fetchId)
|
||||
{
|
||||
//This is simple so nothing more here, but often will be copying to a different output object or some other ops
|
||||
return await ct.DataFilter.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
return await ct.DataListFilter.SingleOrDefaultAsync(m => m.Id == fetchId);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE
|
||||
internal async Task<DataFilter> CreateAsync(DataFilter inObj)
|
||||
internal async Task<DataListFilter> CreateAsync(DataListFilter inObj)
|
||||
{
|
||||
Validate(inObj, true);
|
||||
if (HasErrors)
|
||||
@@ -61,11 +61,11 @@ namespace AyaNova.Biz
|
||||
else
|
||||
{
|
||||
//do stuff with datafilter
|
||||
DataFilter outObj = inObj;
|
||||
DataListFilter outObj = inObj;
|
||||
outObj.UserId = UserId;
|
||||
|
||||
|
||||
await ct.DataFilter.AddAsync(outObj);
|
||||
await ct.DataListFilter.AddAsync(outObj);
|
||||
await ct.SaveChangesAsync();
|
||||
|
||||
//Handle child and associated items:
|
||||
@@ -83,7 +83,7 @@ namespace AyaNova.Biz
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//CREATE
|
||||
internal DataFilter Create(AyContext TempContext, DataFilter inObj)
|
||||
internal DataListFilter Create(AyContext TempContext, DataListFilter inObj)
|
||||
{
|
||||
Validate(inObj, true);
|
||||
if (HasErrors)
|
||||
@@ -91,11 +91,11 @@ namespace AyaNova.Biz
|
||||
else
|
||||
{
|
||||
//do stuff with datafilter
|
||||
DataFilter outObj = inObj;
|
||||
DataListFilter outObj = inObj;
|
||||
outObj.UserId = UserId;
|
||||
|
||||
|
||||
TempContext.DataFilter.Add(outObj);
|
||||
TempContext.DataListFilter.Add(outObj);
|
||||
TempContext.SaveChanges();
|
||||
|
||||
//Handle child and associated items:
|
||||
@@ -115,10 +115,10 @@ namespace AyaNova.Biz
|
||||
/// GET
|
||||
|
||||
//Get one
|
||||
internal async Task<DataFilter> GetAsync(long fetchId)
|
||||
internal async Task<DataListFilter> 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.UserId == UserId));
|
||||
var ret = await ct.DataListFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
|
||||
if (ret != null)
|
||||
{
|
||||
//Log
|
||||
@@ -134,7 +134,7 @@ namespace AyaNova.Biz
|
||||
List<NameIdItem> items = new List<NameIdItem>();
|
||||
if (!string.IsNullOrWhiteSpace(listKey))
|
||||
{
|
||||
items = await ct.DataFilter
|
||||
items = await ct.DataListFilter
|
||||
.AsNoTracking()
|
||||
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
|
||||
.OrderBy(m => m.Name)
|
||||
@@ -156,7 +156,7 @@ namespace AyaNova.Biz
|
||||
//
|
||||
|
||||
//put
|
||||
internal bool Put(DataFilter dbObj, DataFilter inObj)
|
||||
internal bool Put(DataListFilter dbObj, DataListFilter inObj)
|
||||
{
|
||||
//preserve the owner ID if none was specified
|
||||
if (inObj.UserId == 0)
|
||||
@@ -185,7 +185,7 @@ namespace AyaNova.Biz
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DELETE
|
||||
//
|
||||
internal bool Delete(DataFilter dbObj)
|
||||
internal bool Delete(DataListFilter dbObj)
|
||||
{
|
||||
//Determine if the object can be deleted, do the deletion tentatively
|
||||
//Probably also in here deal with tags and associated search text etc
|
||||
@@ -193,7 +193,7 @@ namespace AyaNova.Biz
|
||||
ValidateCanDelete(dbObj);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
ct.DataFilter.Remove(dbObj);
|
||||
ct.DataListFilter.Remove(dbObj);
|
||||
ct.SaveChanges();
|
||||
|
||||
//Delete sibling objects
|
||||
@@ -214,7 +214,7 @@ namespace AyaNova.Biz
|
||||
//
|
||||
|
||||
//Can save or update?
|
||||
private void Validate(DataFilter inObj, bool isNew)
|
||||
private void Validate(DataListFilter inObj, bool isNew)
|
||||
{
|
||||
|
||||
//UserId required
|
||||
@@ -238,7 +238,7 @@ namespace AyaNova.Biz
|
||||
if (!PropertyHasErrors("Name"))
|
||||
{
|
||||
//Use Any command is efficient way to check existance, it doesn't return the record, just a true or false
|
||||
if (ct.DataFilter.Any(m => m.Name == inObj.Name && m.Id != inObj.Id))
|
||||
if (ct.DataListFilter.Any(m => m.Name == inObj.Name && m.Id != inObj.Id))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
|
||||
}
|
||||
@@ -386,7 +386,7 @@ namespace AyaNova.Biz
|
||||
|
||||
|
||||
//Can delete?
|
||||
private void ValidateCanDelete(DataFilter inObj)
|
||||
private void ValidateCanDelete(DataListFilter inObj)
|
||||
{
|
||||
//Leaving this off for now
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user