Exemplo n.º 1
0
        public IActionResult Post([FromBody] Flashcard card)
        {
            if (card == null)
            {
                return(BadRequest());
            }
            card.Id = Guid.NewGuid();
            _context.Add(card);
            _context.SaveChanges();

            return(CreatedAtRoute("GetFlashcard", new { id = card.Id.ToString() }, card));
        }
Exemplo n.º 2
0
        public ActionResult <DeckDTO> CreateDeck(DeckDTO deck)
        {
            _context.Decks.Add(deck);
            _context.SaveChanges();

            return(CreatedAtAction("GetDeck", new CardDTO {
                Id = deck.Id
            }, deck));
        }
Exemplo n.º 3
0
 public void Commit()
 {
     _dbContext.SaveChanges();
 }
 public void Dispose()
 {
     optionsBuilder = null;
     foreach (var card in dbContext.Cards)
     {
         dbContext.Cards.Remove(card);
     }
     dbContext.SaveChanges();
     dbContext.Dispose();
     cardsController = null;
 }