// [Consumes("application/json")]
        // [Produces("application/json")]
        public IActionResult CreateCard([FromForm] MinCard c)
        {
            var id = LoggedInId();

            try
            {
                using var context = new flashcardsContext();
                if (!context.sets.Any(s => s.id == c.inSet))
                {
                    return(BadRequest($"There is no set with id {c.inSet}"));
                }
                if (!context.sets.Any(s => s.id == c.inSet && (s.creatorId == id ||
                                                               s.ownerId == id)))
                {
                    return(BadRequest("Access denied"));
                }
                var card = CreateCardFromMinCard(c, LoggedInId());
                context.cards.Add(card);

                // SaveImage(c.image, card.id);
                context.SaveChanges();

                card.picture = SaveImage(c.image, card.id);
                context.cards.Update(card);
                context.SaveChanges();

                return(Ok());
            }
            catch (Exception e)
            {
                return(BadRequest(e.Message));
            }
        }
 private static Card.Card CreateCardFromMinCard(MinCard minCard, int ownerId)
 => new Card.Card(minCard.answer,
                  minCard.question,
                  minCard.inSet,
                  ownerId,
                  minCard.isPublic);