Example #1
0
        public AddTopicViewModel(Topic topic)
        {
            _topicService = new LocalTopicsService();

            CurrentTopic = topic;

            _acceptCommand = new RelayCommand(async () => await SaveButtonPressed(), () => !string.IsNullOrWhiteSpace(_topicName));

            FromTopic(topic);
        }
Example #2
0
 private void HandleTopicAdded(Topic topic)
 {
     if (topic.IsDone)
     {
         _closedTopics.Add(topic);
     }
     else
     {
         _topics.Add(topic);
     }
 }
Example #3
0
        private void FromTopic(Topic topic)
        {

            if (null != topic && _topic != topic)
            {
                TopicName = topic.Title;
                TopicDescription = topic.Description;
                Priority = topic.Priority;
                DueDate = topic.DueDate;
            }

            TopicName = "";
            TopicDescription = "";
            Priority = 1;
            DueDate = null;

            _topic = null;
        }
Example #4
0
        private void HandleTopicUpdated(Topic topic)
        {
            if (_topics.Contains(topic))
            {
                var found = _topics.Single((t) => t.Key == topic.Key);

                if (topic.IsDone)
                {
                    _topics.Remove(found);
                    _closedTopics.Add(topic);
                }
                else
                {
                    found.Description = topic.Description;
                    found.DueDate = topic.DueDate;
                    found.Priority = topic.Priority;
                    found.Title = topic.Title;
                }
            }
            else if(_closedTopics.Contains(topic))
            {
                var found = _closedTopics.Single((t) => t.Key == topic.Key);

                if (topic.IsDone)
                {
                    found.Description = topic.Description;
                    found.DueDate = topic.DueDate;
                    found.Priority = topic.Priority;
                    found.Title = topic.Title;
                }
                else
                {
                    _closedTopics.Remove(found);
                    _topics.Add(topic);
                }
            }
        }
Example #5
0
        private async Task SaveButtonPressed()
        {
            if (null != _topic)
            {
                await _topicService.UpdateTopicAsync(_topic);

                MessengerInstance.Send(new TopicUpdatedMessage(_topic));
            }
            else
            {

                var topic = new Topic(Guid.NewGuid().ToString(), TopicName, TopicDescription, Priority, DueDate);

                await _topicService.AddTopicAsync(topic);

                MessengerInstance.Send(new TopicAddedMessage(topic));
            }

            FromTopic(null);
        }
 public Task<Topic> UpdateTopicAsync(Topic topic)
 {
     return Task.Run(() => topic);
 }
 public Task<Topic> RemoveTopicAsync(Topic topic)
 {
     return Task.Run(() => topic);
 }
 public Task<Topic> AddTopicAsync(Topic topic)
 {
     return Task.Run(() => topic);
 }