This commit is contained in:
2020-01-22 15:09:06 +00:00
parent 999577f9b6
commit 787fa72d85
8 changed files with 88 additions and 69 deletions

View File

@@ -1,67 +1,70 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.JsonPatch;
using EnumsNET;
using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Biz;
using AyaNova.Models;
// using System.Linq;
// using System.Threading.Tasks;
// using Microsoft.EntityFrameworkCore;
// using Microsoft.AspNetCore.Mvc;
// using Microsoft.AspNetCore.JsonPatch;
// using EnumsNET;
// using AyaNova.Util;
// using AyaNova.Api.ControllerHelpers;
// using AyaNova.Biz;
// using AyaNova.Models;
namespace AyaNova.Biz
{
// namespace AyaNova.Biz
// {
//TODO: UNTESTED, UNUSED (SO FAR)CODE
//This was just blocked out because I know I will need it in future
internal static class BizObjectExistsInDatabase
{
// //TODO: UNTESTED, UNUSED (SO FAR)CODE
// //This was just blocked out because I know I will need it in future
//REALLY? I"M BALLS DEEP IN THIS AND HAVEN'T SEEN A NEED FOR IT YET, not updating or maintaining until I see a need
// internal static class BizObjectExistsInDatabase
// {
internal static bool Exists(AyaTypeId tid)
{
return Exists(tid.ObjectType, tid.ObjectId);
}
// internal static bool Exists(AyaTypeId tid)
// {
// return Exists(tid.ObjectType, tid.ObjectId);
// }
//Returns existance status of object type and id specified in database
internal static bool Exists(AyaType aytype, long id, AyContext ct = null)
{
//new up a context??
if (ct == null)
{
ct = ServiceProviderProvider.DBContext;
}
switch (aytype)
{
case AyaType.User:
return ct.User.Any(m => m.Id == id);
case AyaType.Widget:
return ct.Widget.Any(m => m.Id == id);
case AyaType.FileAttachment:
return ct.FileAttachment.Any(m => m.Id == id);
case AyaType.DataFilter:
return ct.DataListFilter.Any(m => m.Id == id);
case AyaType.FormCustom:
return ct.FormCustom.Any(m => m.Id == id);
// //Returns existance status of object type and id specified in database
// internal static bool Exists(AyaType aytype, long id, AyContext ct = null)
// {
// //new up a context??
// if (ct == null)
// {
// ct = ServiceProviderProvider.DBContext;
// }
// switch (aytype)
// {
// case AyaType.User:
// return ct.User.Any(m => m.Id == id);
// case AyaType.Widget:
// return ct.Widget.Any(m => m.Id == id);
// case AyaType.FileAttachment:
// return ct.FileAttachment.Any(m => m.Id == id);
// case AyaType.DataListFilter:
// return ct.DataListFilter.Any(m => m.Id == id);
// case AyaType.DataListTemplate:
// return ct.DataListTemplate.Any(m => m.Id == id);
// case AyaType.FormCustom:
// return ct.FormCustom.Any(m => m.Id == id);
default:
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
}
// default:
// throw new System.NotSupportedException($"AyaNova.BLL.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
// }
}
// }
/////////////////////////////////////////////////////////////////////
// /////////////////////////////////////////////////////////////////////
}//eoc
// }//eoc
}//eons
// }//eons