Ejemplo n.º 1
0
 public static void TestInsert()
 {
     var r = new Repo<Country>(new DbContextFactory());
     var c = new Country { Name = "Asaaa" };
     r.Insert(c);
     r.Save();
     var o = r.Get(c.Id);
     Assert.AreEqual(c.Name, o.Name);
 }
Ejemplo n.º 2
0
        public static void TestRemove()
        {
            var r = new Repo<Country>(new DbContextFactory());
            var c = new Country { Name = "AsaaaRemove" };
            r.Insert(c);
            r.Save();

            r.Delete(c);
            r.Save();

            var o = r.Get(c.Id);
            Assert.IsTrue(o.IsDeleted);
        }
Ejemplo n.º 3
0
        void SaveAccessTokens()
        {
            using (var repo = new Repo()) {

                var tokens = repo.Table<TwitterOAuthTokens>().Where(t => t.Account == _auth.ScreenName).FirstOrDefault();

                if (tokens == null) {
                    tokens = new TwitterOAuthTokens() {
                        Account = _auth.ScreenName,
                        Token = _auth.AccessToken,
                        TokenSecret = _auth.AccessTokenSecret,
                        UserId = _auth.UserId
                    };
                    repo.Insert(tokens);
                }
                else {
                    tokens.Token = _auth.AccessToken;
                    tokens.TokenSecret = _auth.AccessTokenSecret;
                    tokens.UserId = _auth.UserId;
                    repo.Update(tokens);
                }
            }
        }
Ejemplo n.º 4
0
        void Subscribe(Dictionary<string, string> subs)
        {
            var sourceType = typeof(Blog);

            using (var repo = new Repo()) {
                var sources = repo.GetActiveSources(sourceType);
                var existingSources = new Dictionary<string, Blog>();
                foreach (Blog s in sources) {
                    existingSources.Add(s.Url, s);
                }

                foreach (var s in subs) {
                    var url = s.Value;
                    if (!existingSources.ContainsKey(url)) {
                        var source = new Blog();
                        source.Url = url;
                        repo.Insert(source);
                        Console.WriteLine ("GU: Subscribed to " + url);
                    }
                }
            }

            SourceUpdater.SetSourcesChanged();
            App.RunUI(delegate {
                App.Inst.RefreshInfo();
            });
        }