public CardViewModel()
        {
            try
            {
                currentModel = new CardCurrent();
                firstStart = true;
                previousCardModified = false;
                goingBack = false;
                goingBackNumberOfCards = 1;
                imageNumber = 0;
                id = 0;

                //There was a problem with database initialization
                using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
                {
                    verbs = db.Table<Verbs>().ToList();
                    adjectives = db.Table<Adjectives>().ToList();
                    nouns = db.Table<Nouns>().ToList();
                    images = db.Table<Images>().ToList();
                    if (verbs.Count == 0 || adjectives.Count == 0 || nouns.Count == 0 || images.Count == 0)
                    {
                        Debug.WriteLine("Database not initialized");
                        App app = new App();
                        app.Initialize();
                    }
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine(e.Message);
                Debug.WriteLine(e.StackTrace);
            }
        }
        public void GetOldCard()
        {
            using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
            {
                int count = db.Table<GeneratedCards>().Count() - 1;
                if (goingBackNumberOfCards <= -1 && previousCardModified == true)
                {
                    SaveGeneratedCard(true, back);
                    previousCardModified = false;
                }

                goingBackNumberOfCards++;
                back = count + goingBackNumberOfCards;

                var card = new CardCurrent();

                card.Verb = db.Table<GeneratedCards>().Skip(back).First().VerbWord;
                card.Adjective = db.Table<GeneratedCards>().Skip(back).First().AdjectiveWord;
                card.Noun = db.Table<GeneratedCards>().Skip(back).First().NounWord;
                card.Image = db.Table<GeneratedCards>().Skip(back).First().Image;
                currentModel = card;

            }

        }
        public async void GetNewCard()
        {
            using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
            {
                int i = 0;
                Random rnd = new Random();
                try
                {
                    goingBack = false;
                    if (goingBackNumberOfCards <= 0)
                    {
                        SaveGeneratedCard(false, 0);
                        previousCardModified = false;
                    }
               
                    //If previous card was an old card and it was modified
                    if (goingBackNumberOfCards == 0 && previousCardModified == true)
                    {
                        SaveGeneratedCard(true, back);
                        previousCardModified = false;
                    }

                    if (goingBackNumberOfCards == 1)
                    {
                        goingBackNumberOfCards = 0;
                    }
                    id += 1;

                 
                    imageNumber = 0;
                    var card = new CardCurrent();
                    //Example values:
                    //card.Verb = "help";
                    //card.Adjective = "worried";
                    //card.Noun = "girls";
                    //card.Image = 143;
                    i = rnd.Next(db.Table<Verbs>().Count());
                    card.Verb = db.Table<Verbs>().Skip(i).First().VerbWord;
                    i = rnd.Next(db.Table<Adjectives>().Count());
                    card.Adjective = db.Table<Adjectives>().Skip(i).First().AdjectiveWord;
                    i = rnd.Next(db.Table<Nouns>().Count());
                    card.Noun = db.Table<Nouns>().Skip(i).First().NounWord;
                    i = rnd.Next(1, db.Table<Images>().Count());
                    card.Image = db.Table<Images>().Skip(i).First().ImageNumber;

                    previousCardModified = false;

                    currentModel = card;

                    firstStart = false;
                }
                catch (Exception error)
                {
                    Debug.WriteLine(db.Table<Verbs>().Count());
                    Debug.WriteLine(db.Table<Adjectives>().Count());
                    Debug.WriteLine(db.Table<Nouns>().Count());
                    Debug.WriteLine(db.Table<Images>().Count());
                    var dialog = new MessageDialog("Error on " + error.Message + " Stacktrace " + error.StackTrace);
                    await dialog.ShowAsync();
                    Debug.WriteLine(error.Message + "||" + error.StackTrace);
                }
            }
        }
        /// <summary>
        /// Loads previous card
        /// </summary>
        public void Previous_Button_Click(object sender, RoutedEventArgs e)
        {
            if (firstStart == false)
            {
                using (SQLite.Net.SQLiteConnection db = new SQLite.Net.SQLiteConnection(new SQLite.Net.Platform.WinRT.SQLitePlatformWinRT(), App.path))
                {
                    goingBackNumberOfCards -= 1;
                    int count = db.Table<GeneratedCards>().Count();
                    //We are browsing previous card and saving generated card. It's the first time user have pressed "previous" button when genereting a new card
                    if (goingBackNumberOfCards == -1 && goingBack == false)
                    {
                        SaveGeneratedCard(false, 0);
                        previousCardModified = false;
                        id += 1;
                    }
                    if (goingBackNumberOfCards < -1 && previousCardModified == true && Math.Abs(goingBackNumberOfCards) != count)
                    {
                        SaveGeneratedCard(true, back);
                        previousCardModified = false;
                    }

                    if (previousCardModified == true)
                    {
                        SaveGeneratedCard(true, back);
                        previousCardModified = false;
                    }

                    goingBack = true;

                    if (Math.Abs(goingBackNumberOfCards) == count + 1) //Check if card now is the first card. If it is the first card--> do nothing.
                    {
                        goingBackNumberOfCards += 1;
                    }
                    else
                    {
                        if (id > 1)//if user has two cards
                        {
                            back = count + goingBackNumberOfCards;
                            var card = new CardCurrent();

                            card.Verb = db.Table<GeneratedCards>().Skip(back).First().VerbWord;
                            card.Adjective = db.Table<GeneratedCards>().Skip(back).First().AdjectiveWord;
                            card.Noun = db.Table<GeneratedCards>().Skip(back).First().NounWord;
                            card.Image = db.Table<GeneratedCards>().Skip(back).First().Image;
                            currentModel = card;
                        }
                    }
                }
            }
        }