This commit is contained in:
75
server/biz/BizObjectExistsInDatabase.cs
Normal file
75
server/biz/BizObjectExistsInDatabase.cs
Normal file
@@ -0,0 +1,75 @@
|
||||
using System.Threading.Tasks;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Sockeye.Models;
|
||||
|
||||
|
||||
namespace Sockeye.Biz
|
||||
{
|
||||
|
||||
|
||||
//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
|
||||
{
|
||||
|
||||
|
||||
//Returns existance status of object type and id specified in database
|
||||
|
||||
internal static async Task<bool> ExistsAsync(SockType aType, long id, AyContext ct)
|
||||
{
|
||||
//new up a context??
|
||||
|
||||
switch (aType)
|
||||
{
|
||||
//CoreBizObject add here
|
||||
case SockType.NoType://no type always exists and this is used by orphaned attachments
|
||||
return true;
|
||||
case SockType.FileAttachment:
|
||||
return await ct.FileAttachment.AnyAsync(z => z.Id == id);
|
||||
case SockType.DataListSavedFilter:
|
||||
return await ct.DataListSavedFilter.AnyAsync(z => z.Id == id);
|
||||
case SockType.FormCustom:
|
||||
return await ct.FormCustom.AnyAsync(z => z.Id == id);
|
||||
case SockType.User:
|
||||
return await ct.User.AnyAsync(z => z.Id == id);
|
||||
case SockType.Customer:
|
||||
return await ct.Customer.AnyAsync(z => z.Id == id);
|
||||
case SockType.CustomerNote:
|
||||
return await ct.CustomerNote.AnyAsync(z => z.Id == id);
|
||||
|
||||
case SockType.HeadOffice:
|
||||
return await ct.HeadOffice.AnyAsync(z => z.Id == id);
|
||||
|
||||
case SockType.Memo:
|
||||
return await ct.Memo.AnyAsync(z => z.Id == id);
|
||||
|
||||
|
||||
case SockType.Report:
|
||||
return await ct.Report.AnyAsync(z => z.Id == id);
|
||||
case SockType.Reminder:
|
||||
return await ct.Reminder.AnyAsync(z => z.Id == id);
|
||||
case SockType.Review:
|
||||
return await ct.Review.AnyAsync(z => z.Id == id);
|
||||
|
||||
|
||||
case SockType.CustomerNotifySubscription:
|
||||
return await ct.CustomerNotifySubscription.AnyAsync(z => z.Id == id);
|
||||
case SockType.Integration:
|
||||
return await ct.Integration.AnyAsync(z => z.Id == id);
|
||||
default:
|
||||
throw new System.NotSupportedException($"Sockeye.Biz.BizObjectExistsInDatabase::ExistsAsync type {aType.ToString()} is not supported");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////
|
||||
|
||||
}//eoc
|
||||
|
||||
|
||||
}//eons
|
||||
|
||||
Reference in New Issue
Block a user