This commit is contained in:
@@ -13,7 +13,7 @@ namespace AyaNova.Biz
|
||||
|
||||
public BizObject()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ namespace AyaNova.Biz
|
||||
internal long UserId { get; set; }
|
||||
internal long UserTranslationId { get; set; }
|
||||
internal AuthorizationRoles CurrentUserRoles { get; set; }
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
@@ -210,7 +210,9 @@ namespace AyaNova.Biz
|
||||
|
||||
private async Task ValidateAsync(Customer proposedObj, Customer currentObj)
|
||||
{
|
||||
|
||||
//skip validation if seeding
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
//Name required
|
||||
@@ -262,18 +264,18 @@ namespace AyaNova.Biz
|
||||
|
||||
//So, for a customer, the Customer Notes collection is accessed from within the Customer form, even though it's actually external but user doesn't see it that way
|
||||
//so they would be deleted automatically, same goes for Contacts (if they can be deleted and don't have connections elsewhere)
|
||||
|
||||
|
||||
//Workorders and things that you select a Customer for would trigger an error and NOT be deleted automatically
|
||||
//The Mass delete Extension will be used in those cases to clear out all the workorders etc
|
||||
|
||||
|
||||
|
||||
|
||||
//Referential integrity error
|
||||
if (await ct.User.AnyAsync(z => z.CustomerId == inObj.Id) == true)
|
||||
{
|
||||
//Note: errorbox will ensure it appears in the general errror box and not field specific
|
||||
//the translation key is to indicate what the linked object is that is causing the error
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "errorbox", "LT:Contact");
|
||||
AddError(ApiErrorCode.VALIDATION_REFERENTIAL_INTEGRITY, "errorbox", "LT:Contact");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -205,6 +205,8 @@ namespace AyaNova.Biz
|
||||
|
||||
private async Task ValidateAsync(HeadOffice proposedObj, HeadOffice currentObj)
|
||||
{
|
||||
//skip validation if seeding
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
|
||||
@@ -136,6 +136,7 @@ namespace AyaNova.Biz
|
||||
//will iterate the subscriptions and see if any apply here
|
||||
internal static async Task HandlePotentialNotificationEvent(AyaEvent ayaEvent, ICoreBizObjectModel newObject, ICoreBizObjectModel originalObject = null)
|
||||
{
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
log.LogDebug($"HandlePotentialNotificationEvent processing: [AyaType:{newObject.AyaType}, AyaEvent:{ayaEvent}]");
|
||||
//set to true if any changes are made to the context (NotifyEvent added)
|
||||
bool SaveContext = false;
|
||||
@@ -144,9 +145,9 @@ namespace AyaNova.Biz
|
||||
using (AyContext ct = AyaNova.Util.ServiceProviderProvider.DBContext)
|
||||
{
|
||||
//short circuit if there are no subscriptions which would be typical of a v8 migrate scenario or fresh import or just not using notification
|
||||
if(!await ct.NotifySubscription.AnyAsync())
|
||||
if (!await ct.NotifySubscription.AnyAsync())
|
||||
return;
|
||||
|
||||
|
||||
//switch through AyaEvent then individual Ayatypes as required for event types
|
||||
switch (ayaEvent)
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ namespace AyaNova.Biz
|
||||
|
||||
internal class TranslationBiz : BizObject
|
||||
{
|
||||
public bool SeedOrImportRelaxedRulesMode { get; set; }
|
||||
|
||||
|
||||
internal TranslationBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles userRoles)
|
||||
{
|
||||
@@ -20,8 +20,7 @@ namespace AyaNova.Biz
|
||||
UserId = currentUserId;
|
||||
UserTranslationId = userTranslationId;
|
||||
CurrentUserRoles = userRoles;
|
||||
BizType = AyaType.Translation;
|
||||
SeedOrImportRelaxedRulesMode = false;//default
|
||||
BizType = AyaType.Translation;
|
||||
}
|
||||
|
||||
internal static TranslationBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace AyaNova.Biz
|
||||
internal class UserBiz : BizObject, IJobObject, ISearchAbleObject, IReportAbleObject
|
||||
{
|
||||
|
||||
public bool SeedOrImportRelaxedRulesMode { get; set; }
|
||||
|
||||
|
||||
internal UserBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles userRoles)
|
||||
{
|
||||
@@ -26,7 +26,6 @@ namespace AyaNova.Biz
|
||||
UserTranslationId = userTranslationId;
|
||||
CurrentUserRoles = userRoles;
|
||||
BizType = AyaType.User;
|
||||
SeedOrImportRelaxedRulesMode = false;//default
|
||||
}
|
||||
|
||||
//This is where active tech license consumers are accounted for
|
||||
@@ -448,6 +447,9 @@ namespace AyaNova.Biz
|
||||
//Can save or update?
|
||||
private async Task ValidateAsync(User proposedObj, User currentObj)
|
||||
{
|
||||
//skip validation if seeding
|
||||
if(ServerBootConfig.SEEDING) return;
|
||||
|
||||
//run validation and biz rules
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
@@ -535,7 +537,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Validate customer type user
|
||||
if (!SeedOrImportRelaxedRulesMode && proposedObj.UserType == UserType.Customer)
|
||||
if (proposedObj.UserType == UserType.Customer)
|
||||
{
|
||||
if (proposedObj.CustomerId == null || proposedObj.CustomerId == 0)
|
||||
{
|
||||
@@ -550,7 +552,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Validate headoffice type user
|
||||
if (!SeedOrImportRelaxedRulesMode && proposedObj.UserType == UserType.HeadOffice)
|
||||
if (proposedObj.UserType == UserType.HeadOffice)
|
||||
{
|
||||
if (proposedObj.HeadOfficeId == null || proposedObj.HeadOfficeId == 0)
|
||||
{
|
||||
@@ -565,7 +567,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
//Validate subcontractor type user
|
||||
if (!SeedOrImportRelaxedRulesMode && proposedObj.UserType == UserType.ServiceContractor)
|
||||
if (proposedObj.UserType == UserType.ServiceContractor)
|
||||
{
|
||||
if (proposedObj.VendorId == null || proposedObj.VendorId == 0)
|
||||
{
|
||||
|
||||
@@ -54,6 +54,7 @@ namespace AyaNova.Biz
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
await SearchIndexAsync(newObject, true);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
|
||||
await NotifyEventProcessor.HandlePotentialNotificationEvent(AyaEvent.Created, newObject);
|
||||
return newObject;
|
||||
}
|
||||
@@ -153,7 +154,7 @@ namespace AyaNova.Biz
|
||||
Vendor dbObject = await ct.Vendor.SingleOrDefaultAsync(z => z.Id == id);
|
||||
ValidateCanDelete(dbObject);
|
||||
if (HasErrors)
|
||||
return false;
|
||||
return false;
|
||||
ct.Vendor.Remove(dbObject);
|
||||
await ct.SaveChangesAsync();
|
||||
await EventLogProcessor.DeleteObjectLogAsync(UserId, BizType, dbObject.Id, dbObject.Name, ct);
|
||||
@@ -202,13 +203,16 @@ namespace AyaNova.Biz
|
||||
private async Task ValidateAsync(Vendor proposedObj, Vendor currentObj)
|
||||
{
|
||||
|
||||
//skip validation if seeding
|
||||
if (ServerBootConfig.SEEDING) return;
|
||||
|
||||
bool isNew = currentObj == null;
|
||||
|
||||
//Name required
|
||||
if (string.IsNullOrWhiteSpace(proposedObj.Name))
|
||||
AddError(ApiErrorCode.VALIDATION_REQUIRED, "Name");
|
||||
|
||||
|
||||
|
||||
//If name is otherwise OK, check that name is unique
|
||||
if (!PropertyHasErrors("Name"))
|
||||
{
|
||||
@@ -241,7 +245,7 @@ namespace AyaNova.Biz
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//REPORTING
|
||||
//
|
||||
|
||||
@@ -226,6 +226,9 @@ namespace AyaNova.Biz
|
||||
//
|
||||
private async Task ValidateAsync(Widget proposedObj)
|
||||
{
|
||||
//skip validation if seeding
|
||||
if(ServerBootConfig.SEEDING) return;
|
||||
|
||||
//NOTE: In DB schema only name and serial are not nullable
|
||||
|
||||
//run validation and biz rules
|
||||
|
||||
Reference in New Issue
Block a user