示例#1
0
        public bool AddCard(CardAccount userCard)
        {
            bool added = false;
            int  count;

            try
            {
                if (UserCards == null)
                {
                    UserCards = new List <CardAccount>();
                }

                userCard.MyUserId = Id;
                count             = UserCards.Count;
                UserCards.Add(userCard);

                if ((count + 1) == UserCards.Count)
                {
                    added = true;
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Exception in AddCard User: {ex.Message}");
                added = false;
            }

            return(added);
        }
示例#2
0
        private void LineReceived(ComMessage data)
        {
            Debug.WriteLine("Пллучили карту: " + data.Msg);
            Card card = UserCards.FirstOrDefault(c => c.Card_Num.ToString(CultureInfo.InvariantCulture)
                                                 .StartsWith(data.Msg, StringComparison.OrdinalIgnoreCase));

            if (card != null)
            {
                SelectedCard = card;
                return;
            }
            card = Cards.FirstOrDefault(c => c.Card_Num.ToString(CultureInfo.InvariantCulture)
                                        .StartsWith(data.Msg, StringComparison.InvariantCulture));
            if (card != null)
            {
                App.Current.Dispatcher.Invoke((Action) delegate
                {
                    UserCards.Add(card);
                });
                SelectedCard = card;
                return;
            }
            var msg = new StatusMessage {
                Msg = "Не Найдена: " + data.Msg
            };

            Messenger.Default.Send <StatusMessage>(msg);
        }