This commit is contained in:
@@ -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)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user