This commit is contained in:
2018-09-06 22:45:02 +00:00
parent 5a3a6ff4b2
commit 3afbb96fca
5 changed files with 73 additions and 7 deletions

View File

@@ -21,7 +21,8 @@ namespace AyaNova.Biz
LicenseFetch=7,
LicenseTrialRequest=8,
ServerStateChange=9,
SeedDatabase=10
SeedDatabase=10,
TagMassUntag=11
//NEW ITEMS REQUIRE LOCALE KEYS AND UPDATE EventLogProcessor code that prefetches required keys

View File

@@ -200,6 +200,19 @@ namespace AyaNova.Biz
}
////////////////////////////////////////////////////////////////////////////////////////////////
// UNTAG - Untag this tag from everywhere it's used
//
internal bool Untag(Tag dbObj)
{
//Be careful in future, if you put ToString at the end of each object in the string interpolation
//npgsql driver will assume it's a string and put quotes around it triggering an error that a string can't be compared to an int
ct.Database.ExecuteSqlCommand($"delete from atagmap where tagid = {dbObj.Id}");
ct.Database.ExecuteSqlCommand($"delete from ataggroupmap where tagid = {dbObj.Id}");
return true;
}
////////////////////////////////////////////////////////////////////////////////////////////////
//VALIDATION
//

View File

@@ -32,7 +32,7 @@ namespace AyaNova.Biz
}
////////////////////////////////////////////////////////////////////////////////////////////////
//CREATE
@@ -195,7 +195,8 @@ namespace AyaNova.Biz
ValidateCanDelete(dbObj);
if (HasErrors)
return false;
ct.TagGroup.Remove(dbObj);
ct.Database.ExecuteSqlCommand($"delete from ataggroupmap where taggroupid = {dbObj.Id}");
ct.Database.ExecuteSqlCommand($"delete from ataggroup where id = {dbObj.Id}");
return true;
}
@@ -231,10 +232,10 @@ namespace AyaNova.Biz
//whatever needs to be check to delete this object
//See if any TagGroupmaps exist with this TagGroup in which case it's not deleteable
if (ct.TagGroupMap.Any(e => e.TagGroupId == inObj.Id))
{
AddError(ValidationErrorType.ReferentialIntegrity, "object", "Can't be deleted while has relations");
}
// if (ct.TagGroupMap.Any(e => e.TagGroupId == inObj.Id))
// {
// AddError(ValidationErrorType.ReferentialIntegrity, "TagGroup", "Can't be deleted while has tags mapped");
// }
}