Exemplo n.º 1
0
        /// <inheritdoc />
        public async Task <long> CreateAsync(EmojiCreationData data)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            var entity = data.ToEntity();

            await ModixContext.Emoji.AddAsync(entity);

            await ModixContext.SaveChangesAsync();

            return(entity.Id);
        }
Exemplo n.º 2
0
        /// <inheritdoc />
        public async Task CreateMultipleAsync(EmojiCreationData data, int count)
        {
            if (data is null)
            {
                throw new ArgumentNullException(nameof(data));
            }

            if (count <= 0)
            {
                return;
            }

            var now      = DateTimeOffset.Now;
            var entities = Enumerable.Range(0, count).Select(_ => data.ToEntity(now));

            await ModixContext.Emoji.AddRangeAsync(entities);

            await ModixContext.SaveChangesAsync();
        }