This commit is contained in:
@@ -73,15 +73,15 @@ namespace AyaNova.Biz
|
||||
}
|
||||
UnitModel newObject = new UnitModel();
|
||||
CopyObject.Copy(dbObject, newObject, "Wiki");
|
||||
string newUniqueName = string.Empty;
|
||||
string newUniqueModelNumber = string.Empty;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
|
||||
NotUnique = await ct.UnitModel.AnyAsync(z => z.Name == newUniqueName);
|
||||
newUniqueModelNumber = Util.StringUtil.UniqueNameBuilder(dbObject.Number, l++, 255);
|
||||
NotUnique = await ct.UnitModel.AnyAsync(z => z.Number == newUniqueModelNumber);
|
||||
} while (NotUnique);
|
||||
newObject.Name = newUniqueName;
|
||||
newObject.Number = newUniqueModelNumber;
|
||||
newObject.Id = 0;
|
||||
newObject.Concurrency = 0;
|
||||
await ct.UnitModel.AddAsync(newObject);
|
||||
@@ -135,6 +135,17 @@ namespace AyaNova.Biz
|
||||
AddError(ApiErrorCode.CONCURRENCY_CONFLICT);
|
||||
return null;
|
||||
}
|
||||
catch (Microsoft.EntityFrameworkCore.DbUpdateException ex)
|
||||
{
|
||||
if (ex.InnerException != null && ex.InnerException.Message.Contains("unq_unitmodelnumbervendorid"))
|
||||
{
|
||||
AddError(ApiErrorCode.VALIDATION_NOT_UNIQUE, "number", "Model number plus VendorId combination must be unique");
|
||||
return null;
|
||||
}
|
||||
|
||||
throw;
|
||||
|
||||
}
|
||||
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbObject.Id, BizType, AyaEvent.Modified), ct);
|
||||
await SearchIndexAsync(dbObject, false);
|
||||
await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, dbObject.Tags, SnapshotOfOriginalDBObj.Tags);
|
||||
|
||||
Reference in New Issue
Block a user