Ejemplo n.º 1
0
        public void AddNewTopic(string topicName)
        {
            try
            {
                if (string.IsNullOrWhiteSpace(topicName))
                {
                    throw new Exception("Topic not filled in correctly!");
                }

                var topic = GetTopicByName(topicName);
                if (topic != null)
                {
                    throw new Exception("Topic of name " + topicName + " already exists!");
                }

                topic = new TopicSQL {
                    TopicName = topicName
                };
                dataModel.SaveTopic(topic);

                AllTopics.Add(topic); // Update all topics list
                OnUpdate?.Invoke();
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 2
0
        public ObservableCollection <RevisionCardSQL> GetRevisionCardsOfTopic(TopicSQL topic)
        {
            dataModel.RevisionGroups.TryGetValue(topic, out ObservableCollection <RevisionCardSQL> cardsOfTopic);

            if (cardsOfTopic == null)
            {
                cardsOfTopic = new ObservableCollection <RevisionCardSQL>();                      //Topic with no cards
            }
            return(cardsOfTopic);
        }
Ejemplo n.º 3
0
 public void SaveTopic(TopicSQL topic)
 {
     if (RevisionGroups.ContainsKey(topic)) // Topic is present so must be updated
     {
         conn.Update(topic);
     }
     else // Topic not present so must be saved as new
     {
         RevisionGroups[topic] = new ObservableCollection <RevisionCardSQL>();
         conn.Insert(topic);
     }
 }
Ejemplo n.º 4
0
        public void SaveDeleteTopic(TopicSQL topic)
        {
            if (!RevisionGroups.ContainsKey(topic))
            {
                return;
            }

            foreach (var revisionCard in RevisionGroups[topic])
            {
                conn.Delete(revisionCard); //Delete all cards in topic
            }

            RevisionGroups[topic] = null;
            RevisionGroups.Remove(topic);

            conn.Delete(topic);
        }
Ejemplo n.º 5
0
        //Get data from database and populate dictionary for easy access
        public void LoadData()
        {
            RevisionGroups = new Dictionary <TopicSQL, ObservableCollection <RevisionCardSQL> >();

            var topics = conn.Table <TopicSQL>().ToList();

            foreach (var topic in topics)
            {
                RevisionGroups[topic] = new ObservableCollection <RevisionCardSQL>();
            }

            var revisionCards = conn.Table <RevisionCardSQL>().ToList();

            foreach (var revisionCard in revisionCards)
            {
                TopicSQL topic = GetTopicByName(revisionCard.Topic);
                RevisionGroups[topic].Add(revisionCard);
            }
        }