This commit is contained in:
2020-04-30 22:47:32 +00:00
parent 7341875bfc
commit 8e90d1ab26
6 changed files with 99 additions and 4 deletions

View File

@@ -242,6 +242,44 @@ namespace AyaNova.Biz
return true;
}
internal async Task<bool> PutTranslationItemsDisplayTextAsync(List<NewTextIdConcurrencyTokenItem> inObj, Translation dbParent)
{
if (dbParent.Stock == true)
{
AddError(ApiErrorCode.INVALID_OPERATION, "object", "TranslationItem is from a Stock translation and cannot be modified");
return false;
}
foreach (NewTextIdConcurrencyTokenItem tit in inObj)
{
var titem=await ct.TranslationItem.SingleOrDefaultAsync(m => m.Id == tit.Id);
if(titem==null){
AddError(ApiErrorCode.NOT_FOUND, $"Translation item ID {tit.Id}");
return false;
}
//Replace the db object with the PUT object
//CopyObject.Copy(inObj, dbObj, "Id");
titem.Display = tit.NewText;
//Set "original" value of concurrency token to input token
//this will allow EF to check it out
ct.Entry(titem).OriginalValues["ConcurrencyToken"] = tit.ConcurrencyToken;
//Only thing to validate is if it has data at all in it
if (string.IsNullOrWhiteSpace(tit.NewText))
AddError(ApiErrorCode.VALIDATION_REQUIRED, $"Display (NewText) for Id: {tit.Id}");
}
if (HasErrors)
return false;
await ct.SaveChangesAsync();
//Log
await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, dbParent.Id, AyaType.Translation, AyaEvent.Modified), ct);
return true;
}
internal async Task<bool> PutTranslationNameAsync(Translation dbObj, NewTextIdConcurrencyTokenItem inObj)
{