public ActionResult AddAsync(string sourceId, IPrincipal principal) { StartBackgroundSignallingTask( (session, signal) => { var u = new UserUpdater(session, signal); u.AddShow(principal.Identity.Name, sourceId); }); return Json("ok", JsonRequestBehavior.AllowGet); }
public ActionResult Options(OptionsViewModel model, IPrincipal principal) { if (!ModelState.IsValid) { return View(model); } var u = new UserUpdater(DocumentSession, _ => { }); if (model.RadioChoiceWatched == "choice-episode") { u.SetEpisodeWatched(principal.Identity.Name, model.SourceId); } if (model.RadioChoiceWatched == "choice-season") { u.SetSeasonWatched(principal.Identity.Name, model.SourceId); } if (model.RadioChoiceWatched == "choice-custom") { var foo = model.RadioChoiceCustom.ToLower().Split('x'); u.SetLastWatchedTo(principal.Identity.Name, model.SourceId, int.Parse(foo[0]), int.Parse(foo[1])); } return View("Index"); }
private static void InitTestDb(string ravenUrl) { DocumentStore = new DocumentStore { Url = ravenUrl }.Initialize(); using (var session = DocumentStore.OpenSession()) { if (session.Query<ShowInfoCache>().Count() == 0) { var updater = new ShowUpdater(session, x => Logger.Info("Updated names")); updater.UpdateShowNames(); session.SaveChanges(); } if (session.Query<User>().Count() == 0) { var users = new UserUpdater(session, _ => { }); string salt; var pwHash = Passwords.Hash("123456789012", out salt); users.CreateUser("alun", pwHash, salt); session.SaveChanges(); } } }
public void TestFullRun() { using (var store = new DocumentStore { Url = "http://localhost:8080" }.Initialize()) { IndexCreation.CreateIndexes(typeof(SourceShowInfoCaches_ByName).Assembly, store); using (var session = store.OpenSession()) { var updater = new ShowUpdater(session, x => Console.WriteLine("Updated: " + x)); updater.UpdateShowNames(); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new ShowUpdater(session, x => Console.WriteLine("Updated: " + x)); updater.UpdateShowNames(); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new ShowUpdater(session, x => Console.WriteLine("Updated: " + x)); updater.SeedShow("24496"); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new ShowUpdater(session, x => Console.WriteLine("Updated: " + x)); updater.UpdateShows(); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new UserUpdater(session, x => Console.WriteLine("CreateUser: "******"testve", "2342342434234", "2353465346546"); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new UserUpdater(session, x => Console.WriteLine("AddShow: " + x)); updater.AddShow("testve", "24496"); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new UserUpdater(session, x => Console.WriteLine("AddShow: " + x)); updater.SetEpisodeWatched("testve", "24496"); session.SaveChanges(); } using (var session = store.OpenSession()) { var updater = new UserUpdater(session, x => Console.WriteLine("AddShow: " + x)); updater.SetSeasonWatched("testve", "24496"); session.SaveChanges(); } } }