This commit is contained in:
2020-01-22 16:37:50 +00:00
parent 070688265b
commit f2898b8149
8 changed files with 67 additions and 276 deletions

View File

@@ -1,70 +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
//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
// {
//THIS IS USED BY THE ATTACHMENT CONTROLLER
//IN THEORY WE ONLY NEED TO CHECK FOR ATTACHABLE TYPES, BUT I CAN SEE IT'S POTENTIAL USEFULNESS DOWN THE ROAD FOR OTHER THINGS
internal static class BizObjectExistsInDatabase
{
// internal static bool Exists(AyaTypeId tid)
// {
// return Exists(tid.ObjectType, tid.ObjectId);
// }
//THIS IS THE METHOD CALLED BY THE ATTACHMENT CONTROLLER
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.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);
//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.Biz.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
}
// }
}
// /////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////
// }//eoc
}//eoc
// }//eons
}//eons