public override void ViewDidLoad() { base.ViewDidLoad(); buttonSave.TouchUpInside += HandleTouchUpInsideSave; record = repository.Get(1); labelQuestion.Text = record.Question; // Perform any additional setup after loading the view, typically from a nib. }
public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions) { // Override point for customization after application launch. // If not required for your application you can safely delete this method Window = new UIWindow(UIScreen.MainScreen.Bounds); var storyboard = UIStoryboard.FromName("Main", NSBundle.MainBundle); UIViewController rootViewController = null; FinancialProfileRepository repository = new FinancialProfileRepository(); var record = repository.Get(1); if (record.Answer == null || record.Answer == "") { rootViewController = (UIViewController)storyboard.InstantiateInitialViewController();//.InstantiateViewController("BirthdayController"); } else { for (int i = 2; i < 6; i++) { record = repository.Get(i); if (record.Answer == null || record.Answer == "") { OtherQuestionController otherViewController = storyboard.InstantiateViewController("OtherQuestionController") as OtherQuestionController; otherViewController.Id = i; rootViewController = otherViewController; break; } } } if (rootViewController == null) { rootViewController = (UIViewController)storyboard.InstantiateViewController("OverviewController"); } Window.RootViewController = rootViewController; Window.MakeKeyAndVisible(); return(true); }
private void CalculateFinancialProfile() { MakeSureAllQuestionsAnswered(); var todaysDate = DateTime.Now.Date; var birthday = DateTime.Parse(repository.Get(1).Answer); var netWorthDate = repository.Get(2).ModifiedAt; var netWorth = int.Parse(repository.Get(2).Answer); var makeEachMonth = int.Parse(repository.Get(3).Answer); var spendOnHouse = int.Parse(repository.Get(4).Answer); var spendOnCar = int.Parse(repository.Get(5).Answer); var spendOnOther = int.Parse(repository.Get(6).Answer); var spendEachMonth = spendOnHouse + spendOnCar + spendOnOther; var totalNeeded = spendEachMonth * 12.5 * 12;//assuming 8% interest var principal = netWorth; var time = 0.00; var rate = (double)8 / (double)100; var depositPerMonth = makeEachMonth - spendEachMonth; var depositEachDay = (double)depositPerMonth * 12 / 365; time = CalculateTime(principal, rate, depositEachDay, totalNeeded); var d1 = DateTime.Parse(todaysDate.ToString("d")); var d2 = DateTime.Parse(netWorthDate.Value.ToString("d")); var daysSinceNetWorthSet = (d1 - d2).TotalDays; //Day's before net worth * interest > spending (net spending is positive?) textboxTimeRemaining.Text = (time - daysSinceNetWorthSet).ToString() + " days"; labelSummary.Text = "You will be " + Math.Truncate((((todaysDate - birthday).TotalDays) + (time - daysSinceNetWorthSet)) / 365) + " years old by the time your yearly expenses are less than your net worth * 8% interest. "; //Today's interest earned var currentNetWorth = NetWorthCalculator(principal, rate, depositEachDay, daysSinceNetWorthSet); textboxInterestToday.Text = String.Format("{0:C}", (decimal)Math.Round((double.Parse(currentNetWorth.ToString()) * .08 / 365), 2)); textboxNetWorthToday.Text = String.Format("{0:C}", (decimal)currentNetWorth); textboxSpendingToday.Text = String.Format("{0:C}", (decimal)Math.Round((double)spendEachMonth / 30, 2)); textboxSavingToday.Text = String.Format("{0:C}", (decimal)Math.Round((double)depositPerMonth / 30, 2)); textboxEarningToday.Text = String.Format("{0:C}", (decimal)Math.Round((double)makeEachMonth / 30, 2)); }
private void GetQuestion(int Id) { record = repository.Get(Id); }