This commit is contained in:
2020-02-14 21:20:32 +00:00
parent 8c0bdb05de
commit 5acf0b8a80
11 changed files with 16 additions and 14 deletions

View File

@@ -40,7 +40,7 @@ namespace AyaNova.Biz
//EXISTS
internal async Task<bool> ExistsAsync(long id)
{
return await ct.DataListSortFilter.AnyAsync(e => e.Id == id);
return await ct.DataListView.AnyAsync(e => e.Id == id);
}
@@ -59,7 +59,7 @@ namespace AyaNova.Biz
outObj.UserId = UserId;
await ct.DataListSortFilter.AddAsync(outObj);
await ct.DataListView.AddAsync(outObj);
await ct.SaveChangesAsync();
//Handle child and associated items:
@@ -84,7 +84,7 @@ namespace AyaNova.Biz
internal async Task<DataListView> 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
var ret = await ct.DataListSortFilter.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
var ret = await ct.DataListView.SingleOrDefaultAsync(m => m.Id == fetchId && (m.Public == true || m.UserId == UserId));
if (logTheGetEvent && ret != null)
{
//Log
@@ -102,7 +102,7 @@ namespace AyaNova.Biz
List<NameIdItem> items = new List<NameIdItem>();
if (!string.IsNullOrWhiteSpace(listKey))
{
items = await ct.DataListSortFilter
items = await ct.DataListView
.AsNoTracking()
.Where(m => m.ListKey == listKey && (m.Public == true || m.UserId == UserId))
.OrderBy(m => m.Name)
@@ -164,7 +164,7 @@ namespace AyaNova.Biz
if (HasErrors)
return false;
ct.DataListSortFilter.Remove(dbObj);
ct.DataListView.Remove(dbObj);
await ct.SaveChangesAsync();
//Delete sibling objects
@@ -209,7 +209,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 (await ct.DataListSortFilter.AnyAsync(m => m.Name == inObj.Name && m.Id != inObj.Id))
if (await ct.DataListView.AnyAsync(m => m.Name == inObj.Name && m.Id != inObj.Id))
{
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "Name");
}