コード例 #1
0
        public Sticker CreateSticker(string stickerEmoji,
                                     string stickerFileId,
                                     long?photoId,
                                     int?stickerSetId            = null,
                                     StickerStatus stickerStatus = StickerStatus.Unpublished,
                                     string azureImageUrl        = "")
        {
            var sticker = new Sticker
            {
                VkImageId      = photoId,
                TelegramFileId = stickerFileId,
                CreatedDate    = DateTime.Now,
                StickerStatus  = stickerStatus,
                AzureImageUrl  = azureImageUrl
            };

            if (stickerSetId != null)
            {
                sticker.StickerSet = _context.StickerSets.FirstOrDefault(p => p.Id == stickerSetId);
            }

            var emoji = new StickerEmoji
            {
                Emoji   = _emojiService.GetBySymbol(stickerEmoji),
                Sticker = sticker
            };

            _context.Add(emoji);

            sticker = _context.Add(sticker).Entity;

            _context.SaveChanges();

            return(sticker);
        }
コード例 #2
0
        public IActionResult Add(string emojiSequence)
        {
            foreach (var emoji in emojiSequence.Split(" "))
            {
                _emojiService.GetBySymbol(emoji);
            }

            return(RedirectToAction("Index"));
        }
コード例 #3
0
        public void CreateAndActivateKeyboard(string emojiSequence)
        {
            var emojiSymbolds = emojiSequence.Split(" ");

            var emojis = emojiSymbolds.Select(p => _emojiService.GetBySymbol(p));

            DeactivateAllKeyboards();

            var keyboard = new Keyboard
            {
                KeyboardStatus = KeyboardStatus.Active
            };

            keyboard.Buttons = emojis.Select((emoji, i) => new KeyboardButton
            {
                Emoji     = emoji,
                Postition = i,
                Keyboard  = keyboard
            }).ToList();

            _context.AddRange(keyboard.Buttons);
            _context.AddRange(keyboard);
            _context.SaveChanges();
        }