示例#1
0
 private Card MapEntityToCard(Entities.Card cardEntity) => new Card
 {
     Id         = cardEntity.Id,
     Name       = cardEntity.Name,
     Definition = MapEntityToCardDefinition(cardEntity.Definition),
     Properties = JsonConvert.DeserializeObject <List <Property> >(cardEntity.Properties)
 };
示例#2
0
        public async Task DeleteCard(int cardId)
        {
            var cardEntityToDelete = new Entities.Card
            {
                Id = cardId
            };

            context.Cards.Remove(cardEntityToDelete);
            await context.SaveChangesAsync();
        }
示例#3
0
        public async Task <int> AddCard(AddCardRequest card)
        {
            var cardDefinition = await context.CardDefinitions.FindAsync(card.DefinitionId);

            var cardEntity = new Entities.Card
            {
                Definition = cardDefinition,
                Name       = card.Name,
                Properties = JsonConvert.SerializeObject(card.Properties)
            };

            context.Cards.Add(cardEntity);
            await context.SaveChangesAsync();

            return(cardEntity.Id);
        }