From 5812237d40ab606840f6c18da7d981444ead775f Mon Sep 17 00:00:00 2001 From: Luciano Mendaro Date: Mon, 2 Mar 2026 21:14:04 -0300 Subject: [PATCH 1/3] Project Finished --- CodingTracker.luc-me/.gitignore | 482 ++++++++++++++++++ CodingTracker.luc-me/.vscode/launch.json | 17 + CodingTracker.luc-me/.vscode/tasks.json | 17 + CodingTracker.luc-me/Coding.cs | 13 + .../CodingTracker.luc-me.csproj | 23 + CodingTracker.luc-me/CodingTracker.luc-me.sln | 24 + CodingTracker.luc-me/Controller.cs | 102 ++++ CodingTracker.luc-me/DatabaseManager.cs | 87 ++++ CodingTracker.luc-me/MenuOptions.cs | 10 + CodingTracker.luc-me/Program.cs | 12 + CodingTracker.luc-me/README.md | 31 ++ CodingTracker.luc-me/Tracker.db | Bin 0 -> 12288 bytes CodingTracker.luc-me/UIhandler.cs | 128 +++++ CodingTracker.luc-me/appsettings.json | 5 + 14 files changed, 951 insertions(+) create mode 100644 CodingTracker.luc-me/.gitignore create mode 100644 CodingTracker.luc-me/.vscode/launch.json create mode 100644 CodingTracker.luc-me/.vscode/tasks.json create mode 100644 CodingTracker.luc-me/Coding.cs create mode 100644 CodingTracker.luc-me/CodingTracker.luc-me.csproj create mode 100644 CodingTracker.luc-me/CodingTracker.luc-me.sln create mode 100644 CodingTracker.luc-me/Controller.cs create mode 100644 CodingTracker.luc-me/DatabaseManager.cs create mode 100644 CodingTracker.luc-me/MenuOptions.cs create mode 100644 CodingTracker.luc-me/Program.cs create mode 100644 CodingTracker.luc-me/README.md create mode 100644 CodingTracker.luc-me/Tracker.db create mode 100644 CodingTracker.luc-me/UIhandler.cs create mode 100644 CodingTracker.luc-me/appsettings.json diff --git a/CodingTracker.luc-me/.gitignore b/CodingTracker.luc-me/.gitignore new file mode 100644 index 000000000..0808c4ada --- /dev/null +++ b/CodingTracker.luc-me/.gitignore @@ -0,0 +1,482 @@ +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. +## +## Get latest from `dotnet new gitignore` + +# dotenv files +.env + +# User-specific files +*.rsuser +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Mono auto generated files +mono_crash.* + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +[Ww][Ii][Nn]32/ +[Aa][Rr][Mm]/ +[Aa][Rr][Mm]64/ +bld/ +[Bb]in/ +[Oo]bj/ +[Ll]og/ +[Ll]ogs/ + +# Visual Studio 2015/2017 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# Visual Studio 2017 auto generated files +Generated\ Files/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUnit +*.VisualState.xml +TestResult.xml +nunit-*.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# Benchmark Results +BenchmarkDotNet.Artifacts/ + +# .NET +project.lock.json +project.fragment.lock.json +artifacts/ + +# Tye +.tye/ + +# ASP.NET Scaffolding +ScaffoldingReadMe.txt + +# StyleCop +StyleCopReport.xml + +# Files built by Visual Studio +*_i.c +*_p.c +*_h.h +*.ilk +*.meta +*.obj +*.iobj +*.pch +*.pdb +*.ipdb +*.pgc +*.pgd +*.rsp +# but not Directory.Build.rsp, as it configures directory-level build defaults +!Directory.Build.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*_wpftmp.csproj +*.log +*.tlog +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opendb +*.opensdf +*.sdf +*.cachefile +*.VC.db +*.VC.VC.opendb + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# Visual Studio Trace Files +*.e2e + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# AxoCover is a Code Coverage Tool +.axoCover/* +!.axoCover/settings.json + +# Coverlet is a free, cross platform Code Coverage Tool +coverage*.json +coverage*.xml +coverage*.info + +# Visual Studio code coverage results +*.coverage +*.coveragexml + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# Note: Comment the next line if you want to checkin your web deploy settings, +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# Microsoft Azure Web App publish settings. Comment the next line if you want to +# checkin your Azure Web App publish settings, but sensitive information contained +# in these scripts will be unencrypted +PublishScripts/ + +# NuGet Packages +*.nupkg +# NuGet Symbol Packages +*.snupkg +# The packages folder can be ignored because of Package Restore +**/[Pp]ackages/* +# except build/, which is used as an MSBuild target. +!**/[Pp]ackages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/[Pp]ackages/repositories.config +# NuGet v3's project.json files produces more ignorable files +*.nuget.props +*.nuget.targets + +# Microsoft Azure Build Output +csx/ +*.build.csdef + +# Microsoft Azure Emulator +ecf/ +rcf/ + +# Windows Store app package directories and files +AppPackages/ +BundleArtifacts/ +Package.StoreAssociation.xml +_pkginfo.txt +*.appx +*.appxbundle +*.appxupload + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!?*.[Cc]ache/ + +# Others +ClientBin/ +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.jfm +*.pfx +*.publishsettings +orleans.codegen.cs + +# Including strong name files can present a security risk +# (https://github.com/github/gitignore/pull/2483#issue-259490424) +#*.snk + +# Since there are multiple workflows, uncomment next line to ignore bower_components +# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) +#bower_components/ + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm +ServiceFabricBackup/ +*.rptproj.bak + +# SQL Server files +*.mdf +*.ldf +*.ndf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings +*.rptproj.rsuser +*- [Bb]ackup.rdl +*- [Bb]ackup ([0-9]).rdl +*- [Bb]ackup ([0-9][0-9]).rdl + +# Microsoft Fakes +FakesAssemblies/ + +# GhostDoc plugin setting file +*.GhostDoc.xml + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat +node_modules/ + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio 6 auto-generated workspace file (contains which files were open etc.) +*.vbw + +# Visual Studio 6 auto-generated project file (contains which files were open etc.) +*.vbp + +# Visual Studio 6 workspace and project file (working project files containing files to include in project) +*.dsw +*.dsp + +# Visual Studio 6 technical files +*.ncb +*.aps + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# Paket dependency manager +.paket/paket.exe +paket-files/ + +# FAKE - F# Make +.fake/ + +# CodeRush personal settings +.cr/personal + +# Python Tools for Visual Studio (PTVS) +__pycache__/ +*.pyc + +# Cake - Uncomment if you are using it +# tools/** +# !tools/packages.config + +# Tabs Studio +*.tss + +# Telerik's JustMock configuration file +*.jmconfig + +# BizTalk build output +*.btp.cs +*.btm.cs +*.odx.cs +*.xsd.cs + +# OpenCover UI analysis results +OpenCover/ + +# Azure Stream Analytics local run output +ASALocalRun/ + +# MSBuild Binary and Structured Log +*.binlog + +# NVidia Nsight GPU debugger configuration file +*.nvuser + +# MFractors (Xamarin productivity tool) working folder +.mfractor/ + +# Local History for Visual Studio +.localhistory/ + +# Visual Studio History (VSHistory) files +.vshistory/ + +# BeatPulse healthcheck temp database +healthchecksdb + +# Backup folder for Package Reference Convert tool in Visual Studio 2017 +MigrationBackup/ + +# Ionide (cross platform F# VS Code tools) working folder +.ionide/ + +# Fody - auto-generated XML schema +FodyWeavers.xsd + +# VS Code files for those working on multiple tools +.vscode/* +!.vscode/settings.json +!.vscode/tasks.json +!.vscode/launch.json +!.vscode/extensions.json +*.code-workspace + +# Local History for Visual Studio Code +.history/ + +# Windows Installer files from build outputs +*.cab +*.msi +*.msix +*.msm +*.msp + +# JetBrains Rider +*.sln.iml +.idea/ + +## +## Visual studio for Mac +## + + +# globs +Makefile.in +*.userprefs +*.usertasks +config.make +config.status +aclocal.m4 +install-sh +autom4te.cache/ +*.tar.gz +tarballs/ +test-results/ + +# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore +# General +.DS_Store +.AppleDouble +.LSOverride + +# Icon must end with two \r +Icon + + +# Thumbnails +._* + +# Files that might appear in the root of a volume +.DocumentRevisions-V100 +.fseventsd +.Spotlight-V100 +.TemporaryItems +.Trashes +.VolumeIcon.icns +.com.apple.timemachine.donotpresent + +# Directories potentially created on remote AFP share +.AppleDB +.AppleDesktop +Network Trash Folder +Temporary Items +.apdisk + +# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore +# Windows thumbnail cache files +Thumbs.db +ehthumbs.db +ehthumbs_vista.db + +# Dump file +*.stackdump + +# Folder config file +[Dd]esktop.ini + +# Recycle Bin used on file shares +$RECYCLE.BIN/ + +# Windows Installer files +*.cab +*.msi +*.msix +*.msm +*.msp + +# Windows shortcuts +*.lnk + +# Vim temporary swap files +*.swp diff --git a/CodingTracker.luc-me/.vscode/launch.json b/CodingTracker.luc-me/.vscode/launch.json new file mode 100644 index 000000000..ebe38464b --- /dev/null +++ b/CodingTracker.luc-me/.vscode/launch.json @@ -0,0 +1,17 @@ +{ + "version": "0.2.0", + "configurations": [ + { + "name": ".NET Core Launch (console)", + "type": "coreclr", + "request": "launch", + "preLaunchTask": "build", + "program": "${workspaceFolder}/bin/Debug/net10.0/CodingTracker.luc-me.dll", + "args": [], + "cwd": "${workspaceFolder}", + "stopAtEntry": false, + "console": "externalTerminal" + } + + ] +} \ No newline at end of file diff --git a/CodingTracker.luc-me/.vscode/tasks.json b/CodingTracker.luc-me/.vscode/tasks.json new file mode 100644 index 000000000..e64c51247 --- /dev/null +++ b/CodingTracker.luc-me/.vscode/tasks.json @@ -0,0 +1,17 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "label": "build", + "command": "dotnet", + "type": "process", + "args": [ + "build", + "${workspaceFolder}/CodingTracker.luc-me.csproj", + "/property:GenerateFullPaths=true", + "/consoleloggerparameters:NoSummary" + ], + "problemMatcher": "$msCompile" + } + ] +} \ No newline at end of file diff --git a/CodingTracker.luc-me/Coding.cs b/CodingTracker.luc-me/Coding.cs new file mode 100644 index 000000000..8ef3c5982 --- /dev/null +++ b/CodingTracker.luc-me/Coding.cs @@ -0,0 +1,13 @@ +using System; +using System.Runtime.CompilerServices; + +namespace CodingTracker.luc_me; + +internal class Coding +{ + public int Id { get; set; } + public string? StartTime { get; set; } + public string? EndTime { get; set; } + + public string? Duration { get; set; } +} diff --git a/CodingTracker.luc-me/CodingTracker.luc-me.csproj b/CodingTracker.luc-me/CodingTracker.luc-me.csproj new file mode 100644 index 000000000..c559c06f8 --- /dev/null +++ b/CodingTracker.luc-me/CodingTracker.luc-me.csproj @@ -0,0 +1,23 @@ + + + + Exe + net10.0 + CodingTracker.luc_me + enable + enable + + + + + + + + + + + PreserveNewest + + + + diff --git a/CodingTracker.luc-me/CodingTracker.luc-me.sln b/CodingTracker.luc-me/CodingTracker.luc-me.sln new file mode 100644 index 000000000..096e9abca --- /dev/null +++ b/CodingTracker.luc-me/CodingTracker.luc-me.sln @@ -0,0 +1,24 @@ +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.5.2.0 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingTracker.luc-me", "CodingTracker.luc-me.csproj", "{C378C5B7-526F-17F7-5576-40B8D71F9B87}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {C378C5B7-526F-17F7-5576-40B8D71F9B87}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C378C5B7-526F-17F7-5576-40B8D71F9B87}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C378C5B7-526F-17F7-5576-40B8D71F9B87}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C378C5B7-526F-17F7-5576-40B8D71F9B87}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {C83D2359-0419-44C1-A646-4963F8AF5E99} + EndGlobalSection +EndGlobal diff --git a/CodingTracker.luc-me/Controller.cs b/CodingTracker.luc-me/Controller.cs new file mode 100644 index 000000000..6930b6faa --- /dev/null +++ b/CodingTracker.luc-me/Controller.cs @@ -0,0 +1,102 @@ + +namespace CodingTracker.luc_me; + +public class Controller +{ + DatabaseManager database = new(); + UIhandler ui = new(); + public void MenuHandler() + { + database.CreateTable(); + ui.Flyer(); + + bool endApp = false; + while (!endApp) + { + MenuOptions op = ui.MainMenu(); + + switch (op) + { + case MenuOptions.Insert_session: + AddSession(); + break; + case MenuOptions.See_tracked_sessions: + ViewAll(); + break; + case MenuOptions.Delete_session: + DeleteSession(); + break; + case MenuOptions.Update_session: + UpdateSession(); + break; + case MenuOptions.Close_app: + endApp = true; + break; + default: + break; + + } + } + } + private void AddSession() + { + string duration; + string startTime; + string endTime; + do + { + startTime = ui.GetTimeInput("\nPlease insert the time you start coding: (Format: H:mm). Type 0 to return main menu."); + endTime = ui.GetTimeInput("\nPlease insert the time you end coding: (Format: H:mm). Type 0 to return main menu."); + + } + while (!ui.TryGetDuration(startTime, endTime, out duration)); + + + Coding session = new(); + session.StartTime = startTime; + session.EndTime = endTime; + session.Duration = duration; + + database.Insert(session); + + ui.CleanConsole(); + } + private void ViewAll() + { + var sessions = database.Get(); + ui.ShowTable(sessions); + + ui.CleanConsole(); + } + + private void DeleteSession() + { + var sessions = database.Get(); + var selectedSessions = ui.SelectList(sessions); + database.Delete(selectedSessions); + } + + private void UpdateSession() + { + var sessions = database.Get(); + var selectedSessions = ui.SelectList(sessions); + string duration=""; + foreach (Coding session in selectedSessions) + { + do + { + ui.PrintSession(session); + session.StartTime = ui.GetTimeInput("\nPlease insert the time you start coding: (Format: H:mm). Type 0 to return main menu."); + session.EndTime = ui.GetTimeInput("\nPlease insert the time you end coding: (Format: H:mm). Type 0 to return main menu."); + + } + while (!ui.TryGetDuration(session.StartTime, session.EndTime, out duration)); + + session.Duration = duration; + } + + database.Update(selectedSessions); + } + + +} diff --git a/CodingTracker.luc-me/DatabaseManager.cs b/CodingTracker.luc-me/DatabaseManager.cs new file mode 100644 index 000000000..c9c3564f5 --- /dev/null +++ b/CodingTracker.luc-me/DatabaseManager.cs @@ -0,0 +1,87 @@ +using System; +using System.Linq.Expressions; +using Dapper; +using Microsoft.Data.Sqlite; +using Microsoft.Extensions.Configuration; + + +namespace CodingTracker.luc_me; + +public class DatabaseManager +{ + + static string? connectionString=""; + public DatabaseManager() + { + var config = new ConfigurationBuilder() + .AddJsonFile("appsettings.json") + .Build(); + connectionString= config.GetConnectionString("SQLite"); + + } + internal void CreateTable() + { + using SqliteConnection connection = new(connectionString); + connection.Open(); + string sql = @"CREATE TABLE IF NOT EXISTS Coding ( + Id INTEGER PRIMARY KEY AUTOINCREMENT, + StartTime TEXT, + EndTime TEXT, + Duration TEXT + );"; + + connection.Execute(sql); + connection.Close(); + } + internal void Insert(Coding session) + { + using SqliteConnection connection = new(connectionString); + connection.Open(); + string sql = "INSERT INTO Coding (StartTime,EndTime,Duration) VALUES (@startTime,@endTime,@duration)"; + connection.Execute(sql,new { + startTime = session.StartTime, + endTime = session.EndTime, + duration = session.Duration + }); + + connection.Close(); + } + internal List Get() + { + using SqliteConnection connection = new(connectionString); + connection.Open(); + + string sql = "SELECT * FROM Coding"; + var sessions = connection.Query(sql).ToList(); + + return sessions; + } + internal void Delete(List selectedSessions) + { + using SqliteConnection connection = new(connectionString); + connection.Open(); + var ids = selectedSessions.Select(session=>session.Id); + + string sql = "DELETE FROM Coding WHERE Id IN @ids"; + connection.Execute(sql,new {ids}); + } + internal void Update(List selectedSessions) + { + using SqliteConnection connection = new(connectionString); + connection.Open(); + + string sql = @"UPDATE Coding SET + StartTime = @startTime, + EndTime = @endTime, + Duration = @duration + WHERE Id = @id + "; + foreach (Coding s in selectedSessions) + connection.Execute(sql,new { + startTime = s.StartTime, + endTime = s.EndTime, + duration = s.Duration, + id = s.Id + }); + } +} diff --git a/CodingTracker.luc-me/MenuOptions.cs b/CodingTracker.luc-me/MenuOptions.cs new file mode 100644 index 000000000..c766fe853 --- /dev/null +++ b/CodingTracker.luc-me/MenuOptions.cs @@ -0,0 +1,10 @@ +namespace CodingTracker.luc_me; + +public enum MenuOptions +{ + Insert_session, + See_tracked_sessions, + Delete_session, + Update_session, + Close_app +} diff --git a/CodingTracker.luc-me/Program.cs b/CodingTracker.luc-me/Program.cs new file mode 100644 index 000000000..c8e2bea32 --- /dev/null +++ b/CodingTracker.luc-me/Program.cs @@ -0,0 +1,12 @@ + +namespace CodingTracker.luc_me +{ + class Program + { + static void Main(string[] args) + { + var controller = new Controller(); + controller.MenuHandler(); + } + } +} diff --git a/CodingTracker.luc-me/README.md b/CodingTracker.luc-me/README.md new file mode 100644 index 000000000..d339a69bd --- /dev/null +++ b/CodingTracker.luc-me/README.md @@ -0,0 +1,31 @@ +# Coding Tracker App +This app allows users to track their coding sessions by logging the start time and the end time of the session. + +## Given requeriments +- This application has the same requirements as the previous project, except that now you'll be logging your daily coding time. +- To show the data on the console, you should use the Spectre.Console library. +- You're required to have separate classes in different files (i.e. UserInput.cs, Validation.cs, CodingController.cs) +- You should tell the user the specific format you want the date and time to be logged and not allow any other format. +- You'll need to create a configuration file called appsettings.json, which will contain your database path and connection strings (and any other configs you might need). +- You'll need to create a CodingSession class in a separate file. It will contain the properties of your coding session: Id, StartTime, EndTime, Duration. When reading from the database, you can't use an anonymous object, you have to read your table into a List of CodingSession. +- The user shouldn't input the duration of the session. It should be calculated based on the Start and End times +- The user should be able to input the start and end times manually. +- You need to use Dapper ORM for the data access instead of ADO.NET. (This requirement was included in Feb/2024) +- Follow the DRY Principle, and avoid code repetition. +- Don't forget the ReadMe explaining your thought process. + +## Project Struct +- DatabaseManager : This class can access to the database using Dapper which is a basic ORM. +- UIhandler : This class shows the UI and manage the user's input. Use Spectre.Console. +- Controller : This class connect the database with the UI and add the logic the app. +- MenuOptions : This is a enum used by UIhandler and controller to comunicate which option was selected. +- Coding : This class represent a coding session with the same properties of the table from the database. +- Program : This is the principal file, with the Main method. + +## Improvements +- Add date to the properties of coding session. +- Add style to UI texts. +- Add a real time tracking function + +## Reflections and challenges +This project is similar to the habit tracker so it was easy the part of the crud operations besides, dapper simplifies these operations. I think the most difficult part was setting the project to run in vscode instead of visual studio. I feel comfortable with the oop, but I have the thinking that I'm using the classes incorrectly. I will apreciate the feedback. \ No newline at end of file diff --git a/CodingTracker.luc-me/Tracker.db b/CodingTracker.luc-me/Tracker.db new file mode 100644 index 0000000000000000000000000000000000000000..3f8205ca020795eacebac0bf6d0bf3ee0450339e GIT binary patch literal 12288 zcmeI&-%7$z90%}o{0o9jLK)tjOGSyzO@v)#c8HOh%>{WCD_00QQRf5HMUT)^^b|cs zj}Tq=0R40bDMVLw5#Jy4?3~~E{SM=ECtLr#JqmqsJDpFwP#7%7IA@1KFh*0x;`G}D zr%7V7p!;h5Q{>peV>wGzvAs8@STrCY009U<00Izz00bZa0SG_<0>3EGi>1^`g%3jS zdh9P|WBSv3weV+4Ke*Xl##@eTx>C5!qqY<~wWYwD_*LpG-?w;LEf)EMw?4Bq9gc## zXpC*05amQEn-O2a9tykb$`k2`o?~~K&On^XfoNX1XLgtRJF@Fmw_Ez5HxJ#>#22o- z+})JH@Vl+!<=hKL(_r1UePlVSyt0Jy#FQ81U3sPn0s;_#00bZa0SG_<0uX=z1Rwx` zKN85NlT1}r-L%ZQUZ+9RElta(qO4)*8g1!Xluc}E^#;}Irlwi-20iG0p`aR8-83zu zLAiV~s;gNwgX(IAX3&|dck^8NV00lM009U<00Izz00bZa0SG_<0ucB|0vR4J^60CC F^e3() + .Title("What do you want to do?") + .AddChoices(Enum.GetValues()) + .UseConverter(options => options.ToString().Replace("_"," ")) + ); + + return op; + } + + internal string GetTimeInput(string message) + { + DateTime timeTemp; + var time = new TextPrompt(message) + .DefaultValue(DateTime.UtcNow.ToString("H:mm")).ShowDefaultValue() + .Validate(time => + { + if (!DateTime.TryParseExact(time,"H:mm", null, DateTimeStyles.None, out timeTemp) || timeTemp > DateTime.UtcNow) + return ValidationResult.Error("The time isn't valid"); + + return ValidationResult.Success(); + } + ); + + var input = AnsiConsole.Prompt(time); + + AnsiConsole.WriteLine(input); + return input; + } + internal bool TryGetDuration(string startTime, string endTime,out string duration) + { + duration = ""; + + DateTime time1; + DateTime time2; + DateTime.TryParse(startTime,out time1); + DateTime.TryParse(endTime,out time2); + TimeSpan timeDuration = time2-time1; + if (timeDuration <= TimeSpan.Zero) + { + AnsiConsole.WriteLine($"\nThe end time must be after the start time!\n"); + return false; + } + + else + { + duration = timeDuration.ToString(@"hh\:mm"); + AnsiConsole.WriteLine($"\nYou were coding for {duration}!\n"); + return true; + } + + + } + internal void ShowTable(List sessions) + { + var table = new Table(); + + + table.Border(TableBorder.Rounded); + table.BorderColor(Color.Grey); + + table.Expand(); + table.Title("[bold]All sessions[/]"); + + table.AddColumn("Id"); + table.AddColumn("Start Time"); + table.AddColumn("End Time"); + table.AddColumn("Duration"); + + foreach (Coding session in sessions) + { + table.AddRow( + session.Id.ToString(), + session.StartTime, + session.EndTime, + session.Duration + ); + } + + AnsiConsole.Write(table); + + } + + internal List SelectList(List sessions) + { + var selectedSessions = AnsiConsole.Prompt( + new MultiSelectionPrompt() + .Title("Select the sessions you want to delete") + .NotRequired() + .AddChoices(sessions) + .UseConverter(s => $"Id: {s.Id} | {s.StartTime} -> {s.EndTime} | Duration: {s.Duration}") + ); + + return selectedSessions; + } + + internal void CleanConsole() + { + Console.ReadLine(); + AnsiConsole.Clear(); + Flyer(); + } + + internal void PrintSession(Coding s) + { + AnsiConsole.WriteLine($"\nSession Id: {s.Id} | {s.StartTime} -> {s.EndTime} | Duration: {s.Duration}"); + } +} diff --git a/CodingTracker.luc-me/appsettings.json b/CodingTracker.luc-me/appsettings.json new file mode 100644 index 000000000..1c1e0f2ab --- /dev/null +++ b/CodingTracker.luc-me/appsettings.json @@ -0,0 +1,5 @@ +{ + "ConnectionStrings": { + "SQLite": "DataSource = Tracker.db;" + } +} \ No newline at end of file From 5311c06702e5ff4b3cf823a8b9702c138268c3c9 Mon Sep 17 00:00:00 2001 From: Luciano Mendaro Date: Mon, 2 Mar 2026 21:15:16 -0300 Subject: [PATCH 2/3] README moved --- CodingTracker.luc-me/README.md => README.md | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename CodingTracker.luc-me/README.md => README.md (100%) diff --git a/CodingTracker.luc-me/README.md b/README.md similarity index 100% rename from CodingTracker.luc-me/README.md rename to README.md From ad8e1b37c0bd1eb104d0152e1526bd3c530b9282 Mon Sep 17 00:00:00 2001 From: Luciano Mendaro Date: Mon, 2 Mar 2026 21:32:28 -0300 Subject: [PATCH 3/3] unnecessary 'using' removed --- CodingTracker.luc-me/Coding.cs | 3 --- CodingTracker.luc-me/DatabaseManager.cs | 1 - 2 files changed, 4 deletions(-) diff --git a/CodingTracker.luc-me/Coding.cs b/CodingTracker.luc-me/Coding.cs index 8ef3c5982..23c8ae205 100644 --- a/CodingTracker.luc-me/Coding.cs +++ b/CodingTracker.luc-me/Coding.cs @@ -1,6 +1,3 @@ -using System; -using System.Runtime.CompilerServices; - namespace CodingTracker.luc_me; internal class Coding diff --git a/CodingTracker.luc-me/DatabaseManager.cs b/CodingTracker.luc-me/DatabaseManager.cs index c9c3564f5..323db5b65 100644 --- a/CodingTracker.luc-me/DatabaseManager.cs +++ b/CodingTracker.luc-me/DatabaseManager.cs @@ -1,4 +1,3 @@ -using System; using System.Linq.Expressions; using Dapper; using Microsoft.Data.Sqlite;