예제 #1
0
        async Task <DeckModel> IDeckService.CreateDeckAsync(DeckCreateModel deck, int userId, CancellationToken cancellationToken)
        {
            var newDeckCreate = new DeckCreateData
            {
                Description = deck.Description,
                MaxCards    = 5,
                Name        = deck.Name,
                UserId      = userId,
            };

            var newDeck = await _deckRepository.CreateDeckAsync(newDeckCreate, cancellationToken : cancellationToken);

            return(_deckDataMapper.Map(newDeck));
        }
예제 #2
0
        async Task <DeckData> IDeckRepository.CreateDeckAsync(DeckCreateData deck, CancellationToken cancellationToken)
        {
            var entity = new Deck
            {
                Description = deck.Description,
                MaxCards    = 5,
                Name        = deck.Name,
                UserFk      = deck.UserId,
            };

            _context.Deck.Add(entity);

            await _context.SaveChangesAsync(cancellationToken : cancellationToken);

            return(_deckMapper.Map(entity));
        }