public ActionResult Index() { using (var configService = new ConfigurationService()) using (var httpService = new HttpService()) using (var service = new MonzoService(httpService, configService.GetEnviroment(EnviromentVariableAccessTokenName))) { var auth = service.GetAuthentication(); ViewData["authenticated"] = auth.Authenticated ? "Authenticated" : "Not Authenticated"; ViewData["googlemapskey"] = configService.GetEnviroment(EnviromentVariableGoogleMapsKey); } return(View()); }
/// <summary> /// The entry point of the program, where the program control starts and ends. /// </summary> /// <param name="args">The command-line arguments.</param> public static void Main(string[] args) { using (var configService = new ConfigurationService()) using (var httpService = new HttpService()) using (var service = new MonzoService(httpService, configService.GetEnviroment(EnviromentVariableAccessTokenName))) { WriteLine(SectionBreak); var auth = service.GetAuthentication(); WriteLine(auth); ForegroundColor = (auth.Authenticated) ? ConsoleColor.Green : throw new UnauthorizedAccessException(auth.ToString()); WriteLine(SectionBreak); // Print Detected Acccounts. WriteLine("ID\tDesciption\t"); var accounts = service.GetAccounts(); foreach (var account in accounts.AccountList) { WriteLine(account.ID + "\t" + account.Description); } WriteLine(SectionBreak); // Print Physical Transactions by Date. WriteLine("ID\tName\tCreated\tLatitude\tLongitude\t"); var transactions = service.GetPhysicalTransactionsByDate(accounts.AccountList.ElementAt(0), DateTime.Now.AddDays(-7.0), DateTime.Now); transactions.TransactionList = transactions.TransactionList.Where(x => x.Merchant != null && x.Merchant.Address != null); foreach (var t in transactions.TransactionList.OrderBy(x => x.Created)) { WriteLine(t.ID + "\t" + t.Merchant.Name + "\t" + t.Created + "\t" + t.Merchant.Address.Latitude + "\t" + t.Merchant.Address.longitude); } } ReadKey(); }