diff --git a/server/AyaNova/Controllers/TranslationController.cs b/server/AyaNova/Controllers/TranslationController.cs index 9c0a9a0c..8e1081ae 100644 --- a/server/AyaNova/Controllers/TranslationController.cs +++ b/server/AyaNova/Controllers/TranslationController.cs @@ -399,7 +399,7 @@ namespace AyaNova.Api.Controllers //We have our files now can parse and insert into db if (uploadFormData.UploadedFiles.Count > 0) { - //deserialize the file + //deserialize each file and import foreach (UploadedFileInfo a in uploadFormData.UploadedFiles) { if (!await biz.ImportAsync(ImportJson)) @@ -409,14 +409,6 @@ namespace AyaNova.Api.Controllers DeleteTempUploadFile(uploadFormData); return BadRequest(new ApiErrorResponse(biz.Errors)); } - - //import into the db - - - - var v = await FileUtil.StoreFileAttachmentAsync(a.InitialUploadedPathName, a.MimeType, a.OriginalFileName, theDate, attachToObject, Notes, ct); - - } } } diff --git a/server/AyaNova/biz/TranslationBiz.cs b/server/AyaNova/biz/TranslationBiz.cs index d66ca97e..08bf2b9c 100644 --- a/server/AyaNova/biz/TranslationBiz.cs +++ b/server/AyaNova/biz/TranslationBiz.cs @@ -5,6 +5,9 @@ using AyaNova.Util; using AyaNova.Api.ControllerHelpers; using AyaNova.Models; using System.Collections.Generic; +using Newtonsoft.Json; +using Newtonsoft.Json.Serialization; +using Newtonsoft.Json.Linq; namespace AyaNova.Biz { @@ -121,6 +124,51 @@ namespace AyaNova.Biz + //////////////////////////////////////////////////////////////////////////////////////////////// + //IMPORT + // + internal async Task ImportAsync(JObject o) + { + // Translation dbObject = await ct.Translation.Include(z => z.TranslationItems).SingleOrDefaultAsync(z => z.Id == id); + + // 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; + + // 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; + + + return true; + } + + //////////////////////////////////////////////////////////////////////////////////////////////// /// GET