private static void Header() { Console.Clear(); Shared.Header(); Console.WriteLine("Enter Activity\n"); Console.WriteLine("[0] Exit"); WriterHelper.RedText("=", 119); }
/// <summary> /// Main Menu /// </summary> public static void MainMenu() { int?selection = null; Console.Clear(); Header(); Console.WriteLine("Main Menu \n"); Console.WriteLine("[1] Enter Activity"); Console.WriteLine("[2] View Tracked Data"); Console.WriteLine("[3] Run Calculations \n"); Console.WriteLine("[0] Exit"); WriterHelper.RedText("=", 119); if (!string.IsNullOrWhiteSpace(PersistenceData.TempMessage)) { Console.WriteLine(PersistenceData.TempMessage); } else { Console.WriteLine($"Welcome {PersistenceData.ActiveUser.FirstName}"); } PersistenceData.TempMessage = string.Empty; Console.Write("Selection: "); var read = Console.ReadLine(); selection = Convert.ToInt32(read); switch (selection) { case 1: Activities.Add(); break; case 2: TrackedData.ViewBy(); break; case 3: Calculations.View(); break; case 0: Console.Clear(); Console.WriteLine("Goodbye..."); Console.ReadLine(); PersistenceData.ActiveUser = new User(); Environment.Exit(0); break; default: Console.WriteLine("Invalid selection, try again"); Console.ReadLine(); MainMenu(); break; } }
private static void Header() { Console.Clear(); Shared.Header(); Console.WriteLine("View Tracked Data\n"); Console.WriteLine("[1] View By Date"); Console.WriteLine("[2] View By Category"); Console.WriteLine("[3] View By Description\n"); Console.WriteLine("[0] Main Menu"); WriterHelper.RedText("=", 119); }
public static void Header() { Console.Clear(); Shared.Header(); Console.WriteLine("Calculations \n"); Console.WriteLine("[1] Time Spent Working Out [5] Time Spent Sleep"); Console.WriteLine("[2] Percentage of time Working Out [6] Percentage of time Sleeping"); Console.WriteLine("[3] Time Spent Class [7] Time Spent Relaxation"); Console.WriteLine("[4] Percentage of time Class [8] Percentage of time Relaxation\n"); Console.WriteLine("[0] Main Menu"); WriterHelper.RedText("=", 119); }
public static void View() { var selection = default(int); Header(); if (!string.IsNullOrEmpty(PersistenceData.TempResult)) { Console.WriteLine($"{PersistenceData.TempResult}"); WriterHelper.RedText("=", 119); } PersistenceData.TempResult = String.Empty; Console.Write("Selection: "); selection = Convert.ToInt32(Console.ReadLine()); CalculationMenu(selection); }
public static void Add() { #region --- Get Activities --- Header(); var activities = DbHelper.Activities(); activities.ForEach(c => Console.WriteLine($"[{c.Id}] {c.ActivityDescription}")); WriterHelper.RedText("=", 119); Console.Write("Select A Category: "); var option1 = Console.ReadLine(); var step1 = Convert.ToInt32(option1); var selectedCategory = activities.FirstOrDefault(c => c.Id == step1); if (step1 == 0) { Shared.MainMenu(); } var dates = DbHelper.CalendarDates(); #endregion #region --- Get Date --- Header(); dates.ForEach(d => Console.WriteLine($"[{d.Id}] {d.FormattedDate()}")); WriterHelper.RedText("=", 119); Console.Write("Select A Date: "); var option2 = Console.ReadLine(); var step2 = Convert.ToInt32(option2); var selectedDate = dates.FirstOrDefault(d => d.Id == step2); if (step2 == 0) { Shared.MainMenu(); } #endregion #region --- Get Time Spent --- Header(); var timeOfActivities = DbHelper.TimeOfActivities(); timeOfActivities.ForEach(toa => Console.WriteLine($"[{toa.Id}] {toa.TimeSpentOnActivity}")); WriterHelper.RedText("=", 119); Console.Write("How Long Did You Perform That Activity?: "); var option3 = Console.ReadLine(); var step3 = Convert.ToInt32(option3); var selectedTime = timeOfActivities.FirstOrDefault(s => s.Id == step3); #endregion // insert row in database var result = ActivityHelper.LogActivity(selectedCategory, selectedDate, selectedTime); if (result > 0) { PersistenceData.TempMessage = "Your activity has successfully been added!"; } else { PersistenceData.TempMessage = "Something went wrong..."; } Shared.Welcome(); }
public static void ViewByDescription() { var user = PersistenceData.ActiveUser; var selected = default(int); Console.Clear(); Shared.Header(); Console.WriteLine("View By Description: \n"); Console.WriteLine("[0] Exit"); WriterHelper.RedText("=", 119); #region --- Get Activities --- var descriptions = DbHelper.Activities(); descriptions.ForEach(c => Console.WriteLine($"[{c.Id}] {c.ActivityDescription}")); WriterHelper.RedText("=", 119); Console.Write("Select Description: "); selected = Convert.ToInt32(Console.ReadLine()); if (selected == 0) { ViewByMenu(selected); } var selectedActivity = descriptions.First(d => d.Id == selected); #endregion #region --- View By Description --- Console.Clear(); Header(); Console.WriteLine($"Description: {selectedActivity.ActivityDescription.ToUpper()}:\n"); Console.WriteLine(WindowTitle.VIEW_BY_DESCRIPTION); WriterHelper.WhiteText("-", 119); var viewby = DbHelper.ViewBy(); var row = 1; var total = default(decimal); var summary = viewby .Where(c => c.UserId == user.Id) .Where(c1 => c1.ActivityDescriptionId == selectedActivity.Id) .Select(a => new { Date = a.CalendarDate.ToString("dd MMMM yyyy"), Activity = a.ActivityDescription, TimeSpent = a.TimeSpentOnActivity }); if (summary.Any()) { summary.ToList().ForEach(r => { var index = row++.ToString().PadLeft(2, ' '); total += r.TimeSpent; Console.WriteLine( $"[{index}] {r.Date.PadRight(22, ' ')} {r.Activity.PadRight(43, ' ')} {r.TimeSpent}"); }); } else { Console.WriteLine("No data found for the selected description"); } WriterHelper.WhiteText("-", 119); Console.WriteLine($"Activity {selectedActivity.ActivityDescription} Total: {total} hours"); WriterHelper.RedText("=", 119); Console.Write("Selection: "); selected = Convert.ToInt32(Console.ReadLine()); ViewByMenu(selected); #endregion }
public static void ViewByDate() { var user = PersistenceData.ActiveUser; Console.Clear(); Shared.Header(); Console.WriteLine("View By Date: \n"); Console.WriteLine("[0] Exit"); WriterHelper.RedText("=", 119); #region --- Get Date Id --- var dates = DbHelper.CalendarDates(); dates.ForEach(d => Console.WriteLine($"[{d.Id}] {d.FormattedDate()}")); WriterHelper.RedText("=", 119); Console.Write("Select Date: "); var selection = Convert.ToInt32(Console.ReadLine()); var selectedDate = dates.First(d => d.Id == selection); if (selection == 0) { ViewByMenu(selection); } #endregion #region --- Display Data by Date --- Console.Clear(); Header(); Console.WriteLine($"{selectedDate.Date.ToString("dddd dd MMMM yyyy").ToUpper()}: \n"); var totalTimeTracked = default(decimal); var viewSummary = DbHelper.ViewBy(); var data = viewSummary.Where(a => a.UserId == user.Id) .Where(a1 => a1.CalendarDateId == selectedDate.Id) .GroupBy(c => c.CategoryDescription).Select(c1 => new { Category = c1.First().CategoryDescription, Activity = c1.First().ActivityDescription, TimeSpent = c1.Sum(d => d.TimeSpentOnActivity) }); Console.WriteLine(WindowTitle.VIEW_BY_DATE); WriterHelper.WhiteText("-", 119); if (data.Any()) { var rowNum = 1; data?.ToList().ForEach(d => { var row = rowNum++.ToString().PadRight(2, ' '); var category = d.Category.PadRight(26, ' '); var activity = d.Activity.PadRight(31, ' '); var total = d.TimeSpent; totalTimeTracked += total; Console.WriteLine($"[{row}] {category} {activity} {total}"); }); } else { Console.WriteLine("No tracked data found for the selected date"); } WriterHelper.WhiteText("-", 119); Console.WriteLine($"Activity Time Tracked: {totalTimeTracked} hours"); Console.WriteLine("Activity Time Untracked: 0 hours"); WriterHelper.RedText("=", 119); Console.Write("Selection: "); selection = Convert.ToInt32(Console.ReadLine()); ViewByMenu(selection); #endregion }
/// <summary> /// Header section /// Hint: Don't repeat yourself, by encapsulating this logic /// you can reuse it anywhere throughout your application /// </summary> public static void Header() { WriterHelper.RedText("=", 119); WriterHelper.CyanText("Time Tracker App", null); WriterHelper.RedText("=", 119); }