public async Task <IEnumerable <GetAllCardsViewModel> > GetAllCards() { List <GetAllCardsViewModel> allCards = new List <GetAllCardsViewModel>(); var cards = await _cardRepository.GetCards(); foreach (Card c in cards) { GetAllCardsViewModel allCardsItem = new GetAllCardsViewModel(); allCardsItem.Id = c.Id; allCardsItem.Name = c.Name; allCardsItem.Value = c.Value; allCards.Add(allCardsItem); } return(allCards); }
public GetAllCardsViewModel GetUserCards(string userId) { var cards = this.Db.UserCards.Where(x => x.UserId == userId).Select(uc => new CardViewModel { Id = uc.CardId, Name = uc.Card.Name, Attack = uc.Card.Attack, Health = uc.Card.Health, Description = uc.Card.Description, Image = uc.Card.ImageUrl, Keyword = uc.Card.Keyword }) .ToArray(); GetAllCardsViewModel model = new GetAllCardsViewModel() { Cards = cards }; return(model); }
public GetAllCardsViewModel GetAll() { var cards = this.Db.Cards.Select(x => new CardViewModel { Attack = x.Attack, Description = x.Description, Health = x.Health, Id = x.Id, Image = x.ImageUrl, Keyword = x.Keyword, Name = x.Name }) .ToArray(); GetAllCardsViewModel model = new GetAllCardsViewModel { Cards = cards }; return(model); }