Files
raven/server/AyaNova/biz/BizObjectNameFetcher.cs
2018-10-04 22:30:31 +00:00

71 lines
2.4 KiB
C#

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
{
//Turn a type and ID into a displayable name
internal static class BizObjectNameFetcher
{
/*
NOT SURE IF I WILL WANT TO USE THIS OR NOT GOING FORWARD SO KEEPING IT IN PLACE BUT NOT USABLE FOR NOW
*/
internal static string Name(AyaTypeId tid, AyContext ct = null)
{
throw new System.NotSupportedException("BizObjectNameFetcher:: Slow version, did you mean to call this one?");
//return Name(tid.ObjectType, tid.ObjectId, ct);
}
//Returns existance status of object type and id specified in database
internal static string Name(AyaType aytype, long id, AyContext ct = null)
{
throw new System.NotSupportedException("BizObjectNameFetcher:: Slow version, did you mean to call this one?");
// //new up a context??
// if (ct == null)
// {
// ct = ServiceProviderProvider.DBContext;
// }
// switch (aytype)
// {
// case AyaType.User:
// return ct.User.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
// case AyaType.Widget:
// return ct.Widget.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
// case AyaType.Tag:
// return ct.Tag.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
// case AyaType.TagGroup:
// return ct.TagGroup.AsNoTracking().Where(m => m.Id == id).Select(m => m.Name).FirstOrDefault();
// case AyaType.FileAttachment:
// return ct.FileAttachment.AsNoTracking().Where(m => m.Id == id).Select(m => m.DisplayFileName).FirstOrDefault();
// default:
// throw new System.NotSupportedException($"AyaNova.BLL.BizObjectNameFetcher::Name type {aytype.ToString()} is not supported");
// }
}
/////////////////////////////////////////////////////////////////////
}//eoc
}//eons