diff --git a/.gitignore b/.gitignore
index 154e127..0808c4a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,7 +1,10 @@
## Ignore Visual Studio temporary files, build results, and
## files generated by popular Visual Studio add-ons.
##
-## Get latest from https://github.com/github/gitignore/blob/main/VisualStudio.gitignore
+## Get latest from `dotnet new gitignore`
+
+# dotenv files
+.env
# User-specific files
*.rsuser
@@ -85,6 +88,8 @@ StyleCopReport.xml
*.pgc
*.pgd
*.rsp
+# but not Directory.Build.rsp, as it configures directory-level build defaults
+!Directory.Build.rsp
*.sbr
*.tlb
*.tli
@@ -399,6 +404,7 @@ FodyWeavers.xsd
# JetBrains Rider
*.sln.iml
+.idea/
##
## Visual studio for Mac
@@ -418,11 +424,7 @@ autom4te.cache/
tarballs/
test-results/
-# Mac bundle stuff
-*.dmg
-*.app
-
-# content below from: https://github.com/github/gitignore/blob/master/Global/macOS.gitignore
+# content below from: https://github.com/github/gitignore/blob/main/Global/macOS.gitignore
# General
.DS_Store
.AppleDouble
@@ -451,7 +453,7 @@ Network Trash Folder
Temporary Items
.apdisk
-# content below from: https://github.com/github/gitignore/blob/master/Global/Windows.gitignore
+# content below from: https://github.com/github/gitignore/blob/main/Global/Windows.gitignore
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
@@ -475,3 +477,6 @@ $RECYCLE.BIN/
# Windows shortcuts
*.lnk
+
+# Vim temporary swap files
+*.swp
diff --git a/CodingTracker.dsills735/.gitignore b/CodingTracker.dsills735/.gitignore
new file mode 100644
index 0000000..0808c4a
--- /dev/null
+++ b/CodingTracker.dsills735/.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.dsills735/CodingTracker.UnitTesting/CodingTracker.Testing.csproj b/CodingTracker.dsills735/CodingTracker.UnitTesting/CodingTracker.Testing.csproj
new file mode 100644
index 0000000..3008e1f
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker.UnitTesting/CodingTracker.Testing.csproj
@@ -0,0 +1,27 @@
+
+
+
+ net10.0
+ latest
+ enable
+ enable
+ false
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/CodingTracker.dsills735/CodingTracker.UnitTesting/IntegrationTests.cs b/CodingTracker.dsills735/CodingTracker.UnitTesting/IntegrationTests.cs
new file mode 100644
index 0000000..04b2bd2
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker.UnitTesting/IntegrationTests.cs
@@ -0,0 +1,87 @@
+
+using Microsoft.Data.Sqlite;
+using Dapper;
+
+namespace CodingTracker.Testing;
+
+
+public class IntegrationTests
+{
+ string connString = "Data Source=:memory:";
+
+ //private readonly SqliteConnection _connection;
+ [Test]
+ public void AddRecordToDatabase_AddsRecordToDb()
+ {
+ using var connection = new SqliteConnection(connString);
+ connection.Open();
+
+ //arrange
+ DateTime start = DateTime.Parse("2024-01-01 10:00:00");
+ DateTime end = DateTime.Parse("2024-01-01 11:00:00");
+ string duration = "1:00:00";
+ var tableCreate = SqlHelper.TableCreate();
+ connection.Execute(tableCreate);
+ //act
+ DatabaseManager.AddRecordToDatabase(start, end, duration, connection);
+ //assert
+ var count = connection.ExecuteScalar("SELECT COUNT(*) FROM Coding_Tracker");
+ Assert.That(count, Is.GreaterThan(0));
+ connection.Close();
+ }
+
+
+ [Test]
+ public void TableCreate_EnsuresTableIsCreated()
+ {
+ using var connection = new SqliteConnection(connString);
+ connection.Open();
+ //act
+ var tableCreate = SqlHelper.TableCreate();
+ connection.Execute(tableCreate);
+ //assert
+ var result = connection.QueryFirstOrDefault("SELECT name FROM sqlite_master WHERE type='table' AND name='Coding_Tracker';");
+ Assert.That(result, Is.EqualTo("Coding_Tracker"));
+ connection.Close();
+ }
+
+ [Test]
+ public void ViewAllCommand_ReturnsAllRecords()
+ {
+ using var connection = new SqliteConnection(connString);
+ connection.Open();
+ //arrange
+ var tableCreate = SqlHelper.TableCreate();
+ connection.Execute(tableCreate);
+ DateTime start = DateTime.Parse("2024-01-01 10:00:00");
+ DateTime end = DateTime.Parse("2024-01-01 11:00:00");
+ string duration = "1:00:00";
+ DatabaseManager.AddRecordToDatabase(start, end, duration, connection);
+ //act
+ var records = connection.Query(SqlHelper.ViewAllCommand()).ToList();
+ //assert
+ Assert.That(records.Count, Is.EqualTo(1));
+ connection.Close();
+
+ }
+ [Test]
+ public void DeleteSingleRecord_RemovesRecordFromDatabase()
+ {
+ using var connection = new SqliteConnection(connString);
+ connection.Open();
+
+ var tableCreate = SqlHelper.TableCreate();
+ connection.Execute(tableCreate);
+
+ DateTime start = DateTime.Parse("2024-01-01 10:00:00");
+ DateTime end = DateTime.Parse("2024-01-01 11:00:00");
+ string duration = "1:00:00";
+ DatabaseManager.AddRecordToDatabase(start, end, duration, connection);
+
+ var record = connection.QueryFirstOrDefault("SELECT * FROM Coding_Tracker LIMIT 1");
+ connection.Execute(SqlHelper.DeleteSingleRecord(), new { Id = record.Id });
+ record = connection.QueryFirstOrDefault("SELECT * FROM Coding_Tracker LIMIT 1");
+
+ Assert.That(record, Is.Null);
+ }
+}
diff --git a/CodingTracker.dsills735/CodingTracker.UnitTesting/UnitTests.cs b/CodingTracker.dsills735/CodingTracker.UnitTesting/UnitTests.cs
new file mode 100644
index 0000000..04bfeff
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker.UnitTesting/UnitTests.cs
@@ -0,0 +1,40 @@
+internal class UnitTests {
+ [TestCase("2026-05-26 10:00:00", "2026-05-26 13:00:00", 3, 0)]
+ [TestCase("2026-05-26 10:00:00", "2026-05-26 10:45:00", 0, 45)]
+ [TestCase("2026-05-26 22:00:00", "2026-05-27 02:00:00", 4, 0)]
+ [TestCase("2026-05-26 10:00:00", "2026-05-26 10:00:00", 0, 0)]
+ [TestCase("2026-05-26 15:00:00", "2026-05-26 13:00:00", -2, 0)]
+ public void CalculateTimeDuration_ReturnsExpectedTimeSpan(
+ string startString,
+ string endString,
+ int expectedHours,
+ int expectedMinutes)
+ {
+ var startTime = DateTime.Parse(startString);
+ var endTime = DateTime.Parse(endString);
+ var expectedDuration = TimeSpan.FromHours(expectedHours) + TimeSpan.FromMinutes(expectedMinutes);
+
+ var actualDuration = CalculateDuration.CalculateTimeDuration(startTime, endTime);
+
+ Assert.That(actualDuration, Is.EqualTo(expectedDuration));
+ }
+
+ [TestCase(0, 5, 9, "00:05:09")]
+ [TestCase(0, 0, 0, "00:00:00")]
+ [TestCase(0, 5, 9, "00:05:09")]
+ [TestCase(1, 10, 20, "01:10:20")]
+ [TestCase(12, 34, 56, "12:34:56")]
+ [TestCase(23, 59, 59, "23:59:59")]
+ [TestCase(24, 0, 0, "00:00:00")]
+ [TestCase(26, 30, 0, "02:30:00")]
+ [TestCase(0, 0, 65, "00:01:05")]
+ [TestCase(0, 120, 0, "02:00:00")]
+ [TestCase(5, -30, 0, "04:30:00")]
+ public void TimeFormatter_ReturnsFormattedString(int hours, int minutes, int seconds, string expected)
+ {
+ TimeSpan duration = new TimeSpan(hours, minutes, seconds);
+ string result = CalculateDuration.TimeFormatter(duration);
+ Assert.That(result, Is.EqualTo(expected));
+ }
+
+}
diff --git a/CodingTracker.dsills735/CodingTracker.sln b/CodingTracker.dsills735/CodingTracker.sln
new file mode 100644
index 0000000..4d8371a
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker.sln
@@ -0,0 +1,51 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 18
+VisualStudioVersion = 18.3.11429.125
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingTracker", "CodingTracker\CodingTracker.csproj", "{2F7760D3-9B8E-4F5F-A674-6B736C03B72C}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CodingTracker.Testing", "CodingTracker.UnitTesting\CodingTracker.Testing.csproj", "{0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Debug|x64 = Debug|x64
+ Debug|x86 = Debug|x86
+ Release|Any CPU = Release|Any CPU
+ Release|x64 = Release|x64
+ Release|x86 = Release|x86
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|x64.Build.0 = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Debug|x86.Build.0 = Debug|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|x64.ActiveCfg = Release|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|x64.Build.0 = Release|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|x86.ActiveCfg = Release|Any CPU
+ {2F7760D3-9B8E-4F5F-A674-6B736C03B72C}.Release|x86.Build.0 = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|x64.Build.0 = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Debug|x86.Build.0 = Debug|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|x64.ActiveCfg = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|x64.Build.0 = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|x86.ActiveCfg = Release|Any CPU
+ {0C56C2A8-BC4D-4FA5-A8A6-E8C7A9E19A58}.Release|x86.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {423A5FD1-771D-40F2-B4C2-E0A36514338B}
+ EndGlobalSection
+EndGlobal
diff --git a/CodingTracker.dsills735/CodingTracker/Coding Sessions/CalculateDuration.cs b/CodingTracker.dsills735/CodingTracker/Coding Sessions/CalculateDuration.cs
new file mode 100644
index 0000000..2aa7c6f
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Coding Sessions/CalculateDuration.cs
@@ -0,0 +1,15 @@
+//this is going to use the start and end time from coding session to calculate the duration of the session.
+public class CalculateDuration
+{
+ public static TimeSpan CalculateTimeDuration(DateTime start, DateTime end)
+ {
+ TimeSpan duration = end - start;
+ return duration;
+ }
+ public static string TimeFormatter(TimeSpan duration) {
+ string timeSpentCoding = $"{duration.Hours:00}:{duration.Minutes:00}:{duration.Seconds:00}";
+ return timeSpentCoding;
+ }
+
+
+}
\ No newline at end of file
diff --git a/CodingTracker.dsills735/CodingTracker/Coding Sessions/CodingSession.cs b/CodingTracker.dsills735/CodingTracker/Coding Sessions/CodingSession.cs
new file mode 100644
index 0000000..96b3431
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Coding Sessions/CodingSession.cs
@@ -0,0 +1,10 @@
+public class CodingSession
+{
+ public int Id { get; set; }
+ public required string Start_Time { get; set; }
+ public required string End_Time { get; set; }
+
+ public required string Duration { get; set; }
+
+}
+
diff --git a/CodingTracker.dsills735/CodingTracker/Coding Sessions/LiveSession.cs b/CodingTracker.dsills735/CodingTracker/Coding Sessions/LiveSession.cs
new file mode 100644
index 0000000..89a5004
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Coding Sessions/LiveSession.cs
@@ -0,0 +1,73 @@
+
+using Microsoft.Data.Sqlite;
+using Microsoft.Extensions.Configuration;
+
+internal class LiveSession
+{
+ static string? connectionStr = Program.config.GetConnectionString("DefaultConnection");
+ internal static void StartCodingSession()
+ {
+ DateTime start;
+ DateTime end;
+ Console.Clear();
+ Console.WriteLine(@"You are starting a new coding session, when you are ready to start
+ press 1. If you would like to exit to the main menu, press Q.");
+ string response = Console.ReadLine()!;
+
+ if (response == "1")
+ {
+ bool validInput = false;
+ start = DateTime.Now;
+ Console.WriteLine($"You have begun your coding session at {start}. Dont forget the \";\"!");
+ Console.WriteLine();
+ Console.WriteLine("When you finish this session, please enter \"1\"");
+ string userInput = Console.ReadLine()!;
+ while (!validInput)
+ {
+
+ if (userInput == "1")
+ {
+ validInput = true;
+ end = DateTime.Now;
+ Console.WriteLine($"You finished your coding session at {end}. Calculating duration now...");
+ TimeSpan duration = CalculateDuration.CalculateTimeDuration(start, end);
+
+ string timeSpentCoding = CalculateDuration.TimeFormatter(duration);
+
+ Console.WriteLine($"You coded for a total of {timeSpentCoding}. Great work!");
+ var connection = new SqliteConnection(connectionStr);
+ connection.Open();
+ DatabaseManager.AddRecordToDatabase(start, end, timeSpentCoding, connection);
+ connection.Close();
+ }
+ else
+ {
+ Console.WriteLine("Invalid input. Please enter 1 if you wish to finish.");
+ userInput = Console.ReadLine()!;
+ }
+ }
+ Console.WriteLine("Do you wish to return to the main menu? Press Y. If you wish to exit press any other key.");
+ userInput = Console.ReadLine()!;
+
+ if (userInput.Trim().ToLower() == "y")
+ {
+ Program.MainMenu();
+ }
+ else
+ {
+ Environment.Exit(0);
+ }
+ }
+ else if (response.Trim().ToLower() == "q")
+ {
+ Program.MainMenu();
+
+ }
+ else
+ {
+ Console.WriteLine("Invalid Input, please try again.");
+ StartCodingSession();
+ }
+ }
+}
+
diff --git a/CodingTracker.dsills735/CodingTracker/Coding Sessions/ManualCodingSession.cs b/CodingTracker.dsills735/CodingTracker/Coding Sessions/ManualCodingSession.cs
new file mode 100644
index 0000000..2595fd9
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Coding Sessions/ManualCodingSession.cs
@@ -0,0 +1,48 @@
+using Microsoft.Extensions.Configuration;
+using Microsoft.Data.Sqlite;
+using System.Globalization;
+
+public class ManualCodingSession
+{
+ static string? connectionStr = Program.config.GetConnectionString("DefaultConnection");
+ internal static void ManualSession()
+ {
+ Console.Clear();
+ Console.WriteLine("You are manually inputting a coding session. Please enter the start Date and Time (24 Hour). (MM/DD/YYYY HH:MM)");
+ DateTime start;
+ DateTime end;
+
+ string startTime = Console.ReadLine()!;
+ bool valid = false;
+
+ while (!DateTime.TryParseExact(startTime, "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out start))
+ {
+ Console.WriteLine("Invalid format. Please enter the start Date and Time in the format (MM/DD/YYYY HH:MM)");
+ startTime = Console.ReadLine()!;
+ }
+ Console.WriteLine();
+ Console.WriteLine("Enter the end Date and Time (24 Hour). (MM/DD/YYYY HH:MM)");
+ string endTime = Console.ReadLine()!;
+
+ while (!DateTime.TryParseExact(endTime, "MM/dd/yyyy HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out end))
+ {
+ Console.WriteLine("Invalid format. Please enter the end Date and Time in the format (MM/DD/YYYY HH:MM)");
+ endTime = Console.ReadLine()!;
+ valid = false;
+
+ }
+
+ TimeSpan duration = CalculateDuration.CalculateTimeDuration(start, end);
+
+ String timeSpentCoding = CalculateDuration.TimeFormatter(duration);
+
+ Console.WriteLine($"You coded for a total of {timeSpentCoding}. Great work!");
+
+ using var connection = new SqliteConnection(connectionStr);
+ connection.Open();
+ DatabaseManager.AddRecordToDatabase(start, end, timeSpentCoding, connection);
+ connection.Close();
+
+ Program.MainMenu();
+ }
+}
diff --git a/CodingTracker.dsills735/CodingTracker/CodingTracker.csproj b/CodingTracker.dsills735/CodingTracker/CodingTracker.csproj
new file mode 100644
index 0000000..5898436
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/CodingTracker.csproj
@@ -0,0 +1,32 @@
+
+
+
+ Exe
+ net10.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PreserveNewest
+
+
+
+
diff --git a/CodingTracker.dsills735/CodingTracker/Database Management/DatabaseManager.cs b/CodingTracker.dsills735/CodingTracker/Database Management/DatabaseManager.cs
new file mode 100644
index 0000000..5f53923
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Database Management/DatabaseManager.cs
@@ -0,0 +1,106 @@
+using Dapper;
+using Microsoft.Data.Sqlite;
+using Microsoft.Extensions.Configuration;
+using Spectre.Console;
+
+
+public class DatabaseManager
+{
+
+ static string? connectionStr = Program.config.GetConnectionString("DefaultConnection");
+
+ internal static void AddRecordToDatabase(DateTime start, DateTime end, string duration, SqliteConnection connection)
+ {
+
+ var session = SqlHelper.SessionCreator(start, end, duration);
+
+ string insertCommand = SqlHelper.InsertCommand(session);
+
+ connection.Execute(insertCommand, session);
+
+ }
+ internal static void ViewRecordsPersonal()
+ {
+ Console.Clear();
+ using (var connection = new SqliteConnection(connectionStr))
+ {
+ var sessions = connection.Query(SqlHelper.ViewAllCommand()).ToList();
+
+ var table = new Table()
+ .AddColumn("[red]Session ID[/]")
+ .AddColumn("[green]Start Time[/]")
+ .AddColumn("[maroon]End Time[/]")
+ .AddColumn("[yellow]Duration[/]");
+
+ foreach (var session in sessions)
+ {
+ table.AddRow($"[red]{session.Id}[/]", $"[green]{session.Start_Time}[/]",
+ $"[maroon]{session.End_Time}[/]", $"[yellow]{session.Duration}[/]");
+ }
+
+ AnsiConsole.Write(table);
+ AnsiConsole.MarkupLine("[maroon]Press any key to return to the main menu[/]");
+ Console.ReadKey();
+ Program.MainMenu();
+
+
+ }
+ }
+ internal static void ViewRecordsDelete()
+ {
+ using (var connection = new SqliteConnection(connectionStr))
+ {
+ var sessions = connection.Query(SqlHelper.ViewAllCommand()).ToList();
+
+ var table = new Table()
+ .AddColumn("[red]Session ID[/]")
+ .AddColumn("[green]Start Time[/]")
+ .AddColumn("[maroon]End Time[/]")
+ .AddColumn("[yellow]Duration[/]");
+
+ foreach (var session in sessions)
+ {
+ table.AddRow($"[red]{session.Id}[/]", $"[green]{session.Start_Time}[/]",
+ $"[maroon]{session.End_Time}[/]", $"[yellow]{session.Duration}[/]");
+ }
+
+ AnsiConsole.Write(table);
+ }
+ }
+
+ internal static void DeleteRecords()
+ {
+ ViewRecordsDelete();
+ Console.WriteLine("Enter the ID of the record you wish to delete:");
+ string id = Console.ReadLine()!;
+
+ using (var connection = new SqliteConnection(connectionStr))
+ {
+
+ int rowCount = connection.Execute(SqlHelper.DeleteSingleRecord(), new { Id = id });
+
+ if (rowCount == 0)
+ {
+ Console.WriteLine($"Record with ID: {id} does not exist.");
+ Console.Clear();
+ DeleteRecords();
+ }
+ Console.WriteLine($"Record with ID: {id} has been deleted.");
+
+ Console.WriteLine("Delete another record? Press Y. Any other key to return to main menu.");
+ string response = Console.ReadLine()!.Trim().ToLower();
+
+ if (response == "y")
+ {
+ DeleteRecords();
+ }
+ else
+ {
+ Program.MainMenu();
+ }
+
+
+ Program.MainMenu();
+ }
+ }
+}
diff --git a/CodingTracker.dsills735/CodingTracker/Database Management/SqlHelper.cs b/CodingTracker.dsills735/CodingTracker/Database Management/SqlHelper.cs
new file mode 100644
index 0000000..d163593
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Database Management/SqlHelper.cs
@@ -0,0 +1,43 @@
+using Dapper;
+internal class SqlHelper
+{
+ public static string TableCreate()
+ {
+ return @"CREATE TABLE IF NOT EXISTS Coding_Tracker(
+ Id INTEGER PRIMARY KEY AUTOINCREMENT,
+ Start_Time TEXT,
+ End_Time TEXT,
+ Duration TEXT)";
+ }
+
+ public static CodingSession SessionCreator(DateTime start, DateTime end, string duration)
+ {
+
+ string startTime = start.ToString("yyyy-MM-dd HH:mm:ss");
+ string endTime = end.ToString("yyyy-MM-dd HH:mm:ss");
+
+ return new CodingSession() { Start_Time = startTime, End_Time = endTime, Duration = duration };
+
+ }
+ public static string InsertCommand(CodingSession session)
+ {
+ return @"INSERT INTO Coding_Tracker (Start_Time, End_Time, Duration)
+ VALUES (@Start_Time, @End_Time, @Duration)";
+ }
+
+ public static string ViewAllCommand()
+ {
+ {
+ return "SELECT * FROM Coding_Tracker";
+ }
+ }
+ public static string DeleteSingleRecord()
+ {
+
+
+ return $"DELETE FROM Coding_Tracker WHERE id = @Id";
+ }
+
+}
+
+
\ No newline at end of file
diff --git a/CodingTracker.dsills735/CodingTracker/Program.cs b/CodingTracker.dsills735/CodingTracker/Program.cs
new file mode 100644
index 0000000..c593101
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/Program.cs
@@ -0,0 +1,69 @@
+using Microsoft.Data.Sqlite;
+using Dapper;
+using Spectre.Console;
+using Microsoft.Extensions.Configuration;
+
+
+public class Program
+{
+ internal static IConfiguration config = new ConfigurationBuilder()
+ .AddJsonFile("appsettings.json")
+ .Build();
+
+ static string? connectionString = config.GetConnectionString("DefaultConnection");
+
+ static void Main(string[] args)
+ {
+ var connection = new SqliteConnection(connectionString);
+
+ var tableCreate = SqlHelper.TableCreate();
+
+ connection.Execute(tableCreate);
+
+ MainMenu();
+ }
+
+ internal static void MainMenu()
+ {
+ Console.Clear();
+ AnsiConsole.MarkupLine("[bold purple]Welcome to David's Coding tracker![/] \n[yellow]Select the option that you need by typing the corresponding number.[/]");
+ AnsiConsole.MarkupLine("[bold red]0. Quit[/]");
+ AnsiConsole.MarkupLine("[green]1. Start a live coding session[/]");
+ AnsiConsole.MarkupLine("[green]2. Input a historical coding session[/]");
+ AnsiConsole.MarkupLine("[yellow]3. View History[/]");
+ AnsiConsole.MarkupLine("[maroon]4. Delete a record[/]");
+
+
+ string response = Console.ReadLine()!;
+
+ switch (response)
+ {
+
+ case "0":
+ Environment.Exit(0);
+ break;
+
+ case "1":
+ LiveSession.StartCodingSession();
+ break;
+
+ case "2":
+ ManualCodingSession.ManualSession();
+ break;
+
+ case "3":
+ DatabaseManager.ViewRecordsPersonal();
+ break;
+
+ case "4":
+ DatabaseManager.DeleteRecords();
+ break;
+
+
+ default:
+ Console.WriteLine("Invalid input. Please take a close look at the options, and try again.");
+ break;
+ }
+
+ }
+}
diff --git a/CodingTracker.dsills735/CodingTracker/appsettings.json b/CodingTracker.dsills735/CodingTracker/appsettings.json
new file mode 100644
index 0000000..01c7db7
--- /dev/null
+++ b/CodingTracker.dsills735/CodingTracker/appsettings.json
@@ -0,0 +1,5 @@
+{
+ "ConnectionStrings": {
+ "DefaultConnection": "Data source = codingTracker.db"
+ }
+}
\ No newline at end of file
diff --git a/CodingTracker.dsills735/CodingTracker/codingTracker.db b/CodingTracker.dsills735/CodingTracker/codingTracker.db
new file mode 100644
index 0000000..fe3ddfa
Binary files /dev/null and b/CodingTracker.dsills735/CodingTracker/codingTracker.db differ
diff --git a/CodingTracker.dsills735/README.md b/CodingTracker.dsills735/README.md
new file mode 100644
index 0000000..a68e828
--- /dev/null
+++ b/CodingTracker.dsills735/README.md
@@ -0,0 +1,46 @@
+# Flashcards
+This app is a Console app that will allow myself to track my coding hours if I choose to do so. And view my history of my coding practices.
+
+**Tech used:** C#, Sqlite, VS 2026, Spectre, Dapper
+
+I used C# along with Dapper and Spectre to design the application. I was a bit nervous to introduce both dapper and spectre at the same time, as on the surface level it seemed very daunting. Once I looked into them I realized how simple it all seemed, and had fun learning them! Using dapper over ADO.NET was a gamechanger! So simple!
+
+## Optimizations
+
+I did alot of refactoring throughout this project. I originally built it to functionality using skills I already had, in an effort to reinforce the basics. Once there, I dove into the new requirements and skills which really streamined things (specifically looking at Dapper ORM). Using dapper significantly reduced the lines of code and boilerplate code. It was very eye opening to the power of libraries and packages.
+
+
+## Lessons Learned
+
+This project was the first one I have done with C# and outside of school that required packages from the outside to do alot of the heavy lifting for me. I enjoyed using SQLLite as it has been well over a year since I have done anything SQL. I was excited to see how fast I picked it back up!
+
+The most important lesson I learned was SQL injection risks. I originally had it where the SQL command for DeleteSingleRecord used interpolation to put the ID directly into the command. Feedback informed me of the SQL Injection risk, which really opened my eyes. I have learned about it several times, but this was the first time it truly registered howq SQL injection actually happens.
+
+Another lesson I learned was UI design. Although this is very simple, as I was testing and using the app during development, I had alot of thoughts about a typical user experience with this app. It really made me think about how to simplify and streamline processes, even with something as simple as this.
+
+## Project Requirements
+
+ - This is a project I did as a part of my learning process. The requirements and challenges are listed below. There was more unit tests previously, but those methods have been refactored and removed.
+
+ - To show the data on the console, you should use the "Spectre.Console" library.
+
+ - You're required to have separate classes in different files (ex. 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 that you'll contain your database path and connection strings.
+
+ - 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
+
+ - The user shouldn't input the duration of the session. It should be calculated based on the Start and End times, in a separate "CalculateDuration" method.
+
+ - 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.
+
+ - When reading from the database, you can't use an anonymous object, you have to read your table into a List of Coding Sessions.
+
+**May 2026 Changes**
+- I will be adding a fulll testing suite of integration and unit tests for this project.
+
+