This commit is contained in:
@@ -130,42 +130,27 @@ namespace AyaNova.Biz
|
||||
internal async Task<bool> ImportAsync(JObject o)
|
||||
{
|
||||
|
||||
var v = o.Count;
|
||||
// Translation dbObject = await ct.Translation.Include(z => z.TranslationItems).SingleOrDefaultAsync(z => z.Id == id);
|
||||
Translation t = new Translation();
|
||||
t.Name = (string)o["name"];
|
||||
string newUniqueName = string.Empty;
|
||||
bool NotUnique = true;
|
||||
long l = 1;
|
||||
do
|
||||
{
|
||||
newUniqueName = Util.StringUtil.UniqueNameBuilder(t.Name, l++, 255);
|
||||
NotUnique = await ct.Translation.AnyAsync(z => z.Name == newUniqueName);
|
||||
} while (NotUnique);
|
||||
|
||||
// if (dbObject == null)
|
||||
// {
|
||||
// AddError(ApiErrorCode.NOT_FOUND, "id");
|
||||
// return null;
|
||||
// }
|
||||
// Translation newObject = new Translation();
|
||||
// //CopyObject.Copy(dbObject, newObject, "Id, Salt, Login, Password, CurrentAuthToken, DlKey, DlKeyExpire, Wiki, Serial");
|
||||
// string newUniqueName = string.Empty;
|
||||
// bool NotUnique = true;
|
||||
// long l = 1;
|
||||
// do
|
||||
// {
|
||||
// newUniqueName = Util.StringUtil.UniqueNameBuilder(dbObject.Name, l++, 255);
|
||||
// NotUnique = await ct.Translation.AnyAsync(z => z.Name == newUniqueName);
|
||||
// } while (NotUnique);
|
||||
// newObject.Name = newUniqueName;
|
||||
t.CjkIndex = (bool)o["CjkIndex"];
|
||||
t.Stock = false;
|
||||
|
||||
// newObject.Stock = false;
|
||||
// newObject.CjkIndex = false;
|
||||
// foreach (TranslationItem i in dbObject.TranslationItems)
|
||||
// {
|
||||
// newObject.TranslationItems.Add(new TranslationItem() { Key = i.Key, Display = i.Display });
|
||||
// }
|
||||
|
||||
// newObject.Id = 0;
|
||||
// newObject.Concurrency = 0;
|
||||
// await ct.Translation.AddAsync(newObject);
|
||||
// await ct.SaveChangesAsync();
|
||||
// await EventLogProcessor.LogEventToDatabaseAsync(new Event(UserId, newObject.Id, BizType, AyaEvent.Created), ct);
|
||||
// // await SearchIndexAsync(newObject, true);
|
||||
// // await TagBiz.ProcessUpdateTagsInRepositoryAsync(ct, newObject.Tags, null);
|
||||
// return newObject;
|
||||
int ExpectedKeyCount = await ct.TranslationItem.CountAsync(z => z.TranslationId == 1);
|
||||
|
||||
JArray tItems=(JArray)o["TranslationItems"];
|
||||
if(tItems.Count() < ExpectedKeyCount ){
|
||||
AddError(ApiErrorCode.VALIDATION_FAILED,null, "Not enough");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user