Exemplo n.º 1
0
        private async void RefreshMessageCollection()
        {
            IsRefreshing = true;
            await Task.Run(() =>
            {
                var Result = _dataRepository.GetAllMessages();
                if (null != Result)
                {
                    foreach (Message m in Result)
                    {
                        if (!Messages.Contains(m))
                        {
                            Messages.Add(m);
                        }
                    }
                }
                else
                {
                    var CommandResult = new OperationResultArgs
                    {
                        IsError    = true,
                        ResultText = string.Format("Failed to get messages from server.{0}Error : {1}", Environment.NewLine, Result.ToString())
                    };
                    RaiseNotification(this, CommandResult);
                }
            });

            IsRefreshing = false;
        }
Exemplo n.º 2
0
 public MessagesViewModel(IWebCommunicatorAsync <Message> webCommunicator, IMessageDataRepository dataRepository) : base(webCommunicator)
 {
     Refresh            = new DelegateCommand(CanRefreshMessages, RefreshMessageCollection);
     _dataRepository    = dataRepository;
     _messageCollection = new ObservableCollection <Message>(_dataRepository.GetAllMessages());
     IsRefreshing       = false;
 }