public async Task <OperationResult> Create(FolderCreateModel createModel) { try { var core = await _coreHelper.GetCore(); //var names = new List<KeyValuePair<string, string>>(); //var descriptions = new List<KeyValuePair<string, string>>(); //await using var sdkDbContext = core.DbContextHelper.GetDbContext(); //var languages = await sdkDbContext.Languages // .Select(x => new { x.LanguageCode, x.Id }) // .ToListAsync(); //foreach (var folderTranslationModel in createModel.Translations) //{ // var languageCode = languages // .First(y => y.Id == folderTranslationModel.LanguageId).LanguageCode; // names.Add(new KeyValuePair<string, string>(languageCode, folderTranslationModel.Name)); // descriptions.Add( // new KeyValuePair<string, string>(languageCode, folderTranslationModel.Description)); //} //await core.FolderCreate(names, descriptions, createModel.ParentId); // creating the folder in Danish as default var folderTranslations = createModel.Translations .Select(x => new CommonTranslationsModel { Name = x.Name, Description = x.Description, LanguageId = x.LanguageId, }).ToList(); await core.FolderCreate(folderTranslations, createModel.ParentId); // creating the folder in Danish as default return(new OperationResult(true)); } catch (Exception e) { _logger.LogError(e, e.Message); return(new OperationResult( false, _localizationService.GetString("ErrorWhileCreatingFolder"))); } }
public async Task <OperationResult> Create([FromBody] FolderCreateModel createModel) { return(await _foldersService.Create(createModel)); }