예제 #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);
        }