public Deck(CardSuit[] suits, CardValue[] values) { if ((suits?.Count() ?? 0) <= 0) { suits = Enum.GetValues(typeof(CardSuit)).OfType <CardSuit>().ToArray(); } if ((values?.Count() ?? 0) <= 0) { values = Enum.GetValues(typeof(CardValue)).OfType <CardValue>().ToArray(); } List <Card> c = new List <Card>(); foreach (var s in suits.OrderBy(z => (int)z)) { if (s == CardSuit.Unknown) { continue; } foreach (var v in values.OrderBy(z => (int)z)) { if (v == CardValue.Default) { continue; } c.Add(new Card(s, v)); } } AllCards = c.ToArray(); _Cards = AllCards.OrderBy(z => z.ID).ToList(); }
public async void Initialize() { this.AuthorizedEmployee = SessionService.Instance.AuthorizedEmployee; Favorite favorite = new Favorite(); this.Favorites = await favorite.GetFavoritesAsync(); this.Date = new Card(); this.Date.Date = this.Date.Date.Date; this.Favorite = new Favorite(); Card card = new Card(); this.AllCards = await card.GetCardsAsync(); this.AllCards = AllCards.OrderBy(ac => ac.Date).ToList(); var FavoriteCheckCards = new List <Card>(); for (var i = 0; i < AllCards.Count; i++) { card = AllCards.ElementAt(i); //card.Id == Favorites.CardId && this.AuthorizedEmployee.Id == Favorites.EmployeeId if (Favorites.Any(f => f.CardId == card.Id && f.EmployeeId == this.AuthorizedEmployee.Id)) { //List<int> intList = new List<int>; card = AllCards.ElementAt(i); card.Favorite = true; FavoriteCheckCards.Add(card); //this.AllCards.RemoveAt(i); //this.Cards.Insert(i, card); //this.Cards.Insert(i, new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title = card.Title, Reply = card.Reply, Favorite = card.Favorite, PickUp = card.PickUp }); //this.Cards.Add(card); //this.AllCards.Insert(i, new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title = card.Title, Reply = card.Reply, Favorite = card.Favorite, PickUp = card.PickUp }); //this.Cards.Add(new Card() { Id = card.Id, CD = card.CD, Text = card.Text, Date = card.Date, FromId = card.FromId, ToId = card.ToId, Title=card.Title, Reply=card.Reply, Favorite=card.Favorite, PickUp=card.PickUp}); } else { FavoriteCheckCards.Add(card); } } this.Cards = FavoriteCheckCards; this.Cards = Cards.OrderBy(ac => ac.Date).ToList(); //this.AuthorizedEmployee = SessionService.Instance.AuthorizedEmployee; }
public Deck() { List <Card> c = new List <Card>(); foreach (var s in Enum.GetValues(typeof(CardSuit)).OfType <CardSuit>()) { if (s == CardSuit.Unknown) { continue; } foreach (var v in Enum.GetValues(typeof(CardValue)).OfType <CardValue>()) { if (v == CardValue.Default) { continue; } c.Add(new Card(s, v)); } } AllCards = c.ToArray(); _Cards = AllCards.OrderBy(z => z.ID).ToList(); }