This commit is contained in:
@@ -27,10 +27,11 @@ Once that is done then can steam ahead on the biz objects but until I have the c
|
||||
|
||||
IMMEDIATE ITEMS:
|
||||
================
|
||||
Happy monday Radiant Maiden ;)
|
||||
|
||||
- Need an ObjectExists type object for checking if something exists when specified by type and ID
|
||||
- Could this be a combined method to get the name as well just to save time?
|
||||
- Or should that be another method (YES, first code a translator to translate types to db tables (however the fuck that works with EF), then can use it in turn to verify existance and get name separately)
|
||||
- Or should that be another method (YES, first code a translator to translate types to db tables (however the fuck that works with EF),
|
||||
then can use it in turn to verify existance and get name separately)
|
||||
- Once we have that go back into any code that accepts a typeandid and add to Validation code to check for it
|
||||
- Localized text
|
||||
- ** DEVISE a system to ensure no unused keys are brought forward to raven
|
||||
|
||||
@@ -2,6 +2,8 @@ namespace AyaNova.Biz
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// All AyaNova types and their attributes indicating what features that type will support (tagging, attachments etc)
|
||||
/// </summary>
|
||||
@@ -25,10 +27,16 @@ namespace AyaNova.Biz
|
||||
AyaNova7Import = 10,
|
||||
TrialSeeder = 11,
|
||||
Metrics = 12,
|
||||
Locale = 13,
|
||||
UserOptions=14,
|
||||
TagGroup = 15,
|
||||
TagGroupMap = 16
|
||||
Locale = 13,
|
||||
UserOptions = 14,
|
||||
TagGroup = 15,
|
||||
TagGroupMap = 16
|
||||
|
||||
|
||||
//NOTE: New objects added here need to also be added to the following classes:
|
||||
//AyaNova.Biz.BizObjectExistsInDatabase
|
||||
//AyaNova.Biz.BizObjectFactory
|
||||
//AyaNova.Biz.BizRoles
|
||||
|
||||
}
|
||||
|
||||
|
||||
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
|
||||
|
||||
62
server/AyaNova/biz/BizObjectNameFetcher.cs
Normal file
62
server/AyaNova/biz/BizObjectNameFetcher.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
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 BizObjectNameFetcher
|
||||
{
|
||||
|
||||
internal static string Name(AyaTypeId tid)
|
||||
{
|
||||
return Name(tid.ObjectType, tid.ObjectId);
|
||||
}
|
||||
|
||||
|
||||
//Returns existance status of object type and id specified in database
|
||||
internal static string Name(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.Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||
case AyaType.Widget:
|
||||
return ct.Widget.Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||
case AyaType.Tag:
|
||||
return ct.Tag.Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||
case AyaType.TagGroup:
|
||||
return ct.TagGroup.Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
|
||||
|
||||
default:
|
||||
throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
}//eons
|
||||
|
||||
Reference in New Issue
Block a user