Beispiel #1
0
        private void ExecuteAddCommand()
        {
            var view = new AddWebView();

            view.Show();
            Messenger.Default.Send(new NotificationMessageAction <WebsiteItem>(null, item =>
            {
                DatabaseHelper.Open();
                var row = DatabaseHelper.InsertOrIgnore <WebsiteItem>("Name, Url", "@name, @url",
                                                                      new SQLiteParameter("@name", item.Name),
                                                                      new SQLiteParameter("@url", item.Url));
                DatabaseHelper.Close();
                if (row > 0)
                {
                    WesitesList.Add(item);
                }
                view.Close();
            }), "web");
        }
Beispiel #2
0
        private void ExecuteEditCommand(int index)
        {
            if (index < 0 || index >= WesitesList.Count)
            {
                return;
            }
            var view = new AddWebView();

            view.Show();
            Messenger.Default.Send(new NotificationMessageAction <WebsiteItem>(WesitesList[index], null, item =>
            {
                item.Id = WesitesList[index].Id;
                DatabaseHelper.Open();
                var row = DatabaseHelper.Update <WebsiteItem>("Name = @name, Url = @url", $"Id = {item.Id}",
                                                              new SQLiteParameter("@name", item.Name),
                                                              new SQLiteParameter("@url", item.Url));
                DatabaseHelper.Close();
                if (row > 0)
                {
                    WesitesList[index] = item;
                }
                view.Close();
            }), "web");
        }