This commit is contained in:
@@ -79,6 +79,77 @@ namespace AyaNova.Biz
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// internal async Task<bool> PutTranslationItemDisplayTextAsync(TranslationItem dbObj, 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;
|
||||
// }
|
||||
|
||||
// //Replace the db object with the PUT object
|
||||
// //CopyObject.Copy(inObj, dbObj, "Id");
|
||||
// dbObj.Display = inObj.NewText;
|
||||
// //Set "original" value of concurrency token to input token
|
||||
// //this will allow EF to check it out
|
||||
// ct.Entry(dbObj).OriginalValues["Concurrency"] = inObj.Concurrency;
|
||||
|
||||
// //Only thing to validate is if it has data at all in it
|
||||
// if (string.IsNullOrWhiteSpace(inObj.NewText))
|
||||
// AddError(ApiErrorCode.VALIDATION_REQUIRED, "Display (NewText)");
|
||||
|
||||
// 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> 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(z => z.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["Concurrency"] = tit.Concurrency;
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//DUPLICATE
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user