private ActionResult ConfigView(Settings settings, Config model) { // Grab all of the available sites that the authorized account has access to var authFactory = new GAuthSubRequestFactory("analytics", ApplicationName) { Token = settings.SessionToken }; var analytics = new AnalyticsService(authFactory.ApplicationName) { RequestFactory = authFactory }; foreach (AccountEntry entry in analytics.Query(new AccountQuery()).Entries) { var account = entry.Properties.First(x => x.Name == "ga:accountName").Value; if (!model.Sites.ContainsKey(account)) model.Sites.Add(account, new Dictionary<string, string>()); model.Sites[account].Add(entry.ProfileId.Value, entry.Title.Text); } return View("Config", model); }
public ActionResult Config(Config model) { Settings settings; using (RavenSession.Advanced.DocumentStore.DisableAggressiveCaching()) { settings = RavenSession.Load<Settings>(Settings.DefaultId); } if (settings == null) return RedirectToAction("Auth"); if (!ModelState.IsValid) return ConfigView(settings, model); Mapper.Map(model, settings); RavenSession.Store(settings); Response.RemoveOutputCacheItem(Url.Content("~/Widgets/AnalyticsSummary")); return RedirectToAction("Index"); }