public string Import([FromBody] ImportDeck deck) { if (deck.MainDeck.Count == 0) { throw new InvalidOperationException("Deck is empty or in wrong format."); } var deckId = Guid.NewGuid().ToString(); var dbdeck = new Deck(); dbdeck.ApplicationUser = deck.Owner; dbdeck.UserId = deck.Owner.Id; dbdeck.Name = deck.MainDeck[0].name; dbdeck.Id = deckId; dbdeck.Cards = deck.ToString(); dbdeck.CreationDate = DateTime.UtcNow; context.Decks.Add(dbdeck); context.SaveChanges(); return deckId; }