Пример #1
0
 public async Task <AvatarLayer> AddLayerAsync(AvatarLayer layer)
 {
     VerifyManagementPermission();
     layer.SiteId = GetCurrentSiteId();
     return(await _avatarLayerRepository.AddSaveAsync(
                GetClaimId(ClaimType.UserId), layer));
 }
Пример #2
0
        public async Task <AvatarLayer> AddLayerAsync(AvatarLayer layer)
        {
            VerifyManagementPermission();
            layer.SiteId = GetCurrentSiteId();
            var currentLayer = await _avatarLayerRepository.AddSaveAsync(
                GetClaimId(ClaimType.UserId), layer);

            foreach (var text in layer.Texts)
            {
                var languageId = await _languageService.GetLanguageIdAsync(text.Language);

                if (languageId != default)
                {
                    await _avatarLayerRepository.AddAvatarLayerTextAsync(currentLayer.Id,
                                                                         languageId,
                                                                         text);
                }
            }
            await _avatarLayerRepository.SaveAsync();

            var layerData = _avatarLayerRepository.GetNameAndLabelByLanguageId(currentLayer.Id,
                                                                               await _languageService.GetDefaultLanguageIdAsync());

            currentLayer.Name = layerData["Name"];
            return(currentLayer);
        }