This commit is contained in:
65
server/AyaNova/biz/BizObjectExistsInDatabase.cs
Normal file
65
server/AyaNova/biz/BizObjectExistsInDatabase.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
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
|
||||
{
|
||||
|
||||
|
||||
//TODO: UNTESTED, UNUSED (SO FAR)CODE
|
||||
//This was just blocked out because I know I will need it in future
|
||||
internal static class BizObjectExistsInDatabase
|
||||
{
|
||||
|
||||
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.Tag:
|
||||
return ct.Tag.Any(m => m.Id == id);
|
||||
case AyaType.TagGroup:
|
||||
return ct.TagGroup.Any(m => m.Id == id);
|
||||
|
||||
|
||||
|
||||
default:
|
||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectExistsInDatabase::Exists type {aytype.ToString()} is not supported");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
}//eons
|
||||
|
||||
Reference in New Issue
Block a user