This commit is contained in:
@@ -56,11 +56,9 @@ namespace AyaNova.Api.Controllers
|
|||||||
return BadRequest(new ApiErrorResponse(ModelState));
|
return BadRequest(new ApiErrorResponse(ModelState));
|
||||||
if (id == 0)
|
if (id == 0)
|
||||||
return Ok(ApiOkResponse.Response(ayType.ToString()));
|
return Ok(ApiOkResponse.Response(ayType.ToString()));
|
||||||
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
|
||||||
{
|
return Ok(ApiOkResponse.Response(BizObjectNameFetcherDirect.Name(ayType, id, ct)));
|
||||||
ct.Database.OpenConnection();
|
|
||||||
return Ok(ApiOkResponse.Response(BizObjectNameFetcherDirect.Name(ayType, id, command)));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -108,6 +108,14 @@ namespace AyaNova.Biz
|
|||||||
return await ct.Reminder.AnyAsync(z => z.Id == id);
|
return await ct.Reminder.AnyAsync(z => z.Id == id);
|
||||||
case AyaType.Review:
|
case AyaType.Review:
|
||||||
return await ct.Review.AnyAsync(z => z.Id == id);
|
return await ct.Review.AnyAsync(z => z.Id == id);
|
||||||
|
case AyaType.ServiceRate:
|
||||||
|
return await ct.ServiceRate.AnyAsync(z => z.Id == id);
|
||||||
|
case AyaType.TravelRate:
|
||||||
|
return await ct.TravelRate.AnyAsync(z => z.Id == id);
|
||||||
|
case AyaType.TaxCode:
|
||||||
|
return await ct.TaxCode.AnyAsync(z => z.Id == id);
|
||||||
|
case AyaType.ServiceBank:
|
||||||
|
return await ct.ServiceBank.AnyAsync(z => z.Id == id);
|
||||||
default:
|
default:
|
||||||
throw new System.NotSupportedException($"AyaNova.Biz.BizObjectExistsInDatabase::ExistsAsync type {objectType.ToString()} is not supported");
|
throw new System.NotSupportedException($"AyaNova.Biz.BizObjectExistsInDatabase::ExistsAsync type {objectType.ToString()} is not supported");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,6 +98,8 @@ namespace AyaNova.Biz
|
|||||||
return new TravelRateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new TravelRateBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
case AyaType.TaxCode:
|
case AyaType.TaxCode:
|
||||||
return new TaxCodeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
return new TaxCodeBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
case AyaType.ServiceBank:
|
||||||
|
return new ServiceBankBiz(ct, userId, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, roles);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
using Microsoft.EntityFrameworkCore;
|
||||||
namespace AyaNova.Biz
|
namespace AyaNova.Biz
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -10,6 +11,7 @@ namespace AyaNova.Biz
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
cmd.CommandText = $"select PUBLIC.AYGETNAME({id}, {(int)ayaType}) as m";
|
cmd.CommandText = $"select PUBLIC.AYGETNAME({id}, {(int)ayaType}) as m";
|
||||||
// cmd.CommandText = $"SELECT m.{COLUMN} FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
|
// cmd.CommandText = $"SELECT m.{COLUMN} FROM {TABLE} AS m WHERE m.id = {id} LIMIT 1";
|
||||||
using (var dr = cmd.ExecuteReader())
|
using (var dr = cmd.ExecuteReader())
|
||||||
@@ -21,6 +23,18 @@ namespace AyaNova.Biz
|
|||||||
throw;
|
throw;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//warning: use the above in a loop, not this one
|
||||||
|
internal static string Name(AyaType ayaType, long id, AyaNova.Models.AyContext ct)
|
||||||
|
{
|
||||||
|
using (var command = ct.Database.GetDbConnection().CreateCommand())
|
||||||
|
{
|
||||||
|
ct.Database.OpenConnection();
|
||||||
|
return Name(ayaType, id, command);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}//eoc
|
}//eoc
|
||||||
}//eons
|
}//eons
|
||||||
|
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
|
|
||||||
/////////////////////////////////////////
|
/////////////////////////////////////////
|
||||||
// PROCESS STANDARD CREATE NOTIFICATION
|
// PROCESS STANDARD MODIFIED NOTIFICATION
|
||||||
//
|
//
|
||||||
//
|
//
|
||||||
public static async Task ProcessStandardObjectModifiedEvents(ICoreBizObjectModel newObject, AyContext ct)
|
public static async Task ProcessStandardObjectModifiedEvents(ICoreBizObjectModel newObject, AyContext ct)
|
||||||
|
|||||||
@@ -110,8 +110,18 @@ namespace AyaNova.Biz
|
|||||||
|
|
||||||
//Name required
|
//Name required
|
||||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||||
|
{
|
||||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//Object exists?
|
||||||
|
if (!await BizObjectExistsInDatabase.ExistsAsync(proposedObj.ObjectType, proposedObj.ObjectId, ct))
|
||||||
|
{
|
||||||
|
AddError(ApiErrorCode.NOT_FOUND, "generalerror", $"Bankable source object specified doesn't exist [type:{proposedObj.ObjectType}, id:{proposedObj.ObjectId}]");
|
||||||
|
return;
|
||||||
|
}
|
||||||
/*
|
/*
|
||||||
"CONSTRAINT UNQ_ServiceBank UNIQUE (entrydate, objectid, objecttype, incidentsbalance, hoursbalance, currencybalance), " +
|
"CONSTRAINT UNQ_ServiceBank UNIQUE (entrydate, objectid, objecttype, incidentsbalance, hoursbalance, currencybalance), " +
|
||||||
"CONSTRAINT UNQ_ServiceBank_Previous_values UNIQUE (lastentrydate, objectid, objecttype, lastincidentsbalance, lasthoursbalance, lastcurrencybalance), " +
|
"CONSTRAINT UNQ_ServiceBank_Previous_values UNIQUE (lastentrydate, objectid, objecttype, lastincidentsbalance, lasthoursbalance, lastcurrencybalance), " +
|
||||||
@@ -241,6 +251,45 @@ namespace AyaNova.Biz
|
|||||||
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
await NotifyEventHelper.ProcessStandardObjectEvents(ayaEvent, proposedObj, ct);
|
||||||
|
|
||||||
//SPECIFIC EVENTS FOR THIS OBJECT
|
//SPECIFIC EVENTS FOR THIS OBJECT
|
||||||
|
var o = (ServiceBank)proposedObj;
|
||||||
|
|
||||||
|
|
||||||
|
//SERVICE BANK DEPLETED
|
||||||
|
{
|
||||||
|
var subs = await ct.NotifySubscription.Where(z => z.EventType == NotifyEventType.ServiceBankDepleted).ToListAsync();
|
||||||
|
string SourceName = string.Empty;
|
||||||
|
if (subs.Count > 0)
|
||||||
|
SourceName = BizObjectNameFetcherDirect.Name(o.ObjectType, o.ObjectId, ct);
|
||||||
|
|
||||||
|
foreach (var sub in subs)
|
||||||
|
{
|
||||||
|
//not for inactive users
|
||||||
|
if (!await UserBiz.UserIsActive(sub.UserId)) continue;
|
||||||
|
|
||||||
|
//Has any of the balances changed and is that changed balance within this users selected threshold?
|
||||||
|
//decvalue here refers to the balance left
|
||||||
|
if (
|
||||||
|
(o.LastCurrencyBalance != null && o.CurrencyBalance != o.LastCurrencyBalance && o.CurrencyBalance <= sub.DecValue)
|
||||||
|
|| (o.LastHoursBalance != null && o.HoursBalance != o.LastHoursBalance && o.HoursBalance <= sub.DecValue)
|
||||||
|
|| (o.LastIncidentsBalance != null && o.IncidentsBalance != o.LastIncidentsBalance && o.IncidentsBalance <= sub.DecValue)
|
||||||
|
)
|
||||||
|
{
|
||||||
|
|
||||||
|
NotifyEvent n = new NotifyEvent()
|
||||||
|
{
|
||||||
|
EventType = NotifyEventType.ServiceBankDepleted,
|
||||||
|
UserId = sub.UserId,
|
||||||
|
AyaType = o.ObjectType,
|
||||||
|
ObjectId = o.ObjectId,
|
||||||
|
NotifySubscriptionId = sub.Id,
|
||||||
|
Name = SourceName
|
||||||
|
};
|
||||||
|
await ct.NotifyEvent.AddAsync(n);
|
||||||
|
log.LogDebug($"Adding NotifyEvent: [{n.ToString()}]");
|
||||||
|
await ct.SaveChangesAsync();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}//end of process notifications
|
}//end of process notifications
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user