diff --git a/Console.ExerciseTracker.ananttuli/.gitignore b/Console.ExerciseTracker.ananttuli/.gitignore
deleted file mode 100644
index 2c2ce2e5..00000000
--- a/Console.ExerciseTracker.ananttuli/.gitignore
+++ /dev/null
@@ -1,2 +0,0 @@
-.vscode
-*.db
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/App.config b/Console.ExerciseTracker.ananttuli/App/App.config
deleted file mode 100644
index 0f691c4f..00000000
--- a/Console.ExerciseTracker.ananttuli/App/App.config
+++ /dev/null
@@ -1,6 +0,0 @@
-
-
-
-
-
-
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/App.csproj b/Console.ExerciseTracker.ananttuli/App/App.csproj
deleted file mode 100644
index 8941bd38..00000000
--- a/Console.ExerciseTracker.ananttuli/App/App.csproj
+++ /dev/null
@@ -1,23 +0,0 @@
-
-
-
- Exe
- net8.0
- enable
- enable
-
-
-
-
-
-
- runtime; build; native; contentfiles; analyzers; buildtransitive
- all
-
-
-
-
-
-
-
-
diff --git a/Console.ExerciseTracker.ananttuli/App/Controllers/AppController.cs b/Console.ExerciseTracker.ananttuli/App/Controllers/AppController.cs
deleted file mode 100644
index 6e657bb3..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Controllers/AppController.cs
+++ /dev/null
@@ -1,81 +0,0 @@
-using App.Util;
-using Spectre.Console;
-
-namespace App.Controllers;
-
-public class AppController
-{
- private readonly ExerciseController LogsController;
-
- public AppController(ExerciseController logsController)
- {
- LogsController = logsController;
- }
-
- public async Task Run()
- {
- var keepRunning = true;
- while (keepRunning) keepRunning = await ShowMenu();
- }
-
- public async Task ShowMenu()
- {
- string[] menuItems =
- [
- "Create log", "View logs",
- "Update log", "Delete log", "[red]Exit[/]"
- ];
- var option = PrintMainMenu(menuItems);
-
- try
- {
- switch (option)
- {
- case '1':
- await LogsController.CreateLog();
- break;
- case '2':
- await LogsController.ListAllLogs();
- break;
- case '3':
- await LogsController.UpdateLog();
- break;
- case '4':
- await LogsController.DeleteLog();
- break;
- case '5':
- return false;
- default:
- AnsiConsole.MarkupLine("[red]Please press one of the menu options above[/]");
- break;
- }
- }
- catch (Exception ex)
- {
- if (ex is UserFacingException)
- AnsiConsole.MarkupLine($"[red]{ex.Message}[/]");
- else
- AnsiConsole.MarkupLine("[red]Error[/]");
- }
-
- UiUtil.PressKeyToContinue();
-
- return true;
- }
-
- private static char PrintMainMenu(string[] menuItems)
- {
- Console.Clear();
- AnsiConsole.MarkupLine("\n\nE X E R C I S E T R A C K E R\n");
- AnsiConsole.Write(new Rows(
- menuItems.Select((menuItem, i) => new Markup($"{i + 1,-3} {menuItem,-3}"))
- ));
-
- AnsiConsole.Write("\n\nEnter option? ");
-
- var option = Console.ReadKey().KeyChar;
-
- AnsiConsole.WriteLine("\n");
- return option;
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Controllers/ExerciseController.cs b/Console.ExerciseTracker.ananttuli/App/Controllers/ExerciseController.cs
deleted file mode 100644
index a6cfe702..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Controllers/ExerciseController.cs
+++ /dev/null
@@ -1,187 +0,0 @@
-using System.Globalization;
-using App.ExerciseLogs;
-using App.ExerciseLogs.Models;
-using App.Util;
-using Spectre.Console;
-
-namespace App.Controllers;
-
-public class ExerciseController
-{
- private readonly ExerciseService ExerciseLogsService;
-
- public ExerciseController(ExerciseService exerciseLogsService)
- {
- ExerciseLogsService = exerciseLogsService;
- }
-
- public async Task CreateLog()
- {
- await ListAllLogs();
- AnsiConsole.MarkupLine($"Create exercise log");
- var (startDateTime, endDateTime) = PromptDateTimes();
- var comments = PromptForComments();
-
- var created = await ExerciseLogsService.CreateExerciseLog(new ExerciseLogCreateDto(
- startDateTime,
- endDateTime,
- comments
- ));
-
- if (created == null)
- AnsiConsole.MarkupLine("[red]ERROR: Could not create exercise log[/]");
- else
- AnsiConsole.MarkupLine("[green]Created successfuly[/]");
- }
-
- public async Task ListAllLogs()
- {
- PrintLogs(await ExerciseLogsService.ListAllLogs());
- }
-
- public async Task UpdateLog()
- {
- await ListAllLogs();
- AnsiConsole.MarkupLine($"Edit exercise log");
- var exerciseLog = await PromptForExistingLog();
- var (startDateTime, endDateTime) = PromptDateTimes(exerciseLog.StartDateTime, exerciseLog.EndDateTime);
- var comments = PromptForComments(exerciseLog.Comments);
-
- exerciseLog.StartDateTime = startDateTime;
- exerciseLog.EndDateTime = endDateTime;
- exerciseLog.Comments = comments;
-
- var updated = await ExerciseLogsService.UpdateExerciseLog(exerciseLog.Id, exerciseLog);
-
- if (updated == null)
- AnsiConsole.MarkupLine("[red]ERROR: Could not update exercise log[/]");
- else
- AnsiConsole.MarkupLine("[green]Update successful[/]");
- }
-
- public async Task DeleteLog()
- {
- await ListAllLogs();
- AnsiConsole.MarkupLine($"Delete exercise log");
-
- var exerciseLog = await PromptForExistingLog();
- var deleteSuccessful = await ExerciseLogsService.DeleteExerciseLog(exerciseLog.Id);
-
- if (deleteSuccessful == true)
- AnsiConsole.MarkupLine("[green]Delete successful[/]");
- else
- AnsiConsole.MarkupLine("[red]ERROR: Could not update exercise log[/]");
- }
-
- private async Task PromptForExistingLog()
- {
- while (true)
- {
- var exerciseLogId = AnsiConsole.Ask("Enter exercise log ID: ");
- var log = await ExerciseLogsService.GetExerciseLog(exerciseLogId);
- if (log != null)
- {
- return log;
- }
- AnsiConsole.MarkupLine(
- "[red]Could not find a log with that ID." +
- " Please enter a valid ID from the list above[/]"
- );
- }
- }
-
- private string PromptForComments(string? existingComment = null)
- {
- return AnsiConsole.Ask("Comment: ", existingComment ?? "");
- }
-
- private static void PrintLogs(List logs)
- {
- if (logs.Count == 0)
- {
- AnsiConsole.WriteLine("No logs found");
- return;
- }
-
- var table = new Table();
-
- table.AddColumns(["Id", "Start time", "End time", "Duration", "Comments"]);
-
- foreach (var log in logs)
- {
- table.AddRow([
- log.Id.ToString(), log.StartDateTime.ToString(), log.EndDateTime.ToString(),
- UiUtil.FormatDuration(log.Duration), log.Comments
- ]);
- }
-
- AnsiConsole.Write(table);
- }
-
- private Tuple PromptDateTimes(DateTime? existingStartDateTime = null, DateTime? existingEndDateTime = null)
- {
- const string expectedDateTimeFormat = "yyyy-MM-dd HH:mm";
-
- AnsiConsole.MarkupLine("[grey]Note: Date times must be YYYY-mm-dd hh:mm with 24hr time e.g. [/][blue]2024-12-31 14:15[/]");
-
- string validStartDateTimeString = AnsiConsole.Prompt(
- new TextPrompt("[green]Start[/] date time: ")
- .PromptStyle("blue")
- .DefaultValue(existingStartDateTime?.ToString(expectedDateTimeFormat) ?? "")
- .ValidationErrorMessage("[red]That's not a valid date time[/]")
- .Validate(startDateTimeInput =>
- {
- bool validDate = DateTime.TryParseExact(
- startDateTimeInput,
- expectedDateTimeFormat,
- CultureInfo.CurrentCulture,
- DateTimeStyles.None,
- out DateTime value
- );
-
- return validDate switch
- {
- false => ValidationResult.Error("\t[red]Please enter valid date format[/]"),
- true => ValidationResult.Success()
- };
- }
- )
- );
-
- DateTime startDateTime = DateTime.Parse(validStartDateTimeString);
-
- string validEndDateTimeString = AnsiConsole.Prompt(
- new TextPrompt("[green]End[/] date time: ")
- .PromptStyle("blue")
- .DefaultValue(existingEndDateTime?.ToString(expectedDateTimeFormat) ?? "")
- .ValidationErrorMessage("[red]That's not a valid date time[/]")
- .Validate(endDateTimeInput =>
- {
- bool validDate = DateTime.TryParseExact(
- endDateTimeInput,
- expectedDateTimeFormat,
- CultureInfo.CurrentCulture,
- DateTimeStyles.None,
- out DateTime value
- );
-
- if (validDate == false)
- {
- return ValidationResult.Error("\t[red]Please enter valid date format[/]");
- }
-
- if (value < startDateTime)
- {
- return ValidationResult.Error("\t[red]End date time must be later than start date time[/]");
- }
-
- return ValidationResult.Success();
- }
- )
- );
-
- DateTime endDateTime = DateTime.Parse(validEndDateTimeString);
-
- return new Tuple(startDateTime, endDateTime);
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/ExercisesDbContext.cs b/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/ExercisesDbContext.cs
deleted file mode 100644
index adc84d58..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/ExercisesDbContext.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using App.ExerciseLogs.Models;
-using Microsoft.EntityFrameworkCore;
-
-namespace App.Database.EntityFramework;
-
-public class ExercisesDbContext : DbContext
-{
- public DbSet Exercise { get; set; }
-
- protected override void OnConfiguring(DbContextOptionsBuilder builder)
- {
- var dbPath = System.Configuration.ConfigurationManager.AppSettings["DbPath"] ??
- throw new System.Configuration.ConfigurationErrorsException("DbPath configuration must be defined in App.config");
-
- builder.UseSqlite($"Data Source={dbPath}");
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/RepositoryBase.cs b/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/RepositoryBase.cs
deleted file mode 100644
index 42d3f35f..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Database/EntityFramework/RepositoryBase.cs
+++ /dev/null
@@ -1,78 +0,0 @@
-
-using Microsoft.EntityFrameworkCore;
-
-namespace App.Database.EntityFramework;
-
-public class RepositoryBase : IRepositoryBase where T : class, new()
-{
- protected readonly ExercisesDbContext Db;
-
- public RepositoryBase(ExercisesDbContext db)
- {
- Db = db;
- }
-
- public async Task DeleteOne(int id)
- {
- T existingEntity = await GetById(id);
-
- Db.Remove(existingEntity);
- await Db.SaveChangesAsync();
-
- var entityAfterDeletion = await FindById(id);
-
- return entityAfterDeletion == null;
- }
-
- public async Task FindById(int id)
- {
- var result = await Db.FindAsync(typeof(T), id);
-
- return (T?)result;
- }
-
- public async Task GetById(int id)
- {
- var result = await Db.FindAsync(typeof(T), id);
-
- if (result == null)
- {
- throw new Exception($"Could not find {nameof(T)} by ID {id}");
- }
-
- return (T)result;
- }
-
- public async Task> ListAll()
- {
- return await Db.Set().ToListAsync();
- }
-
- public async Task CreateOne(T entity)
- {
- if (entity == null)
- {
- throw new ArgumentNullException($"{nameof(T)} cannot be null");
- }
-
- await Db.AddAsync(entity);
-
- await Db.SaveChangesAsync();
-
- return entity;
- }
-
- public async Task UpdateOne(T entity)
- {
- if (entity == null)
- {
- throw new ArgumentNullException($"{nameof(T)} cannot be null");
- }
-
- Db.Update(entity);
-
- await Db.SaveChangesAsync();
-
- return entity;
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Database/IRepositoryBase.cs b/Console.ExerciseTracker.ananttuli/App/Database/IRepositoryBase.cs
deleted file mode 100644
index 23d4e199..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Database/IRepositoryBase.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace App.Database;
-
-public interface IRepositoryBase
-{
- public Task> ListAll();
- public Task GetById(int id);
- public Task CreateOne(T entity);
- public Task UpdateOne(T entity);
- public Task DeleteOne(int id);
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/ExerciseService.cs b/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/ExerciseService.cs
deleted file mode 100644
index 4284caf7..00000000
--- a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/ExerciseService.cs
+++ /dev/null
@@ -1,63 +0,0 @@
-using App.Database;
-using App.ExerciseLogs.Models;
-using App.Util;
-
-namespace App.ExerciseLogs;
-
-public class ExerciseService
-{
- private readonly IRepositoryBase ExerciseLogsRepo;
-
- public ExerciseService(IRepositoryBase exerciseLogsRepo)
- {
- ExerciseLogsRepo = exerciseLogsRepo;
- }
-
- public async Task CreateExerciseLog(ExerciseLogCreateDto payload)
- {
- AssertLogTimesValid(payload.StartDateTime, payload.EndDateTime);
-
- return await ExerciseLogsRepo.CreateOne(new ExerciseLog
- {
- StartDateTime = payload.StartDateTime,
- EndDateTime = payload.EndDateTime,
- Comments = payload.Comments
- });
- }
-
- public async Task GetExerciseLog(int id) => await ExerciseLogsRepo.GetById(id);
-
- public async Task> ListAllLogs() => await ExerciseLogsRepo.ListAll();
-
- public async Task UpdateExerciseLog(int id, ExerciseLog payload)
- {
- if (id != payload.Id)
- {
- throw new Exception("Update ID must match entity ID");
- }
-
- AssertLogTimesValid(payload.StartDateTime, payload.EndDateTime);
-
- var updatedLog = await ExerciseLogsRepo.UpdateOne(payload);
-
- return updatedLog;
- }
-
- public async Task DeleteExerciseLog(int id)
- {
- return await ExerciseLogsRepo.DeleteOne(id);
- }
-
- private void AssertLogTimesValid(DateTime? startDateTime, DateTime? endDateTime)
- {
- if (startDateTime == null || endDateTime == null)
- {
- throw new UserFacingException("Dates must be supplied");
- }
-
- if (startDateTime > endDateTime)
- {
- throw new UserFacingException("Start date cannot be later than end date");
- }
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLog.cs b/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLog.cs
deleted file mode 100644
index 9eacb4a0..00000000
--- a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLog.cs
+++ /dev/null
@@ -1,17 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-
-namespace App.ExerciseLogs.Models;
-
-[PrimaryKey("Id")]
-public class ExerciseLog
-{
- public int Id { get; set; }
- public DateTime StartDateTime { get; set; }
- public DateTime EndDateTime { get; set; }
- public string Comments { get; set; } = "";
-
- public TimeSpan Duration
- {
- get => EndDateTime.Subtract(StartDateTime);
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogCreateDto.cs b/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogCreateDto.cs
deleted file mode 100644
index a3b935d7..00000000
--- a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogCreateDto.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace App.ExerciseLogs.Models;
-
-public record class ExerciseLogCreateDto(
- DateTime StartDateTime,
- DateTime EndDateTime,
- string Comments
-);
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogUpdateDto.cs b/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogUpdateDto.cs
deleted file mode 100644
index 0c79fb85..00000000
--- a/Console.ExerciseTracker.ananttuli/App/ExerciseLogs/Models/ExerciseLogUpdateDto.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace App.ExerciseLogs.Models;
-
-public record class ExerciseLogUpdateDto(
- int Id,
- DateTime StartDateTime,
- DateTime EndDateTime,
- string Comments
-);
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.Designer.cs b/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.Designer.cs
deleted file mode 100644
index c2c91571..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.Designer.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-//
-using System;
-using App.Database.EntityFramework;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace App.Migrations
-{
- [DbContext(typeof(ExercisesDbContext))]
- [Migration("20240629070307_Initial")]
- partial class Initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
-
- modelBuilder.Entity("App.ExerciseLogs.Models.ExerciseLog", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("EndDateTime")
- .HasColumnType("TEXT");
-
- b.Property("StartDateTime")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Exercise");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.cs b/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.cs
deleted file mode 100644
index 34da2646..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Migrations/20240629070307_Initial.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace App.Migrations
-{
- ///
- public partial class Initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Exercise",
- columns: table => new
- {
- Id = table.Column(type: "INTEGER", nullable: false)
- .Annotation("Sqlite:Autoincrement", true),
- StartDateTime = table.Column(type: "TEXT", nullable: false),
- EndDateTime = table.Column(type: "TEXT", nullable: false),
- Comments = table.Column(type: "TEXT", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Exercise", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Exercise");
- }
- }
-}
diff --git a/Console.ExerciseTracker.ananttuli/App/Migrations/ExercisesDbContextModelSnapshot.cs b/Console.ExerciseTracker.ananttuli/App/Migrations/ExercisesDbContextModelSnapshot.cs
deleted file mode 100644
index c9c3f3f6..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Migrations/ExercisesDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,43 +0,0 @@
-//
-using System;
-using App.Database.EntityFramework;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace App.Migrations
-{
- [DbContext(typeof(ExercisesDbContext))]
- partial class ExercisesDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder.HasAnnotation("ProductVersion", "8.0.6");
-
- modelBuilder.Entity("App.ExerciseLogs.Models.ExerciseLog", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("INTEGER");
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("TEXT");
-
- b.Property("EndDateTime")
- .HasColumnType("TEXT");
-
- b.Property("StartDateTime")
- .HasColumnType("TEXT");
-
- b.HasKey("Id");
-
- b.ToTable("Exercise");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/Console.ExerciseTracker.ananttuli/App/Program.cs b/Console.ExerciseTracker.ananttuli/App/Program.cs
deleted file mode 100644
index 6c7ae929..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Program.cs
+++ /dev/null
@@ -1,41 +0,0 @@
-using App.Controllers;
-using App.Database;
-using App.Database.EntityFramework;
-using App.ExerciseLogs;
-using App.ExerciseLogs.Models;
-using Microsoft.Extensions.DependencyInjection;
-using Spectre.Console;
-
-namespace App;
-
-public class Program
-{
- public static void Main()
- {
- var serviceProvider = BuildServiceProvider();
-
- var userInterface = serviceProvider?.GetService();
-
- if (userInterface is null)
- {
- AnsiConsole.WriteLine("App failed to start");
- Environment.Exit(1);
- }
-
- userInterface.Run().GetAwaiter().GetResult();
- }
-
- public static ServiceProvider BuildServiceProvider()
- {
- var serviceCollection = new ServiceCollection();
-
- serviceCollection.AddDbContext();
- serviceCollection.AddTransient(typeof(IRepositoryBase<>), typeof(RepositoryBase<>));
- serviceCollection.AddTransient, RepositoryBase>();
- serviceCollection.AddTransient(typeof(ExerciseService));
- serviceCollection.AddTransient(typeof(AppController));
- serviceCollection.AddTransient(typeof(ExerciseController));
-
- return serviceCollection.BuildServiceProvider();
- }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/App/Util/UiUtil.cs b/Console.ExerciseTracker.ananttuli/App/Util/UiUtil.cs
deleted file mode 100644
index 0dec6129..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Util/UiUtil.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-namespace App.Util;
-
-public static class UiUtil
-{
- public static char PressKeyToContinue(string message = "Press any key to continue")
- {
- Console.WriteLine(message);
- var keyChar = Console.ReadKey().KeyChar;
- Console.Clear();
-
- return keyChar;
- }
-
- public static string FormatDuration(TimeSpan duration)
- {
- return string.Format(
- $"{(int)duration.TotalHours,-3} h, {duration.Minutes,-3} m"
- );
- }
-}
diff --git a/Console.ExerciseTracker.ananttuli/App/Util/UserFacingException.cs b/Console.ExerciseTracker.ananttuli/App/Util/UserFacingException.cs
deleted file mode 100644
index d4533d84..00000000
--- a/Console.ExerciseTracker.ananttuli/App/Util/UserFacingException.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace App.Util;
-
-public class UserFacingException : Exception
-{
- public UserFacingException(string message) : base(message)
- { }
-}
\ No newline at end of file
diff --git a/Console.ExerciseTracker.ananttuli/Console.ExerciseTracker.ananttuli.sln b/Console.ExerciseTracker.ananttuli/Console.ExerciseTracker.ananttuli.sln
deleted file mode 100644
index 30f0ad18..00000000
--- a/Console.ExerciseTracker.ananttuli/Console.ExerciseTracker.ananttuli.sln
+++ /dev/null
@@ -1,22 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31903.59
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "App", "App\App.csproj", "{18335949-AEDF-4F4A-BB77-21376F1DD64E}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {18335949-AEDF-4F4A-BB77-21376F1DD64E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {18335949-AEDF-4F4A-BB77-21376F1DD64E}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {18335949-AEDF-4F4A-BB77-21376F1DD64E}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {18335949-AEDF-4F4A-BB77-21376F1DD64E}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/Console.ExerciseTracker.ananttuli/README.rst b/Console.ExerciseTracker.ananttuli/README.rst
deleted file mode 100644
index 1c06f803..00000000
--- a/Console.ExerciseTracker.ananttuli/README.rst
+++ /dev/null
@@ -1,28 +0,0 @@
-Exercise Tracker
-================
-
-Log exercise sessions and track progress.
-
-Run locally
------------
-
-1. Clone this repository
-2. ``cd /App``
-3. ``dotnet ef database update``
-4. ``dotnet run``
-
-Configuration (optional)
-------------------------
-
-Default configuration should work as-is, but can be customised if
-desired:
-
-- Change SQLite database path in ``App/App.config`` (default should
- work)
-
-Tech stack
-----------
-
-- C#
-- EntityFramework Core ORM
-- SQLite
\ No newline at end of file
diff --git a/ExerciceTracker.Cactus/App.json b/ExerciceTracker.Cactus/App.json
deleted file mode 100644
index 7052467a..00000000
--- a/ExerciceTracker.Cactus/App.json
+++ /dev/null
@@ -1,5 +0,0 @@
-{
- "ConnectionStrings": {
- "LocalDbConnection": "Data Source=(localdb)\\MSSQLLocalDB;Initial Catalog=ExerciseDB;Integrated Security=True;"
- }
-}
\ No newline at end of file
diff --git a/ExerciceTracker.Cactus/Controller/ExerciseController.cs b/ExerciceTracker.Cactus/Controller/ExerciseController.cs
deleted file mode 100644
index d9740c10..00000000
--- a/ExerciceTracker.Cactus/Controller/ExerciseController.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using ExerciseTracker.Cactus.Service;
-using ExerciseTracker.Cactus.UI;
-using Spectre.Console;
-
-enum MenuOptions
-{
- AddExercise,
- DeleteExercise,
- ViewAllExercises,
- UpdateExercise,
- Quit
-}
-
-namespace ExerciseTracker.Cactus.Controller
-{
- public class ExerciseController
- {
- private readonly ExerciseService _exerciseService;
-
- public ExerciseController(ExerciseService exerciseService)
- {
- _exerciseService = exerciseService;
- }
-
- public async Task MainMenu()
- {
- bool isAppRunning = true;
- while (isAppRunning)
- {
- var option = AnsiConsole.Prompt(
- new SelectionPrompt()
- .Title("What would you like to do?")
- .AddChoices(
- MenuOptions.AddExercise,
- MenuOptions.ViewAllExercises,
- MenuOptions.UpdateExercise,
- MenuOptions.DeleteExercise,
- MenuOptions.Quit));
-
- switch (option)
- {
- case MenuOptions.AddExercise:
- var exercise = await _exerciseService.AddExerciseAsync();
- UserInterface.ShowExercise(exercise);
- UserInterface.BackToMainMenuPrompt();
- break;
- case MenuOptions.DeleteExercise:
- var deletedExercise = await _exerciseService.DeleteExerciseAsync();
- UserInterface.ShowExercise(deletedExercise);
- UserInterface.BackToMainMenuPrompt();
- break;
- case MenuOptions.ViewAllExercises:
- var exercises = await _exerciseService.GetAllExercisesAsync();
- UserInterface.ShowExercise(exercises);
- UserInterface.BackToMainMenuPrompt();
- break;
- case MenuOptions.UpdateExercise:
- var updatedExercise = await _exerciseService.UpdateExerciseAsync();
- UserInterface.ShowExercise(updatedExercise);
- UserInterface.BackToMainMenuPrompt();
- break;
- case MenuOptions.Quit:
- isAppRunning = false;
- break;
- }
- }
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Data/ExerciseDbContext.cs b/ExerciceTracker.Cactus/Data/ExerciseDbContext.cs
deleted file mode 100644
index fe56591a..00000000
--- a/ExerciceTracker.Cactus/Data/ExerciseDbContext.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using ExerciseTracker.Cactus.Model;
-using Microsoft.EntityFrameworkCore;
-
-namespace ExerciseTracker.Cactus.Data
-{
- public class ExerciseDbContext : DbContext
- {
- public DbSet ExerciseSet { get; set; }
-
- public ExerciseDbContext(DbContextOptions options)
- : base(options)
- {
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Data/Interfaces/IExerciseRepository .cs b/ExerciceTracker.Cactus/Data/Interfaces/IExerciseRepository .cs
deleted file mode 100644
index cc0f319c..00000000
--- a/ExerciceTracker.Cactus/Data/Interfaces/IExerciseRepository .cs
+++ /dev/null
@@ -1,8 +0,0 @@
-using ExerciseTracker.Cactus.Model;
-
-namespace ExerciseTracker.Cactus.Data.Interfaces
-{
- public interface IExerciseRepository : IRepository
- {
- }
-}
diff --git a/ExerciceTracker.Cactus/Data/Interfaces/IRepository.cs b/ExerciceTracker.Cactus/Data/Interfaces/IRepository.cs
deleted file mode 100644
index e08cd849..00000000
--- a/ExerciceTracker.Cactus/Data/Interfaces/IRepository.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace ExerciseTracker.Cactus.Data.Interfaces
-{
- public interface IRepository where T : class
- {
- Task> GetAllAsync();
- Task GetByIdAsync(int id);
- Task AddAsync(T entity);
- Task UpdateAsync(T entity);
- Task DeleteAsync(int id);
- }
-}
diff --git a/ExerciceTracker.Cactus/Data/Repositories/ExerciseRepository .cs b/ExerciceTracker.Cactus/Data/Repositories/ExerciseRepository .cs
deleted file mode 100644
index 47752290..00000000
--- a/ExerciceTracker.Cactus/Data/Repositories/ExerciseRepository .cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using ExerciseTracker.Cactus.Data.Interfaces;
-using ExerciseTracker.Cactus.Model;
-
-namespace ExerciseTracker.Cactus.Data.Repositories
-{
- public class ExerciseRepository : Repository, IExerciseRepository
- {
- public ExerciseRepository(ExerciseDbContext context) : base(context)
- {
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Data/Repositories/Repository.cs b/ExerciceTracker.Cactus/Data/Repositories/Repository.cs
deleted file mode 100644
index 72761cfd..00000000
--- a/ExerciceTracker.Cactus/Data/Repositories/Repository.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using ExerciseTracker.Cactus.Data.Interfaces;
-using Microsoft.EntityFrameworkCore;
-
-namespace ExerciseTracker.Cactus.Data.Repositories
-{
- public class Repository : IRepository where T : class
- {
- protected readonly DbContext _context;
-
- public Repository(DbContext context)
- {
- _context = context;
- }
-
- public async Task> GetAllAsync()
- {
- return await _context.Set().ToListAsync();
- }
-
- public async Task GetByIdAsync(int id)
- {
- return await _context.Set().FindAsync(id);
- }
-
- public async Task AddAsync(T entity)
- {
- await _context.Set().AddAsync(entity);
- await _context.SaveChangesAsync();
- }
-
- public async Task UpdateAsync(T entity)
- {
- _context.Set().Update(entity);
- await _context.SaveChangesAsync();
- }
-
- public async Task DeleteAsync(int id)
- {
- var entity = await GetByIdAsync(id);
- if (entity != null)
- {
- _context.Set().Remove(entity);
- await _context.SaveChangesAsync();
- }
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/ExerciceTracker.Cactus.sln b/ExerciceTracker.Cactus/ExerciceTracker.Cactus.sln
deleted file mode 100644
index 737163b9..00000000
--- a/ExerciceTracker.Cactus/ExerciceTracker.Cactus.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.6.33815.320
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "ExerciseTracker.Cactus", "ExerciseTracker.Cactus.csproj", "{90B3F9B2-4261-412C-82C2-5F1E2A85B900}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {90B3F9B2-4261-412C-82C2-5F1E2A85B900}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {90B3F9B2-4261-412C-82C2-5F1E2A85B900}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {90B3F9B2-4261-412C-82C2-5F1E2A85B900}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {90B3F9B2-4261-412C-82C2-5F1E2A85B900}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {A7F18757-E79F-4D61-87D4-35125C291531}
- EndGlobalSection
-EndGlobal
diff --git a/ExerciceTracker.Cactus/ExerciseTracker.Cactus.csproj b/ExerciceTracker.Cactus/ExerciseTracker.Cactus.csproj
deleted file mode 100644
index dbecaa48..00000000
--- a/ExerciceTracker.Cactus/ExerciseTracker.Cactus.csproj
+++ /dev/null
@@ -1,32 +0,0 @@
-
-
-
- Exe
- net7.0
- enable
- enable
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
- PreserveNewest
-
-
-
-
-
-
-
diff --git a/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.Designer.cs b/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.Designer.cs
deleted file mode 100644
index 900b7482..00000000
--- a/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-using System;
-using ExerciseTracker.Cactus.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciseTracker.Cactus.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- [Migration("20240519080422_InitialCreate")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "7.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciseTracker.Cactus.Model.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("ExerciseSet");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.cs b/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.cs
deleted file mode 100644
index b32385f8..00000000
--- a/ExerciceTracker.Cactus/Migrations/20240519080422_InitialCreate.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace ExerciseTracker.Cactus.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ExerciseSet",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- DateStart = table.Column(type: "datetime2", nullable: false),
- DateEnd = table.Column(type: "datetime2", nullable: false),
- Duration = table.Column(type: "int", nullable: false),
- Comments = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ExerciseSet", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ExerciseSet");
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Migrations/ExerciseDbContextModelSnapshot.cs b/ExerciceTracker.Cactus/Migrations/ExerciseDbContextModelSnapshot.cs
deleted file mode 100644
index 5bdaf513..00000000
--- a/ExerciceTracker.Cactus/Migrations/ExerciseDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-using System;
-using ExerciseTracker.Cactus.Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciseTracker.Cactus.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- partial class ExerciseDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "7.0.3")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciseTracker.Cactus.Model.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("int");
-
- b.HasKey("Id");
-
- b.ToTable("ExerciseSet");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Model/Exercise.cs b/ExerciceTracker.Cactus/Model/Exercise.cs
deleted file mode 100644
index ee70a9d6..00000000
--- a/ExerciceTracker.Cactus/Model/Exercise.cs
+++ /dev/null
@@ -1,24 +0,0 @@
-using Microsoft.Identity.Client;
-
-namespace ExerciseTracker.Cactus.Model
-{
- public class Exercise
- {
- public int Id { get; set; }
- public DateTime DateStart { get; set; }
- public DateTime DateEnd { get; set; }
- public int Duration { get; set; }
- public string Comments { get; set; }
-
- public Exercise()
- { }
-
- public Exercise(DateTime dateStart, DateTime dateEnd, int duration, string comments)
- {
- DateStart = dateStart;
- DateEnd = dateEnd;
- Duration = duration;
- Comments = comments;
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Program.cs b/ExerciceTracker.Cactus/Program.cs
deleted file mode 100644
index ef2aaf35..00000000
--- a/ExerciceTracker.Cactus/Program.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using ExerciseTracker.Cactus.Controller;
-using ExerciseTracker.Cactus.Data;
-using ExerciseTracker.Cactus.Data.Interfaces;
-using ExerciseTracker.Cactus.Data.Repositories;
-using ExerciseTracker.Cactus.Service;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.Configuration;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
-public class Program
-{
- public static async Task Main(string[] args)
- {
- var host = new HostBuilder()
- .ConfigureServices((hostContext, services) =>
- {
- var configuration = new ConfigurationBuilder()
- .SetBasePath(AppContext.BaseDirectory)
- .AddJsonFile("App.json", optional: false, reloadOnChange: true)
- .Build();
-
- services.AddDbContext(options =>
- options.UseSqlServer(configuration.GetConnectionString("LocalDbConnection")));
-
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- })
- .Build();
-
- using (var scope = host.Services.CreateScope())
- {
- var services = scope.ServiceProvider;
- var controller = services.GetRequiredService();
- await controller.MainMenu();
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/README.md b/ExerciceTracker.Cactus/README.md
deleted file mode 100644
index 3f674ed6..00000000
--- a/ExerciceTracker.Cactus/README.md
+++ /dev/null
@@ -1,15 +0,0 @@
-# Exercise Tracker Console Application
-
-The Console application record the exercise data. It utilizes the `Repository Pattern` in its implementation.
-
-## ScreenShots
-
-Here is some screenshots in this application's run time.
-
-
-
-## Reference
-
-* [Tutorial: Use dependency injection in .NET](https://learn.microsoft.com/en-us/dotnet/core/extensions/dependency-injection-usage)
-
-* ChatGPT
diff --git a/ExerciceTracker.Cactus/Service/ExerciseService.cs b/ExerciceTracker.Cactus/Service/ExerciseService.cs
deleted file mode 100644
index d57c6d56..00000000
--- a/ExerciceTracker.Cactus/Service/ExerciseService.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-using ExerciseTracker.Cactus.Data.Interfaces;
-using ExerciseTracker.Cactus.Model;
-using Spectre.Console;
-
-namespace ExerciseTracker.Cactus.Service
-{
- public class ExerciseService
- {
- private readonly IExerciseRepository _exerciseRepository;
-
- public ExerciseService(IExerciseRepository exerciseRepository)
- {
- _exerciseRepository = exerciseRepository;
- }
-
- public async Task> GetAllExercisesAsync()
- {
- return await _exerciseRepository.GetAllAsync();
- }
-
- public async Task AddExerciseAsync()
- {
- Exercise exercise = ExerciseServiceHelper.InputExercise();
-
- await _exerciseRepository.AddAsync(exercise);
-
- return exercise;
- }
-
- public async Task UpdateExerciseAsync()
- {
- var exercises = await _exerciseRepository.GetAllAsync();
-
- if (exercises.Count() <= 0) { return null; }
-
- Exercise selectedExercise = ExerciseServiceHelper.SelectExerciseById(exercises);
-
- selectedExercise.DateStart = AnsiConsole.Confirm("Update start date?") ? ExerciseServiceHelper.GetValidDate() : selectedExercise.DateStart;
- selectedExercise.DateEnd = AnsiConsole.Confirm("Update end date?") ? ExerciseServiceHelper.GetValidEndDate(selectedExercise.DateStart) : selectedExercise.DateEnd;
- selectedExercise.Duration = AnsiConsole.Confirm("Update duarion?") ? AnsiConsole.Ask("Please input duration:") : selectedExercise.Duration;
- selectedExercise.Comments = AnsiConsole.Confirm("Update comments?") ? AnsiConsole.Ask("Please input your comments:") : selectedExercise.Comments;
-
- await _exerciseRepository.UpdateAsync(selectedExercise);
-
- return selectedExercise;
- }
-
- public async Task DeleteExerciseAsync()
- {
- var exercises = await _exerciseRepository.GetAllAsync();
-
- if (exercises.Count() <= 0) { return null; }
-
- var selectedExeercise = ExerciseServiceHelper.SelectExerciseById(exercises);
-
- await _exerciseRepository.DeleteAsync(selectedExeercise.Id);
-
- return selectedExeercise;
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Service/ExerciseServiceHelper.cs b/ExerciceTracker.Cactus/Service/ExerciseServiceHelper.cs
deleted file mode 100644
index a01920ef..00000000
--- a/ExerciceTracker.Cactus/Service/ExerciseServiceHelper.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using ExerciseTracker.Cactus.Model;
-using ExerciseTracker.Cactus.Util;
-using Spectre.Console;
-
-namespace ExerciseTracker.Cactus.Service
-{
- public static class ExerciseServiceHelper
- {
- public static Exercise InputExercise()
- {
- Console.WriteLine("Please type start date");
- DateTime startDate = GetValidDate();
-
- Console.WriteLine("Please type end date");
- DateTime endDate = GetValidEndDate(startDate);
-
- int duration = AnsiConsole.Ask("Duration:");
-
- string comments = AnsiConsole.Ask("Comments:");
-
- Exercise exercise = new Exercise(startDate, endDate, duration, comments);
-
- return exercise;
- }
-
-
- public static DateTime GetValidDate()
- {
- var dateStr = AnsiConsole.Ask("Date (format: yyyy-MM-dd):");
- DateTime date;
- while (!Validator.IsValidDate(dateStr, out date))
- {
- Console.WriteLine("Please type correct format date.");
- dateStr = AnsiConsole.Ask("Date (format: yyyy-MM-dd):");
- }
-
- return date;
- }
-
-
- public static DateTime GetValidEndDate(DateTime startDate)
- {
- DateTime endDate = GetValidDate();
- while (endDate < startDate)
- {
- Console.WriteLine($"End date should late than start date {startDate}.");
- var endDateStr = AnsiConsole.Ask("End date (format: yyyy-MM-dd): ");
- while (!Validator.IsValidDate(endDateStr, out endDate))
- {
- Console.WriteLine("Please type correct format date.");
- endDateStr = AnsiConsole.Ask("End date (format: yyyy-MM-dd): ");
- }
- }
- return endDate;
- }
-
-
- public static Exercise SelectExerciseById(IEnumerable exercise)
- {
- List uniqueIds = exercise.Select(exercise => exercise.Id).Distinct().ToList();
-
- var selectedId = AnsiConsole.Prompt(
- new SelectionPrompt()
- .Title("Please choose the exercise you like to operate?")
- .AddChoices(uniqueIds));
-
- var selectedExercise = exercise.Where(exercise => exercise.Id == selectedId).ToArray()[0];
-
- return selectedExercise;
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/UI/UserInterface.cs b/ExerciceTracker.Cactus/UI/UserInterface.cs
deleted file mode 100644
index 908a7bd6..00000000
--- a/ExerciceTracker.Cactus/UI/UserInterface.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-using ExerciseTracker.Cactus.Model;
-using Spectre.Console;
-
-namespace ExerciseTracker.Cactus.UI
-{
- public class UserInterface
- {
- public static void ShowExercise(IEnumerable exercises)
- {
- if (exercises is null)
- {
- Console.WriteLine("No Exercise.");
- return;
- }
-
- var table = new Table();
- table.Title("Exercise Info");
- table.AddColumn("Id");
- table.AddColumn("StartTime");
- table.AddColumn("EndTime");
- table.AddColumn("Duration");
- table.AddColumn("Comments");
-
- foreach (Exercise exercise in exercises)
- {
- table.AddRow(exercise.Id.ToString(),
- exercise.DateStart.ToString("yyyy/MM/dd"), exercise.DateEnd.ToString("yyyy/MM/dd"),
- exercise.Duration.ToString(), exercise.Comments);
- }
-
- AnsiConsole.Write(table);
- }
-
- public static void ShowExercise(Exercise exercise)
- {
- if (exercise == null)
- {
- Console.WriteLine("No Exercise.");
- return;
- }
-
- var panel = new Panel($"{exercise.DateStart.ToString("yyyy/MM/dd")} - {exercise.DateEnd.ToString("yyyy/MM/dd")} {exercise.Duration} {exercise.Comments}")
- .Header("[bold]Exercise Info[/]")
- .BorderColor(Color.Blue);
-
- panel.Padding(2, 2, 2, 2);
-
- AnsiConsole.Write(panel);
- }
-
- public static void BackToMainMenuPrompt()
- {
- Console.WriteLine("Press any key to go back to Main Menu");
- Console.ReadLine();
- Console.Clear();
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/Util/Validator.cs b/ExerciceTracker.Cactus/Util/Validator.cs
deleted file mode 100644
index 3278d8e4..00000000
--- a/ExerciceTracker.Cactus/Util/Validator.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace ExerciseTracker.Cactus.Util
-{
- public class Validator
- {
- public static bool IsValidDate(string dateStr, out DateTime date)
- {
-
- if (DateTime.TryParseExact(dateStr, "yyyy-MM-dd", null, System.Globalization.DateTimeStyles.None, out date))
- {
- return true;
- }
- return false;
- }
- }
-}
diff --git a/ExerciceTracker.Cactus/img/exerciseTracker.png b/ExerciceTracker.Cactus/img/exerciseTracker.png
deleted file mode 100644
index 0a5c99df..00000000
Binary files a/ExerciceTracker.Cactus/img/exerciseTracker.png and /dev/null differ
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Controllers/ExerciseController.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Controllers/ExerciseController.cs
deleted file mode 100644
index 07042dc0..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Controllers/ExerciseController.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-using ExerciceTracker.Services;
-
-namespace ExerciceTracker.Controllers
-{
- internal class ExerciseController
- {
- private readonly ExerciseService _exerciseService;
-
- public ExerciseController(ExerciseService exerciseService)
- {
- _exerciseService = exerciseService;
- }
-
- internal void MainMenu()
- {
- bool isAppRunning = true;
-
- while (isAppRunning)
- {
- Console.WriteLine("\nChoose: \n");
- Console.WriteLine("1 to add an exercise\n");
- Console.WriteLine("2 to delete an exercise\n");
- Console.WriteLine("3 to see all exercises\n");
- Console.WriteLine("Q to quit\n");
-
- string userInput = Console.ReadLine();
- switch (userInput.ToLower())
- {
- case "1":
- _exerciseService.AddService();
- break;
- case "2":
- _exerciseService.DeleteService();
- break;
- case "3":
- _exerciseService.GetAllService();
- break;
- case "q":
- isAppRunning = false;
- break;
- default:
- Console.WriteLine("Invalid input.");
- break;
- }
- }
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/Exercise.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/Exercise.cs
deleted file mode 100644
index 22c717d3..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/Exercise.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace ExerciceTracker.Data.Models
-{
- internal class Exercise
- {
- public int Id { get; set; }
- public DateTime DateStart { get; set; }
- public DateTime DateEnd { get; set; }
- public TimeSpan Duration { get; set; }
- public string? Comments { get; set; }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/ExerciseDbContext.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/ExerciseDbContext.cs
deleted file mode 100644
index 84a8891e..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Models/ExerciseDbContext.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-
-namespace ExerciceTracker.Data.Models
-{
- internal class ExerciseDbContext : DbContext
- {
- public ExerciseDbContext(DbContextOptions options) : base(options)
- {
- }
-
- public DbSet Exercises { get; set; }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- optionsBuilder.UseSqlServer("Server=DESKTOP-ETA4JL7;Database=Exercices;Trusted_Connection=True;Integrated Security=True;Encrypt=False;");
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/ExerciseRepository.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/ExerciseRepository.cs
deleted file mode 100644
index 95927ab5..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/ExerciseRepository.cs
+++ /dev/null
@@ -1,34 +0,0 @@
-using ExerciceTracker.Data.Models;
-
-namespace ExerciceTracker.Data.Repositories
-{
- internal class ExerciseRepository : IExerciseRepository
- {
- private readonly ExerciseDbContext _context;
- public ExerciseRepository(ExerciseDbContext context)
- {
- _context = context;
- }
-
- public void Add(Exercise exercise)
- {
- _context.Add(exercise);
- _context.SaveChanges();
- }
-
- public IEnumerable GetAll()
- {
- return _context.Set().ToList();
- }
-
- public void Delete(int id)
- {
- var exerciseInDb = _context.Exercises.Find(id);
- if (exerciseInDb != null)
- {
- _context.Remove(exerciseInDb);
- _context.SaveChanges();
- }
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/IExerciseRepository.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/IExerciseRepository.cs
deleted file mode 100644
index 456754c7..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Data/Repositories/IExerciseRepository.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-using ExerciceTracker.Data.Models;
-
-namespace ExerciceTracker.Data.Repositories
-{
- internal interface IExerciseRepository
- {
- public IEnumerable GetAll();
- public void Add(Exercise exercise);
- public void Delete(int id);
- }
-}
\ No newline at end of file
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/ExerciceTracker.csproj b/ExerciceTrackerApp.MicVerg/ExerciceTracker/ExerciceTracker.csproj
deleted file mode 100644
index cb9762f2..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/ExerciceTracker.csproj
+++ /dev/null
@@ -1,19 +0,0 @@
-
-
-
- Exe
- net8.0
- enable
- enable
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.Designer.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.Designer.cs
deleted file mode 100644
index 63bee8e0..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.Designer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-using System;
-using ExerciceTracker.Data;
-using ExerciceTracker.Data.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciceTracker.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- [Migration("20231213190646_initial")]
- partial class initial
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.0")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciceTracker.Data.Models.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.HasKey("Id");
-
- b.ToTable("Exercises");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.cs
deleted file mode 100644
index 95343675..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190646_initial.cs
+++ /dev/null
@@ -1,37 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace ExerciceTracker.Migrations
-{
- ///
- public partial class initial : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Exercises",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- DateStart = table.Column(type: "datetime2", nullable: false),
- DateEnd = table.Column(type: "datetime2", nullable: false),
- Duration = table.Column(type: "time", nullable: false),
- Comments = table.Column(type: "nvarchar(max)", nullable: false)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Exercises", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Exercises");
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.Designer.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.Designer.cs
deleted file mode 100644
index d54f3f2d..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.Designer.cs
+++ /dev/null
@@ -1,57 +0,0 @@
-//
-using System;
-using ExerciceTracker.Data;
-using ExerciceTracker.Data.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciceTracker.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- [Migration("20231213190836_fix")]
- partial class fix
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.0")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciceTracker.Data.Models.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.HasKey("Id");
-
- b.ToTable("Exercises");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.cs
deleted file mode 100644
index 101349d8..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/20231213190836_fix.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace ExerciceTracker.Migrations
-{
- ///
- public partial class fix : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
-
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
-
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/ExerciseDbContextModelSnapshot.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/ExerciseDbContextModelSnapshot.cs
deleted file mode 100644
index 847d17ef..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Migrations/ExerciseDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-//
-using System;
-using ExerciceTracker.Data;
-using ExerciceTracker.Data.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciceTracker.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- partial class ExerciseDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.0")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciceTracker.Data.Models.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.HasKey("Id");
-
- b.ToTable("Exercises");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Program.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Program.cs
deleted file mode 100644
index a7313d0e..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Program.cs
+++ /dev/null
@@ -1,28 +0,0 @@
-using ExerciceTracker.Controllers;
-using ExerciceTracker.Data.Models;
-using ExerciceTracker.Data.Repositories;
-using ExerciceTracker.Services;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Hosting;
-
-var host = new HostBuilder()
- .ConfigureServices((hostContext, services) =>
- {
- services.AddDbContext(options =>
- options.UseSqlServer("Server=DESKTOP-ETA4JL7;Database=Exercices;Trusted_Connection=True;Integrated Security=True;Encrypt=False;"));
-
- services.AddTransient();
- services.AddTransient();
- services.AddTransient();
- })
- .Build();
-
-using (var scope = host.Services.CreateScope())
-{
- var services = scope.ServiceProvider;
- var context = services.GetRequiredService();
- var exerciseController = services.GetRequiredService();
-
- exerciseController.MainMenu();
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Services/ExerciseService.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/Services/ExerciseService.cs
deleted file mode 100644
index f35742e3..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/Services/ExerciseService.cs
+++ /dev/null
@@ -1,54 +0,0 @@
-using ExerciceTracker.Data.Repositories;
-
-namespace ExerciceTracker.Services
-{
- internal class ExerciseService
- {
- private readonly IExerciseRepository _exerciseRepository;
-
- public ExerciseService(IExerciseRepository exerciseRepository)
- {
- _exerciseRepository = exerciseRepository;
- }
-
- public void AddService()
- {
- Console.Clear();
- var exercise = UserInput.GetUserInputExercise();
- _exerciseRepository.Add(exercise);
- }
- public void DeleteService()
- {
- Console.Clear();
- var exercises = _exerciseRepository.GetAll().ToList();
- if (exercises.Count() == 0)
- {
- Console.WriteLine("The database is empty");
- Console.ReadKey();
- }
- else
- {
- Console.WriteLine("Enter the ID you want to delete");
- int id = int.Parse(Console.ReadLine());
- _exerciseRepository.Delete(id);
- }
- }
- public void GetAllService()
- {
- Console.Clear();
- var exercises = _exerciseRepository.GetAll().ToList();
- if (exercises.Count == 0)
- {
- Console.WriteLine("Db is empty");
- Console.ReadLine();
- }
- else
- {
- foreach (var exercise in exercises)
- {
- Console.WriteLine($"Id: {exercise.Id}, Start: {exercise.DateStart}, End: {exercise.DateEnd}, Duration: {exercise.Duration}, Comments: {exercise.Comments}");
- }
- }
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTracker/UserInput.cs b/ExerciceTrackerApp.MicVerg/ExerciceTracker/UserInput.cs
deleted file mode 100644
index 2cbad6c9..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTracker/UserInput.cs
+++ /dev/null
@@ -1,69 +0,0 @@
-using ExerciceTracker.Data.Models;
-using System.Globalization;
-
-namespace ExerciceTracker
-{
- internal class UserInput
- {
-
- internal static Exercise GetUserInputExercise()
- {
- var exercise = new Exercise();
- DateTime startTime, endTime;
- bool isValidStartTime = false;
- bool isValidEndTime = false;
- // get start time
- while (!isValidStartTime)
- {
- Console.WriteLine("What's the start time? (dd/mm/yyyy hh:mm) \n");
- string userInputStart = Console.ReadLine();
-
- if (DateTime.TryParseExact(userInputStart, "d/M/yyyy H:m", CultureInfo.InvariantCulture, DateTimeStyles.None, out startTime))
- {
- exercise.DateStart = startTime;
- isValidStartTime = true;
- }
- else
- {
- Console.WriteLine("Invalid input. (dd/mm/yyyy hh:mm)");
- }
- }
-
- // get end time
- while (!isValidEndTime)
- {
- Console.WriteLine("What's the end time? (dd/mm/yyyy hh:mm) \n");
- string userInputEnd = Console.ReadLine();
-
- if (DateTime.TryParseExact(userInputEnd, "d/M/yyyy H:m", CultureInfo.InvariantCulture, DateTimeStyles.None, out endTime))
- {
- if (endTime < exercise.DateStart)
- {
- Console.WriteLine("Invalid input, end time can't be earlier than start time.");
- }
- else
- {
- exercise.DateEnd = endTime;
- isValidEndTime = true;
- }
- }
- else
- {
- Console.WriteLine("Invalid input. (dd/mm/yyyy hh:mm)");
- }
- }
-
- // get duration
- TimeSpan duration;
- duration = exercise.DateEnd - exercise.DateStart;
- exercise.Duration = duration;
-
- // get comments
- Console.WriteLine("Want to add a comment?\n");
- string userInputComments = Console.ReadLine();
- exercise.Comments = userInputComments;
-
- return exercise;
- }
- }
-}
diff --git a/ExerciceTrackerApp.MicVerg/ExerciceTrackerApp.sln b/ExerciceTrackerApp.MicVerg/ExerciceTrackerApp.sln
deleted file mode 100644
index 98fbf2fe..00000000
--- a/ExerciceTrackerApp.MicVerg/ExerciceTrackerApp.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.8.34322.80
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExerciceTracker", "ExerciceTracker\ExerciceTracker.csproj", "{FDF11569-98E3-48ED-A91F-AE3CF1ED675C}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {FDF11569-98E3-48ED-A91F-AE3CF1ED675C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {FDF11569-98E3-48ED-A91F-AE3CF1ED675C}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {FDF11569-98E3-48ED-A91F-AE3CF1ED675C}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {FDF11569-98E3-48ED-A91F-AE3CF1ED675C}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {1369E200-C48C-4143-8EB0-86904BB9C787}
- EndGlobalSection
-EndGlobal
diff --git a/ExerciseTracker.Arashi256/App.config b/ExerciseTracker.Arashi256/App.config
deleted file mode 100644
index 76173508..00000000
--- a/ExerciseTracker.Arashi256/App.config
+++ /dev/null
@@ -1,10 +0,0 @@
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Classes/CommonUI.cs b/ExerciseTracker.Arashi256/Classes/CommonUI.cs
deleted file mode 100644
index b2382001..00000000
--- a/ExerciseTracker.Arashi256/Classes/CommonUI.cs
+++ /dev/null
@@ -1,80 +0,0 @@
-using ExerciseTracker.Arashi256.Enums;
-using Spectre.Console;
-using System.Net.Quic;
-
-namespace ExerciseTracker.Arashi256.Classes
-{
- internal class CommonUI
- {
- public static int MenuOption(string question, int min, int max)
- {
- bool isValid = false;
- int selectedValue = 0;
- do
- {
- var userInput = AnsiConsole.Ask(question);
- selectedValue = userInput;
- if (selectedValue < min || selectedValue > max)
- {
- AnsiConsole.MarkupLine("[red]Invalid input. Please enter a value within the specified range.[/]");
- isValid = false;
- }
- else
- isValid = true;
- } while (!isValid);
- return selectedValue;
- }
-
- public static void Pause(string colour)
- {
- AnsiConsole.Markup($"[{colour}]Press any key to continue...[/]");
- Console.ReadKey(true);
- }
-
- public static string? GetStringWithPrompt(string prompt, int lengthlimit, string nullString)
- {
- AnsiConsole.MarkupLine("[white]Enter '0' to cancel[/]");
- string input = AnsiConsole.Ask(prompt).Trim();
- if (input.Equals("0")) return null;
- while (input.Length > lengthlimit)
- {
- AnsiConsole.MarkupLine($"\n[red]Entry needs to be less than {lengthlimit} characters. Try again.[/]\n\n");
- input = AnsiConsole.Ask(prompt);
- }
- return input;
- }
-
- public static DateTime? GetDateTimeDialog(string format)
- {
- DateTime? dateTime = null;
- while (!dateTime.HasValue)
- {
- AnsiConsole.MarkupLine($"[steelblue1_1]Note: Enter '0' to abort[/]");
- var userInput = AnsiConsole.Prompt(new TextPrompt($"Enter a date/time in the format '{format}':").PromptStyle("white")).Trim();
- if (userInput == "0")
- {
- return null;
- }
- else
- {
- if (DateTime.TryParseExact(userInput, format, null, System.Globalization.DateTimeStyles.None, out DateTime result))
- {
- dateTime = result;
- }
- else
- {
- AnsiConsole.MarkupLine("[red]Invalid date/time format. Please enter the date/time in the specified format.[/]");
- }
- }
- }
- return dateTime;
- }
-
- public static ExerciseType GetExerciseTypeDialog(IEnumerable exerciseTypes)
- {
- // Prompt the user to select an exercise type from the exercise type public enum. Avert your eyes.
- var exerciseType = AnsiConsole.Prompt(new SelectionPrompt().Title("Select your exercise type:").AddChoices(exerciseTypes));
- return exerciseType;
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Classes/ServiceResponse.cs b/ExerciseTracker.Arashi256/Classes/ServiceResponse.cs
deleted file mode 100644
index 7e2ebb35..00000000
--- a/ExerciseTracker.Arashi256/Classes/ServiceResponse.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace ExerciseTracker.Arashi256.Classes
-{
- public class ServiceResponse
- {
- public ResponseStatus Status { get; set; } = ResponseStatus.Failure;
- public string Message { get; set; } = string.Empty;
- public object? Data { get; set; }
- }
-
- public enum ResponseStatus { Success, Failure }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Classes/ServiceResponseUtils.cs b/ExerciseTracker.Arashi256/Classes/ServiceResponseUtils.cs
deleted file mode 100644
index 3ca07f0f..00000000
--- a/ExerciseTracker.Arashi256/Classes/ServiceResponseUtils.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-namespace ExerciseTracker.Arashi256.Classes
-{
- public class ServiceResponseUtils
- {
- public static ServiceResponse CreateResponse(ResponseStatus status, string message, object? data)
- {
- return new ServiceResponse { Status = status, Message = message, Data = data };
- }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Classes/Validation.cs b/ExerciseTracker.Arashi256/Classes/Validation.cs
deleted file mode 100644
index 091949e0..00000000
--- a/ExerciseTracker.Arashi256/Classes/Validation.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-namespace ExerciseTracker.Arashi256.Classes
-{
- internal class Validation
- {
- public static bool ValidateDatesForDuration(DateTime start, DateTime end)
- {
- return start < end;
- }
-
- public static TimeSpan CalculateDuration(DateTime start, DateTime end)
- {
- return end - start;
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Config/AppManager.cs b/ExerciseTracker.Arashi256/Config/AppManager.cs
deleted file mode 100644
index 37a3c96e..00000000
--- a/ExerciseTracker.Arashi256/Config/AppManager.cs
+++ /dev/null
@@ -1,33 +0,0 @@
-using System.Collections.Specialized;
-
-namespace ExerciseTracker.Arashi256.Config
-{
- internal class AppManager
- {
- public string? DatabaseConnectionString { get; private set; }
- public string? DateTimeFormatString { get; private set; }
-
- private NameValueCollection? _appConfig;
-
- public AppManager()
- {
- try
- {
- _appConfig = System.Configuration.ConfigurationManager.AppSettings;
- if (_appConfig.Count == 0)
- {
- Console.WriteLine("\nERROR: AppSettings is empty or cannot be read.\n");
- }
- else
- {
- DatabaseConnectionString = _appConfig.Get("ConnectionString");
- DateTimeFormatString = _appConfig.Get("PreferredDateTimeFormat");
- }
- }
- catch (System.Configuration.ConfigurationErrorsException)
- {
- Console.WriteLine("\nERROR: Could not read app settings\n");
- }
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Config/AppSettings.cs b/ExerciseTracker.Arashi256/Config/AppSettings.cs
deleted file mode 100644
index 9f3d206f..00000000
--- a/ExerciseTracker.Arashi256/Config/AppSettings.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-namespace ExerciseTracker.Arashi256.Config
-{
- public class AppSettings
- {
- private string? _databaseConnectionString;
- private string? _preferredDateTime;
-
- public AppSettings()
- {
- AppManager appManager = new AppManager();
- _databaseConnectionString = appManager.DatabaseConnectionString;
- _preferredDateTime = appManager.DateTimeFormatString;
- }
-
- public string? DatabaseConnectionString { get { return _databaseConnectionString; } }
- public string? DateTimeFormat { get { return _preferredDateTime; } }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Controllers/ExerciseSessionController.cs b/ExerciseTracker.Arashi256/Controllers/ExerciseSessionController.cs
deleted file mode 100644
index 25b0b59b..00000000
--- a/ExerciseTracker.Arashi256/Controllers/ExerciseSessionController.cs
+++ /dev/null
@@ -1,40 +0,0 @@
-using ExerciseTracker.Arashi256.Classes;
-using ExerciseTracker.Arashi256.Models;
-using ExerciseTracker.Arashi256.Services;
-
-namespace ExerciseTracker.Arashi256.Controllers
-{
- internal class ExerciseSessionController
- {
- private readonly ExerciseSessionService _exerciseService;
- public ExerciseSessionController(ExerciseSessionService service)
- {
- _exerciseService = service;
- }
-
- public ServiceResponse GetAllExerciseSessions()
- {
- return _exerciseService.GetAllExerciseSessions();
- }
-
- public ServiceResponse AddNewExerciseSession(ExerciseSessionInputDto newSession)
- {
- return _exerciseService.AddNewExerciseSession(newSession);
- }
-
- public ServiceResponse DeleteExistingExerciseSession(int id)
- {
- return _exerciseService.DeleteExistingExerciseSession(id);
- }
-
- public ServiceResponse UpdateExistingExerciseSession(int id, ExerciseSessionInputDto updateSession)
- {
- return _exerciseService.UpdateExistingExerciseSession(id, updateSession);
- }
-
- public ServiceResponse GetExerciseSessionById(int id)
- {
- return _exerciseService.GetExerciseSessionById(id);
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Enums/ExerciseType.cs b/ExerciseTracker.Arashi256/Enums/ExerciseType.cs
deleted file mode 100644
index 8647e94f..00000000
--- a/ExerciseTracker.Arashi256/Enums/ExerciseType.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-namespace ExerciseTracker.Arashi256.Enums
-{
- // DEVELOPER'S NOTE: This is used as a quick and dirty way to have exercise types in order to satisfy the challenge.
- // If this had been a requirement rather than a challenge, I would have had this as a separate table in the database
- // with it's own model, controller, service, DTOs, repostiory and CRUD operations but is beyond the scope of this
- // project.
- public enum ExerciseType
- {
- HIKING,
- CARDIO
- }
-}
diff --git a/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.csproj b/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.csproj
deleted file mode 100644
index b0cf7f71..00000000
--- a/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.csproj
+++ /dev/null
@@ -1,24 +0,0 @@
-
-
-
- Exe
- net8.0
- enable
- enable
-
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
-
diff --git a/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.sln b/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.sln
deleted file mode 100644
index cd4ea47e..00000000
--- a/ExerciseTracker.Arashi256/ExerciseTracker.Arashi256.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.11.35312.102
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExerciseTracker.Arashi256", "ExerciseTracker.Arashi256.csproj", "{666926DA-CB67-4589-A855-F0805B69AB2A}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {666926DA-CB67-4589-A855-F0805B69AB2A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {666926DA-CB67-4589-A855-F0805B69AB2A}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {666926DA-CB67-4589-A855-F0805B69AB2A}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {666926DA-CB67-4589-A855-F0805B69AB2A}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {27743D9B-9797-49CE-BF47-32DEFC2FFDA2}
- EndGlobalSection
-EndGlobal
diff --git a/ExerciseTracker.Arashi256/Interfaces/IExerciseSessionRepository.cs b/ExerciseTracker.Arashi256/Interfaces/IExerciseSessionRepository.cs
deleted file mode 100644
index 05946fe5..00000000
--- a/ExerciseTracker.Arashi256/Interfaces/IExerciseSessionRepository.cs
+++ /dev/null
@@ -1,15 +0,0 @@
-using ExerciseTracker.Arashi256.Models;
-using ExerciseTracker.Arashi256.Classes;
-
-namespace ExerciseTracker.Arashi256.Interfaces
-{
- public interface IExerciseSessionRepository
- {
- ServiceResponse GetExerciseSessions();
- ServiceResponse GetExerciseSessionById(int id);
- ServiceResponse AddExerciseSession(ExerciseSession exercise);
- ServiceResponse DeleteExerciseSession(int id);
- ServiceResponse UpdateExerciseSession(int id, ExerciseSession exercise);
- ServiceResponse ExerciseSessionExistsInRange(DateTime startDate, DateTime endDate, int? sessionIdToExclude = null);
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.Designer.cs b/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.Designer.cs
deleted file mode 100644
index b4b07ac3..00000000
--- a/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.Designer.cs
+++ /dev/null
@@ -1,61 +0,0 @@
-//
-using System;
-using ExerciseTracker.Arashi256.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciseTracker.Arashi256.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- [Migration("20241020113301_InitialSchema")]
- partial class InitialSchema
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.10")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciseTracker.Arashi256.Models.ExerciseSession", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasMaxLength(255)
- .HasColumnType("nvarchar(255)");
-
- b.Property("DateTimeEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateTimeStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.Property("Type")
- .IsRequired()
- .HasMaxLength(25)
- .HasColumnType("nvarchar(25)");
-
- b.HasKey("Id");
-
- b.ToTable("ExerciseSessions");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.cs b/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.cs
deleted file mode 100644
index 69eb9859..00000000
--- a/ExerciseTracker.Arashi256/Migrations/20241020113301_InitialSchema.cs
+++ /dev/null
@@ -1,39 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace ExerciseTracker.Arashi256.Migrations
-{
- ///
- public partial class InitialSchema : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "ExerciseSessions",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- Type = table.Column(type: "nvarchar(25)", maxLength: 25, nullable: false),
- DateTimeStart = table.Column(type: "datetime2", nullable: false),
- DateTimeEnd = table.Column(type: "datetime2", nullable: false),
- Duration = table.Column(type: "time", nullable: false),
- Comments = table.Column(type: "nvarchar(255)", maxLength: 255, nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_ExerciseSessions", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "ExerciseSessions");
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Migrations/ExerciseDbContextModelSnapshot.cs b/ExerciseTracker.Arashi256/Migrations/ExerciseDbContextModelSnapshot.cs
deleted file mode 100644
index d5257f1c..00000000
--- a/ExerciseTracker.Arashi256/Migrations/ExerciseDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,58 +0,0 @@
-//
-using System;
-using ExerciseTracker.Arashi256.Models;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace ExerciseTracker.Arashi256.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- partial class ExerciseDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.10")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("ExerciseTracker.Arashi256.Models.ExerciseSession", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasMaxLength(255)
- .HasColumnType("nvarchar(255)");
-
- b.Property("DateTimeEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateTimeStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.Property("Type")
- .IsRequired()
- .HasMaxLength(25)
- .HasColumnType("nvarchar(25)");
-
- b.HasKey("Id");
-
- b.ToTable("ExerciseSessions");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Models/ExerciseDbContext.cs b/ExerciseTracker.Arashi256/Models/ExerciseDbContext.cs
deleted file mode 100644
index 57e014b6..00000000
--- a/ExerciseTracker.Arashi256/Models/ExerciseDbContext.cs
+++ /dev/null
@@ -1,30 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using ExerciseTracker.Arashi256.Config;
-
-namespace ExerciseTracker.Arashi256.Models
-{
- public class ExerciseDbContext : DbContext
- {
- private readonly AppSettings _connection;
-
- public ExerciseDbContext(AppSettings connection)
- {
- _connection = connection;
- }
-
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- if (!optionsBuilder.IsConfigured)
- {
- optionsBuilder.UseSqlServer(_connection.DatabaseConnectionString);
- }
- }
-
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- modelBuilder.Entity().HasKey(es => es.Id);
- }
-
- public DbSet ExerciseSessions { get; set; }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Models/ExerciseSession.cs b/ExerciseTracker.Arashi256/Models/ExerciseSession.cs
deleted file mode 100644
index c4ac6cd9..00000000
--- a/ExerciseTracker.Arashi256/Models/ExerciseSession.cs
+++ /dev/null
@@ -1,20 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExerciseTracker.Arashi256.Models
-{
- public class ExerciseSession
- {
- [Key]
- public int Id { get; set; }
- [Required, MaxLength(25)]
- public string Type { get; set; } = string.Empty;
- [Required]
- public DateTime DateTimeStart { get; set; }
- [Required]
- public DateTime DateTimeEnd { get; set; }
- [Required]
- public TimeSpan Duration { get; set; }
- [MaxLength(255)]
- public string? Comments { get; set; }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Models/ExerciseSessionInputDto.cs b/ExerciseTracker.Arashi256/Models/ExerciseSessionInputDto.cs
deleted file mode 100644
index 0697968b..00000000
--- a/ExerciseTracker.Arashi256/Models/ExerciseSessionInputDto.cs
+++ /dev/null
@@ -1,18 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExerciseTracker.Arashi256.Models
-{
- public record ExerciseSessionInputDto
- {
- [Key]
- public int Id { get; set; }
- [Required, MaxLength(25)]
- public string Type { get; set; } = string.Empty;
- [Required]
- public DateTime DateTimeStart { get; set; }
- [Required]
- public DateTime DateTimeEnd { get; set; }
- [MaxLength(255)]
- public string? Comments { get; set; }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Models/ExerciseSessionOutputDto.cs b/ExerciseTracker.Arashi256/Models/ExerciseSessionOutputDto.cs
deleted file mode 100644
index 6cac9d63..00000000
--- a/ExerciseTracker.Arashi256/Models/ExerciseSessionOutputDto.cs
+++ /dev/null
@@ -1,22 +0,0 @@
-using System.ComponentModel.DataAnnotations;
-
-namespace ExerciseTracker.Arashi256.Models
-{
- public record ExerciseSessionOutputDto
- {
- [Required]
- public int DisplayId { get; set; }
- [Key]
- public int Id { get; set; }
- [Required, MaxLength(25)]
- public string Type { get; set; } = string.Empty;
- [Required]
- public DateTime DateTimeStart { get; set; }
- [Required]
- public DateTime DateTimeEnd { get; set; }
- [Required]
- public TimeSpan Duration { get; set; }
- [MaxLength(255)]
- public string? Comments { get; set; }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Models/READ.ME b/ExerciseTracker.Arashi256/Models/READ.ME
deleted file mode 100644
index 9ef231c4..00000000
--- a/ExerciseTracker.Arashi256/Models/READ.ME
+++ /dev/null
@@ -1,16 +0,0 @@
-READ.ME
--------
-
-An C# Console-based exercise tracker using SQL Server. App settings are configured in App.config - please change to suit your testing requirements.
-
-Developer's note:
-All challenges complete for this project. The last challenge will use the default EF-Core based Repository if the exercise Type is "HIKING", if the exercise Type is "CARDIO", it will use the Dapper-based Repository.
-This only applies to Create and Update CRUD operations. Retreive and Delete operations would need to know the Type ahead of Retreiving it. There was an issue where updates made with Dapper do not show in the listing of exercise sessions unless:-
-
-List sessions = _context.ExerciseSessions.ToList();
-
-was changed to:-
-
-List sessions = _context.ExerciseSessions.AsNoTracking.ToList();
-
-...to get the changes executed by the Dapper Repository seen immediately by the Retrieve operation performed by EF Core Repository. I recognise that in the real-world, this would not be necessary as you'd not be mixing and matching Dapper and EF Core in the same application like this.
diff --git a/ExerciseTracker.Arashi256/Program.cs b/ExerciseTracker.Arashi256/Program.cs
deleted file mode 100644
index e12aad17..00000000
--- a/ExerciseTracker.Arashi256/Program.cs
+++ /dev/null
@@ -1,25 +0,0 @@
-using Microsoft.Extensions.Hosting;
-using Microsoft.Extensions.DependencyInjection;
-using Microsoft.Extensions.Logging;
-using ExerciseTracker.Arashi256.Models;
-using ExerciseTracker.Arashi256.Repositories;
-using ExerciseTracker.Arashi256.Services;
-using ExerciseTracker.Arashi256.Controllers;
-using ExerciseTracker.Arashi256.Config;
-using ExerciseTracker.Arashi256.Views;
-
-var builder = Host.CreateApplicationBuilder();
-builder.Services.AddSingleton();
-builder.Services.AddDbContext();
-builder.Services.AddScoped();
-builder.Services.AddScoped();
-builder.Services.AddScoped();
-builder.Services.AddScoped();
-builder.Logging.ClearProviders();
-var app = builder.Build();
-var scope = app.Services.CreateScope();
-var exerciseService = scope.ServiceProvider;
-var exerciseController = exerciseService.GetRequiredService();
-var appSettings = exerciseService.GetRequiredService();
-MainView mainView = new MainView(exerciseController, appSettings);
-mainView.DisplayView();
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepository.cs b/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepository.cs
deleted file mode 100644
index 09a944ba..00000000
--- a/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepository.cs
+++ /dev/null
@@ -1,110 +0,0 @@
-using ExerciseTracker.Arashi256.Interfaces;
-using ExerciseTracker.Arashi256.Models;
-using ExerciseTracker.Arashi256.Classes;
-using Microsoft.EntityFrameworkCore;
-
-namespace ExerciseTracker.Arashi256.Repositories
-{
- public class ExerciseSessionRepository : IExerciseSessionRepository
- {
- private readonly ExerciseDbContext _context;
-
- public ExerciseSessionRepository(ExerciseDbContext context)
- {
- _context = context;
- }
-
- public ServiceResponse AddExerciseSession(ExerciseSession exercise)
- {
- try
- {
- _context.ExerciseSessions.Add(exercise);
- _context.SaveChanges();
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", exercise);
- }
- catch (DbUpdateException ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse DeleteExerciseSession(int id)
- {
- try
- {
- var session = _context.ExerciseSessions.Find(id);
- if (session == null)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Exercise session not found", null);
- else
- {
- _context.ExerciseSessions.Remove(session);
- _context.SaveChanges();
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", null);
- }
- }
- catch (DbUpdateException ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse GetExerciseSessions()
- {
- // AsNoTracking() used here to cope with operations outside EF Core like when mixing DB operations with Dapper for the extra challenge.
- List sessions = _context.ExerciseSessions.AsNoTracking().ToList();
- if (sessions != null && sessions.Count > 0)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", sessions);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "No exercise sessions found", sessions);
- }
-
- public ServiceResponse GetExerciseSessionById(int id)
- {
- var session = _context.ExerciseSessions.Find(id);
- if (session != null)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", session);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Exercise session not found", null);
- }
-
- public ServiceResponse UpdateExerciseSession(int id, ExerciseSession exercise)
- {
- if (id != exercise.Id)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Update exercise session and id mismatch", null);
- }
- var existingSession = _context.ExerciseSessions.Find(id);
- if (existingSession == null)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Exercise session not found", null);
- }
- existingSession.Type = exercise.Type;
- existingSession.DateTimeStart = exercise.DateTimeStart;
- existingSession.DateTimeEnd = exercise.DateTimeEnd;
- existingSession.Duration = exercise.Duration;
- existingSession.Comments = exercise.Comments;
- try
- {
- _context.SaveChanges();
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", existingSession);
- }
- catch (DbUpdateException ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse ExerciseSessionExistsInRange(DateTime startDate, DateTime endDate, int? sessionIdToExclude = null)
- {
- try
- {
- bool isOverlapping = _context.ExerciseSessions.AsNoTracking().Any(session => (!sessionIdToExclude.HasValue || session.Id != sessionIdToExclude.Value) && startDate < session.DateTimeEnd && endDate > session.DateTimeStart);
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", isOverlapping);
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepositoryDapper.cs b/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepositoryDapper.cs
deleted file mode 100644
index 3df8e3b9..00000000
--- a/ExerciseTracker.Arashi256/Repositories/ExerciseSessionRepositoryDapper.cs
+++ /dev/null
@@ -1,175 +0,0 @@
-using Dapper;
-using ExerciseTracker.Arashi256.Classes;
-using ExerciseTracker.Arashi256.Config;
-using ExerciseTracker.Arashi256.Interfaces;
-using ExerciseTracker.Arashi256.Models;
-using Microsoft.Data.SqlClient;
-
-namespace ExerciseTracker.Arashi256.Repositories
-{
- public class ExerciseSessionRepositoryDapper : IExerciseSessionRepository
- {
- private readonly string _connectionString;
-
- public ExerciseSessionRepositoryDapper(AppSettings appSettings)
- {
- _connectionString = appSettings.DatabaseConnectionString ?? throw new ArgumentNullException(nameof(appSettings.DatabaseConnectionString), "HALT ERROR: Connection string cannot be null.");
- EnsureModelTableCreated();
- }
-
- private void EnsureModelTableCreated()
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- try
- {
- // Check if the table for the ExerciseSession exists.
- var tableExists = connection.ExecuteScalar("SELECT COUNT(*) FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'ExerciseSessions'");
- // If the table does not exist, create it.
- if (tableExists == 0)
- {
- connection.Execute(@"CREATE TABLE dbo.ExerciseSessions (
- Id INT IDENTITY(1,1) PRIMARY KEY,
- Type NVARCHAR(25) NOT NULL,
- DateTimeStart DATETIME2 NOT NULL,
- DateTimeEnd DATETIME2 NOT NULL,
- Duration TIME NOT NULL,
- Comments NVARCHAR(255));");
- }
- }
- catch (Exception ex)
- {
- throw new Exception($"HALT ERROR: ExerciseSession table does not exist and could not create it: '{ex.Message}'");
- }
- }
- }
-
- public ServiceResponse AddExerciseSession(ExerciseSession exercise)
- {
- try
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- string insertQuery = "INSERT INTO dbo.ExerciseSessions(Type, DateTimeStart, DateTimeEnd, Duration, Comments) VALUES (@Type, @DateTimeStart, @DateTimeEnd, @Duration, @Comments)";
- int rows = connection.Execute(insertQuery, exercise);
- if (rows > 0)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", exercise);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Could not add exercise session", null);
- }
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse DeleteExerciseSession(int id)
- {
- try
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- string deleteQuery = "DELETE FROM dbo.ExerciseSessions WHERE Id = @Id";
- int rows = connection.Execute(deleteQuery, new { Id = id });
- if (rows > 0)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", null);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Could not dete exercise session", null);
- }
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse GetExerciseSessionById(int id)
- {
- try
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- string selectQuery = "SELECT * FROM ExerciseSessions WHERE Id = @id";
- var session = connection.QuerySingleOrDefault(selectQuery, new { id });
- if (session != null)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", session);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Exercise session not found", null);
- }
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse GetExerciseSessions()
- {
- List results = new List();
- using (var connection = new SqlConnection(_connectionString))
- {
- try
- {
- string selectQuery = "SELECT * from dbo.ExerciseSessions";
- results = connection.Query(selectQuery).AsList();
- if (results == null || results.Count == 0)
- ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "No exercise sessions found", results);
- }
- catch (Exception ex)
- {
- ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", results);
- }
-
- public ServiceResponse UpdateExerciseSession(int id, ExerciseSession exercise)
- {
- if (id != exercise.Id)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Update exercise session and id mismatch", null);
- }
- try
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- // Check if the session exists in the database
- string selectQuery = "SELECT * FROM ExerciseSessions WHERE Id = @id";
- var existingSession = connection.QuerySingleOrDefault(selectQuery, new { id });
- if (existingSession == null)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Exercise session not found", null);
- string updateQuery = "UPDATE ExerciseSessions SET Type = @Type, DateTimeStart = @DateTimeStart, DateTimeEnd = @DateTimeEnd, Duration = @Duration, Comments = @Comments WHERE Id = @Id";
- int rows = connection.Execute(updateQuery, exercise);
- if (rows > 0)
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", exercise);
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Could not update exercise session", null);
- }
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
-
- public ServiceResponse ExerciseSessionExistsInRange(DateTime startDate, DateTime endDate, int? sessionIdToExclude = null)
- {
- try
- {
- using (var connection = new SqlConnection(_connectionString))
- {
- string existsQuery = sessionIdToExclude.HasValue
- ? "SELECT CASE WHEN EXISTS (SELECT 1 FROM ExerciseSessions WHERE Id != @sessionIdToExclude AND @startDate < DateTimeEnd AND @endDate > DateTimeStart) THEN 1 ELSE 0 END"
- : "SELECT CASE WHEN EXISTS (SELECT 1 FROM ExerciseSessions WHERE @startDate < DateTimeEnd AND @endDate > DateTimeStart) THEN 1 ELSE 0 END";
- bool isOverlapping = connection.ExecuteScalar(existsQuery, new { startDate, endDate, sessionIdToExclude }) == 1;
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", isOverlapping);
- }
- }
- catch (Exception ex)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, ex.Message, null);
- }
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Services/ExerciseSessionService.cs b/ExerciseTracker.Arashi256/Services/ExerciseSessionService.cs
deleted file mode 100644
index bde64a08..00000000
--- a/ExerciseTracker.Arashi256/Services/ExerciseSessionService.cs
+++ /dev/null
@@ -1,210 +0,0 @@
-using ExerciseTracker.Arashi256.Classes;
-using ExerciseTracker.Arashi256.Interfaces;
-using ExerciseTracker.Arashi256.Models;
-using ExerciseTracker.Arashi256.Repositories;
-using ExerciseTracker.Arashi256.Enums;
-
-namespace ExerciseTracker.Arashi256.Services
-{
- internal class ExerciseSessionService
- {
- private readonly IExerciseSessionRepository _exerciseRepository;
- private readonly IExerciseSessionRepository _exerciseRepositoryDapper;
-
- public ExerciseSessionService(ExerciseSessionRepository repEFCore, ExerciseSessionRepositoryDapper repDapper)
- {
- _exerciseRepository = repEFCore;
- _exerciseRepositoryDapper = repDapper;
- }
-
- // Method to get all exercise sessions and assign DisplayIds
- public ServiceResponse GetAllExerciseSessions()
- {
- ServiceResponse serviceResponse = _exerciseRepository.GetExerciseSessions();
- if (serviceResponse.Status.Equals(ResponseStatus.Success))
- {
- // Translate ExerciseSessions to ExerciseSessionsOutputDtos
- List? sessions = serviceResponse.Data as List;
- if (sessions != null && sessions.Count > 0)
- {
- serviceResponse.Data = ConvertToOutputDtoList(sessions);
- }
- return serviceResponse;
- }
- else
- return serviceResponse;
- }
-
- private List ConvertToOutputDtoList(List sessions)
- {
- int displayID = 0;
- List outputSessions = new List();
- foreach (var session in sessions)
- {
- outputSessions.Add(ConvertToOutputDto(++displayID, session));
- }
- return outputSessions;
- }
-
- private ExerciseSessionOutputDto ConvertToOutputDto(int displayID, ExerciseSession session)
- {
- var sessionDto = new ExerciseSessionOutputDto
- {
- Id = session.Id,
- DisplayId = displayID,
- Type = session.Type,
- DateTimeStart = session.DateTimeStart,
- DateTimeEnd = session.DateTimeEnd,
- Duration = session.Duration,
- Comments = session.Comments,
- };
- return sessionDto;
- }
-
- public ServiceResponse AddNewExerciseSession(ExerciseSessionInputDto newSession)
- {
- ServiceResponse response;
- bool hasOverlap = false;
- if (!Validation.ValidateDatesForDuration(newSession.DateTimeStart, newSession.DateTimeEnd))
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "End datetime cannot be before start datetime", null);
- else
- {
- if (newSession.Type.Equals(ExerciseType.HIKING))
- {
- // If HIKING, check for overlapping exercise sessions before doing anything from EF Core.
- response = _exerciseRepository.ExerciseSessionExistsInRange(newSession.DateTimeStart, newSession.DateTimeEnd);
- }
- else
- {
- // If CARDIO, Check for overlapping exercise sessions before doing anything from Dapper.
- response = _exerciseRepositoryDapper.ExerciseSessionExistsInRange(newSession.DateTimeStart, newSession.DateTimeEnd);
- }
- if (response.Status.Equals(ResponseStatus.Success))
- {
- if (response.Data is bool isOverlapping)
- {
- hasOverlap = isOverlapping;
- if (hasOverlap)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "The exercise session overlaps with an existing exercise session", null);
- }
- }
- else
- {
- return response; // If not boolean, return response which will be error anyway.
- }
- }
- TimeSpan duration = Validation.CalculateDuration(newSession.DateTimeStart, newSession.DateTimeEnd);
- var addSession = new ExerciseSession
- {
- Type = newSession.Type,
- DateTimeStart = newSession.DateTimeStart,
- DateTimeEnd = newSession.DateTimeEnd,
- Duration = duration,
- Comments = newSession.Comments
- };
- if (addSession.Type.Equals(ExerciseType.HIKING))
- return _exerciseRepository.AddExerciseSession(addSession);
- else
- return _exerciseRepositoryDapper.AddExerciseSession(addSession);
- }
- }
-
- public ServiceResponse DeleteExistingExerciseSession(int id)
- {
- ServiceResponse serviceResponse = _exerciseRepository.GetExerciseSessionById(id);
- if (serviceResponse.Status.Equals(ResponseStatus.Success))
- {
- return _exerciseRepository.DeleteExerciseSession(id);
- }
- else
- return serviceResponse;
- }
-
- public ServiceResponse UpdateExistingExerciseSession(int id, ExerciseSessionInputDto updateSession)
- {
- ServiceResponse response;
- bool hasOverlap = false;
- if (!Validation.ValidateDatesForDuration(updateSession.DateTimeStart, updateSession.DateTimeEnd))
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "End datetime cannot be before start datetime", null);
- else
- {
- if (updateSession.Type.Equals(ExerciseType.HIKING))
- {
- // If HIKING, check for overlapping exercise sessions before doing anything from EF Core.
- response = _exerciseRepository.ExerciseSessionExistsInRange(updateSession.DateTimeStart, updateSession.DateTimeEnd, updateSession.Id);
- }
- else
- {
- // If CARDIO, Check for overlapping exercise sessions before doing anything from Dapper.
- response = _exerciseRepositoryDapper.ExerciseSessionExistsInRange(updateSession.DateTimeStart, updateSession.DateTimeEnd, updateSession.Id);
- }
- if (response.Status.Equals(ResponseStatus.Success))
- {
- if (response.Data is bool isOverlapping)
- {
- hasOverlap = isOverlapping;
- if (hasOverlap)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "The exercise session overlaps with an existing exercise session", null);
- }
- }
- else
- {
- return response; // If not boolean, return response.
- }
- }
- TimeSpan duration = Validation.CalculateDuration(updateSession.DateTimeStart, updateSession.DateTimeEnd);
- var newSession = new ExerciseSession
- {
- Id = updateSession.Id,
- Type = updateSession.Type,
- DateTimeStart = updateSession.DateTimeStart,
- DateTimeEnd = updateSession.DateTimeEnd,
- Duration = duration,
- Comments = updateSession.Comments
- };
- if (newSession.Type.Equals(ExerciseType.HIKING))
- {
- // If HIKING, check for overlapping exercise sessions before doing anything from EF Core.
- response = _exerciseRepository.UpdateExerciseSession(updateSession.Id, newSession);
- }
- else
- {
- // If CARDIO, Check for overlapping exercise sessions before doing anything from Dapper.
- response = _exerciseRepositoryDapper.UpdateExerciseSession(updateSession.Id, newSession);
- }
- if (response.Status.Equals(ResponseStatus.Success))
- {
- var exerciseSessionUpdated = response.Data as ExerciseSession;
- if (exerciseSessionUpdated != null)
- {
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", ConvertToOutputDto(1, exerciseSessionUpdated));
- }
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Cannot format output session", null);
- }
- else
- return response;
- }
- }
-
- public ServiceResponse GetExerciseSessionById(int id)
- {
- ServiceResponse response = _exerciseRepository.GetExerciseSessionById(id);
- if (response.Equals(ResponseStatus.Success))
- {
- ExerciseSession? session = response.Data as ExerciseSession;
- if (session != null)
- {
- var outputSession = ConvertToOutputDto(1, session);
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Success, "OK", outputSession);
- }
- else
- return ServiceResponseUtils.CreateResponse(ResponseStatus.Failure, "Could not retrieve ExerciseSession", null);
- }
- else
- return response;
- }
- }
-}
diff --git a/ExerciseTracker.Arashi256/Views/MainView.cs b/ExerciseTracker.Arashi256/Views/MainView.cs
deleted file mode 100644
index 541cea83..00000000
--- a/ExerciseTracker.Arashi256/Views/MainView.cs
+++ /dev/null
@@ -1,306 +0,0 @@
-using ExerciseTracker.Arashi256.Classes;
-using ExerciseTracker.Arashi256.Config;
-using ExerciseTracker.Arashi256.Controllers;
-using ExerciseTracker.Arashi256.Enums;
-using ExerciseTracker.Arashi256.Models;
-using Spectre.Console;
-
-namespace ExerciseTracker.Arashi256.Views
-{
- internal class MainView
- {
- private const int QUIT_APPLICATION_OPTION_NUM = 5;
- private readonly string DATETIME_FORMAT;
- private readonly Table _tblMainMenu;
- private readonly string _appTitle = "EXERCISE TRACKER";
- private readonly FigletText _figletAppTitle;
- private readonly string[] _menuOptions =
- {
- "Add New Exercise Session",
- "Update Existing Exercise Session",
- "Delete Existing Exercise Session",
- "List All Exercise Sessions",
- "Quit application"
- };
- private ExerciseSessionController _controller;
-
- public MainView(ExerciseSessionController controller, AppSettings appSettings)
- {
- _figletAppTitle = new FigletText(_appTitle);
- _figletAppTitle.Centered();
- _figletAppTitle.Color = Color.Yellow3_1;
- _tblMainMenu = new Table();
- _tblMainMenu.AddColumn(new TableColumn("[orange1]CHOICE[/]").Centered());
- _tblMainMenu.AddColumn(new TableColumn("[orange1]OPTION[/]").LeftAligned());
- for (int i = 0; i < _menuOptions.Length; i++)
- {
- _tblMainMenu.AddRow($"[white]{i + 1}[/]", $"[yellow]{_menuOptions[i]}[/]");
- }
- _tblMainMenu.Alignment(Justify.Center);
- _controller = controller;
- // Default to this datetime format if external settings can't be loaded.
- DATETIME_FORMAT = appSettings.DateTimeFormat ?? "dd-MM-yy HH:mm";
- }
-
- public void DisplayView()
- {
- int selectedValue = 0;
- do
- {
- Console.Clear();
- AnsiConsole.Write(_figletAppTitle);
- AnsiConsole.Write(new Text("M A I N M E N U").Centered());
- AnsiConsole.Write(_tblMainMenu);
- selectedValue = CommonUI.MenuOption($"Enter a value between 1 and {_menuOptions.Length}: ", 1, _menuOptions.Length);
- ProcessMainMenu(selectedValue);
- } while (selectedValue != QUIT_APPLICATION_OPTION_NUM);
- AnsiConsole.MarkupLine("[lime]Goodbye![/]");
- }
-
- private void ProcessMainMenu(int option)
- {
- AnsiConsole.Markup($"[lightslategrey]Menu option selected: {option}[/]\n");
- switch (option)
- {
- case 1:
- // Add new exercise session
- AddNewExerciseSession();
- break;
- case 2:
- // Update an existing exercise session
- UpdateExistingExerciseSession();
- break;
- case 3:
- // Delete existing exercise session
- DeleteExistingExerciseSession();
- break;
- case 4:
- // List all exercise sessions
- ListAllExerciseSessions(true);
- CommonUI.Pause("grey53");
- break;
- }
- }
-
- private void AddNewExerciseSession()
- {
- ExerciseSessionInputDto? newSession = GetExerciseSessionDetails();
- if (newSession != null)
- {
- DisplayExerciseSessionInput(newSession);
- if (AnsiConsole.Confirm("Are you sure you want to add this exercise session?"))
- {
- var response = _controller.AddNewExerciseSession(newSession);
- if (response.Status.Equals(ResponseStatus.Success))
- AnsiConsole.MarkupLine($"[green]New exercise session added: '{response.Message}'[/]");
- else
- AnsiConsole.MarkupLine($"[red]Exercise addition failed: '{response.Message}'[/]");
- }
- else
- AnsiConsole.MarkupLine("\n[yellow]Operation cancelled[/]\n");
- }
- else
- {
- AnsiConsole.MarkupLine("\n[yellow]Operation cancelled[/]\n");
- }
- CommonUI.Pause("grey53");
- }
- private void UpdateExistingExerciseSession()
- {
- List? sessions = ListAllExerciseSessions(false);
- if (sessions != null)
- {
- int selectedSession = CommonUI.MenuOption("(Enter '0' to cancel)\nPlease select an exercise session ID to update: ", 0, sessions.Count);
- if (selectedSession == 0)
- {
- AnsiConsole.MarkupLine("[yellow]Operation cancelled[/]");
- }
- else
- {
- AnsiConsole.MarkupLine($"Selected session: {selectedSession}");
- var updateSession = sessions[selectedSession - 1];
- DisplayExerciseSessionOutput(updateSession);
- if (AnsiConsole.Confirm("Are you sure you want to update this exercise session?"))
- {
- ExerciseSessionInputDto? newSession = GetExerciseSessionDetails();
- if (newSession != null)
- {
- newSession.Id = updateSession.Id;
- var response = _controller.UpdateExistingExerciseSession(updateSession.Id, newSession);
- if (response.Status.Equals(ResponseStatus.Success))
- {
- AnsiConsole.MarkupLine($"[green]Exercise session updated: '{response.Message}'[/]");
- var updatedSession = response.Data as ExerciseSessionOutputDto;
- if (updatedSession != null)
- {
- DisplayExerciseSessionOutput(updatedSession);
- }
- else
- AnsiConsole.MarkupLine("\n[yellow]Could not display updated exercise session[/]\n");
- }
- else
- AnsiConsole.MarkupLine($"[red]Exercise session update failed: '{response.Message}'[/]");
- }
- else
- AnsiConsole.MarkupLine("\n[yellow]Operation cancelled[/]\n");
- }
- else
- AnsiConsole.MarkupLine("\n[yellow]Operation cancelled[/]\n");
- }
- }
- CommonUI.Pause("grey53");
- }
-
- private void DeleteExistingExerciseSession()
- {
- List? sessions = ListAllExerciseSessions(false);
- if (sessions != null)
- {
- int selectedSession = CommonUI.MenuOption("(Enter '0' to cancel)\nPlease select an exercise session ID to delete: ", 0, sessions.Count);
- if (selectedSession == 0)
- {
- AnsiConsole.MarkupLine("[yellow]Operation cancelled[/]");
- }
- else
- {
- AnsiConsole.MarkupLine($"Selected session: {selectedSession}");
- var deleteSession = sessions[selectedSession - 1];
- DisplayExerciseSessionOutput(deleteSession);
- if (AnsiConsole.Confirm("Are you sure you want to delete this exercise session?"))
- {
- var response = _controller.DeleteExistingExerciseSession(deleteSession.Id);
- if (response.Status.Equals(ResponseStatus.Success))
- AnsiConsole.MarkupLine($"[green]Exercise session deleted: '{response.Message}'[/]");
- else
- AnsiConsole.MarkupLine($"[red]Exercise session delete failed: '{response.Message}'[/]");
- }
- else
- AnsiConsole.MarkupLine("\n[yellow]Operation cancelled[/]\n");
- }
- }
- CommonUI.Pause("grey53");
- }
-
- private ExerciseSessionInputDto? GetExerciseSessionDetails()
- {
- bool isValidSession = false;
- ExerciseType exerciseType;
- DateTime startDateTime, endDateTime;
- string? comments;
- do
- {
- // Get exercise types from the public enum.
- exerciseType = CommonUI.GetExerciseTypeDialog(new List { ExerciseType.HIKING, ExerciseType.CARDIO });
- AnsiConsole.MarkupLine($"\n[white]SELECTED: {exerciseType.ToString()}[/]");
- // Get session start
- AnsiConsole.Markup("\n[white]Enter the start of the exercise session[/]\n");
- startDateTime = CommonUI.GetDateTimeDialog(DATETIME_FORMAT) ?? DateTime.MinValue;
- if (startDateTime == DateTime.MinValue) return null;
- // Get session end
- AnsiConsole.Markup("\n[white]Enter the end of the exercise session[/]\n");
- endDateTime = CommonUI.GetDateTimeDialog(DATETIME_FORMAT) ?? DateTime.MinValue;
- if (endDateTime == DateTime.MinValue) return null;
- // Validate session datetimes
- isValidSession = Validation.ValidateDatesForDuration(startDateTime, endDateTime);
- // Any other comments
- comments = CommonUI.GetStringWithPrompt("Enter any other comments (enter 'n' for none): ", 255, "n");
- if (comments == null) return null;
- if (comments.ToLower().Equals("n")) comments = null;
- if (!isValidSession)
- AnsiConsole.MarkupLine("\n[yellow]The exercise session end cannot be before session start. Try again.[/]\n");
- } while (!isValidSession);
- var newSession = new ExerciseSessionInputDto
- {
- Type = exerciseType.ToString().ToUpper(),
- DateTimeStart = startDateTime,
- DateTimeEnd = endDateTime,
- Comments = comments
- };
- return newSession;
- }
-
- private void DisplayExerciseSessionInput(ExerciseSessionInputDto exerciseSession)
- {
- Table tblSession = new Table();
- tblSession.AddColumn(new TableColumn("[cyan]ID[/]").RightAligned());
- tblSession.AddColumn(new TableColumn($"[white]1[/]").LeftAligned());
- tblSession.AddRow($"[cyan]Type[/]", $"[white]{exerciseSession.Type.ToString().ToUpper()}[/]");
- tblSession.AddRow($"[cyan]Start Time[/]", $"[white]{exerciseSession.DateTimeStart.ToString(DATETIME_FORMAT)}[/]");
- tblSession.AddRow($"[cyan]End Time[/]", $"[white]{exerciseSession.DateTimeEnd.ToString(DATETIME_FORMAT)}[/]");
- tblSession.AddRow($"[cyan]Comments[/]", $"[white]{exerciseSession.Comments ?? "NONE"}[/]");
- AnsiConsole.Write(tblSession);
- }
-
- private void DisplayExerciseSessionOutput(ExerciseSessionOutputDto exerciseSession)
- {
- Table tblSession = new Table();
- tblSession.AddColumn(new TableColumn("[cyan]ID[/]").RightAligned());
- tblSession.AddColumn(new TableColumn($"[white]{exerciseSession.DisplayId}[/]").LeftAligned());
- tblSession.AddRow($"[cyan]Type[/]", $"[white]{exerciseSession.Type.ToString().ToUpper()}[/]");
- tblSession.AddRow($"[cyan]Start Time[/]", $"[white]{exerciseSession.DateTimeStart.ToString(DATETIME_FORMAT)}[/]");
- tblSession.AddRow($"[cyan]End Time[/]", $"[white]{exerciseSession.DateTimeEnd.ToString(DATETIME_FORMAT)}[/]");
- tblSession.AddRow($"[cyan]Duration[/]", $"[white]{exerciseSession.Duration.ToString(@"hh\:mm")}[/]");
- tblSession.AddRow($"[cyan]Comments[/]", $"[white]{exerciseSession.Comments ?? "NONE"}[/]");
- AnsiConsole.Write(tblSession);
- }
-
- private List? ListAllExerciseSessions(bool showTotals)
- {
- var response = _controller.GetAllExerciseSessions();
- if (response.Status.Equals(ResponseStatus.Success))
- {
- List? displaySessions = response.Data as List;
- if (displaySessions != null && displaySessions.Count > 0)
- {
- DisplayExerciseSessions(displaySessions, showTotals);
- return displaySessions;
- }
- else
- {
- AnsiConsole.MarkupLine($"[red]There are no exercise sessions to display[/]");
- }
- }
- else
- AnsiConsole.MarkupLine($"[red]{response.Message}[/]");
- return null;
- }
-
- private void DisplayExerciseSessions(List? sessions, bool showTotal)
- {
- TimeSpan totalDuration = TimeSpan.Zero;
- if (sessions == null || !sessions.Any()) return;
- Table sessionsTable = new Table();
- sessionsTable.AddColumn(new TableColumn("[white]ID[/]").Centered());
- sessionsTable.AddColumn(new TableColumn("[white]Type[/]").LeftAligned());
- sessionsTable.AddColumn(new TableColumn("[white]Session Start[/]").LeftAligned());
- sessionsTable.AddColumn(new TableColumn("[white]Session End[/]").LeftAligned());
- sessionsTable.AddColumn(new TableColumn("[white]Comments[/]").LeftAligned());
- sessionsTable.AddColumn(new TableColumn("[white]Duration[/]").LeftAligned());
- sessionsTable.Alignment(Justify.Center);
- foreach (var session in sessions)
- {
- var displayId = session.DisplayId.ToString();
- var Type = session.Type.ToString().ToUpper() ?? "UNKNOWN";
- var sessionStart = session.DateTimeStart.ToString(DATETIME_FORMAT);
- var sessionEnd = session.DateTimeEnd.ToString(DATETIME_FORMAT);
- var sessionDuration = session.Duration.ToString(@"hh\:mm");
- var sesseionComments = session.Comments ?? "N/A";
- totalDuration += session.Duration;
- sessionsTable.AddRow(
- displayId,
- Type,
- sessionStart,
- sessionEnd,
- sesseionComments,
- sessionDuration
- );
- }
- if (showTotal)
- {
- sessionsTable.AddRow("");
- sessionsTable.AddRow("", "", "", "", "[yellow]Total Duration[/]", $"[cyan]{totalDuration.ToString(@"hh\:mm")}[/]");
- }
- AnsiConsole.Write(sessionsTable);
- }
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour.sln b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour.sln
deleted file mode 100644
index f55061f8..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour.sln
+++ /dev/null
@@ -1,25 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.8.34511.84
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "STUDY.ConsoleProjects.ExerciseTrackerFour", "STUDY.ConsoleProjects.ExerciseTrackerFour\STUDY.ConsoleProjects.ExerciseTrackerFour.csproj", "{9451B8FD-FB8E-4655-87ED-72371F521C43}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {9451B8FD-FB8E-4655-87ED-72371F521C43}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {9451B8FD-FB8E-4655-87ED-72371F521C43}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {9451B8FD-FB8E-4655-87ED-72371F521C43}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {9451B8FD-FB8E-4655-87ED-72371F521C43}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ExtensibilityGlobals) = postSolution
- SolutionGuid = {733AF67A-5B55-41A9-A937-ED5EA1BD04A7}
- EndGlobalSection
-EndGlobal
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Controller/ExerciseController.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Controller/ExerciseController.cs
deleted file mode 100644
index 03cf55d9..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Controller/ExerciseController.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-using Spectre.Console;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data.Repository;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Controller;
-public class ExerciseController
-{
- private readonly IExerciseService _exerciseService;
- private readonly IExerciseRepository _exerciseRepository;
- public ExerciseController(IExerciseService exerciseService, IExerciseRepository exerciseRepository)
- {
- _exerciseService = exerciseService;
- _exerciseRepository = exerciseRepository;
- }
- public void ViewAllExerciseEntries()
- {
- var exercises = _exerciseRepository.GetExercises();
-
- if (exercises.Count == 0)
- {
- AnsiConsole.MarkupLine("404 - Cannot be found");
- MainMenu.ShowMainMenu();
- }
-
- else
- {
- DataVisualization.ShowDataInTable(exercises);
- }
-
- Console.WriteLine("View All Exercise Entries completed");
- }
- public void ViewSpecificExerciseEntry()
- {
- Console.WriteLine("Enter the ID of the exercise entry you want to view:");
- int exerciseId = int.Parse(Console.ReadLine());
-
- Exercise? selectedExercise = _exerciseRepository.GetExerciseEntryById(exerciseId);
-
- if (selectedExercise is null)
- {
- AnsiConsole.MarkupLine("404 - Cannot be found");
- MainMenu.ShowMainMenu();
- }
-
- Exercise exercise = _exerciseRepository.ViewSpecificExerciseEntry(exerciseId);
-
- DataVisualization.ShowSingleExercise(exercise);
- }
- public void AddExerciseEntry()
- {
- _exerciseService.AddExerciseEntry();
- }
- public void UpdateExerciseEntry()
- {
- _exerciseService.UpdateExerciseEntry();
- }
- public void DeleteExerciseEntry()
- {
- _exerciseService.DeleteExerciseEntry();
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/ExerciseDbContext.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/ExerciseDbContext.cs
deleted file mode 100644
index ac73b7f5..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/ExerciseDbContext.cs
+++ /dev/null
@@ -1,16 +0,0 @@
-using Microsoft.EntityFrameworkCore;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Data;
-public class ExerciseDbContext : DbContext
-{
- public DbSet Exercises { get; set; }
- protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
- {
- optionsBuilder.UseSqlServer("Data Source=(LocalDB)\\LocalDBDemo;Database=exerciseTrackerDb;Trusted_Connection=True;TrustServerCertificate=True;");
- }
- protected override void OnModelCreating(ModelBuilder modelBuilder)
- {
- base.OnModelCreating(modelBuilder);
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/ExerciseRepository.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/ExerciseRepository.cs
deleted file mode 100644
index 5aed6f50..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/ExerciseRepository.cs
+++ /dev/null
@@ -1,47 +0,0 @@
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Data.Repository;
-public class ExerciseRepository : IExerciseRepository
-{
- private readonly ExerciseDbContext _context;
- public ExerciseRepository(ExerciseDbContext context)
- {
- _context = context;
- }
- public void AddExerciseEntry(Exercise exercise)
- {
- _context.Exercises.Add(exercise);
- _context.SaveChanges();
- }
- public void DeleteExerciseEntry(int exerciseId)
- {
- var exercise = _context.Exercises.Find(exerciseId);
- _context.Exercises.Remove(exercise);
- _context.SaveChanges();
- }
- public void UpdateExerciseEntry(int exerciseId, Exercise newExercise)
- {
- var oldExercise = _context.Exercises.Find(exerciseId);
-
- oldExercise.StarTime = newExercise.StarTime;
- oldExercise.EndTime = newExercise.EndTime;
- oldExercise.Duration = newExercise.Duration;
- oldExercise.Comments = newExercise.Comments;
-
- _context.SaveChanges();
- }
- public Exercise ViewSpecificExerciseEntry(int exerciseId)
- {
- var exercise = _context.Exercises.FirstOrDefault(e => e.Id == exerciseId);
-
- return exercise;
- }
- public Exercise GetExerciseEntryById(int exerciseId)
- {
- return _context.Exercises.Find(exerciseId)!;
- }
- public List GetExercises()
- {
- return _context.Exercises.ToList();
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/IExerciseRepository.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/IExerciseRepository.cs
deleted file mode 100644
index b3295fea..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Data/Repository/IExerciseRepository.cs
+++ /dev/null
@@ -1,12 +0,0 @@
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Data.Repository;
-public interface IExerciseRepository
-{
- public Exercise ViewSpecificExerciseEntry(int exerciseId);
- void AddExerciseEntry(Exercise exercise);
- void UpdateExerciseEntry(int exerciseId, Exercise newExercise);
- void DeleteExerciseEntry(int exerciseId);
- public Exercise GetExerciseEntryById(int exerciseId);
- public List GetExercises();
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/DataVisualization.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/DataVisualization.cs
deleted file mode 100644
index fe4b1896..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/DataVisualization.cs
+++ /dev/null
@@ -1,32 +0,0 @@
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour;
-internal class DataVisualization
-{
- public static void ShowDataInTable(List exercises, bool isSingle = false)
- {
- if (isSingle)
- {
- var exercise = exercises[0];
- ShowSingleExercise(exercise);
- }
- else
- {
- foreach (var exercise in exercises)
- {
- ShowSingleExercise(exercise);
- }
- }
- }
- public static void ShowSingleExercise(Exercise exercise)
- {
- TimeSpan duration = exercise.EndTime - exercise.StarTime;
- Console.WriteLine($@"
- Id: {exercise.Id},
- StartTime: {exercise.StarTime},
- EndTime: {exercise.EndTime},
- Duration: {duration},
- Comments: {exercise.Comments}
- ");
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/MainMenu.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/MainMenu.cs
deleted file mode 100644
index 8d30d277..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/MainMenu.cs
+++ /dev/null
@@ -1,66 +0,0 @@
-using Spectre.Console;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Controller;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data.Repository;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour;
-internal class MainMenu
-{
- public enum MenuOption
- {
- ViewAllExerciseEntries,
- ViewSpecificExerciseEntry,
- AddExerciseEntry,
- UpdateExerciseEntry,
- DeleteExerciseEntry,
- Quit
- }
- public static void ShowMainMenu()
- {
- var exerciseContext = new ExerciseDbContext();
- var exerciseRepository = new ExerciseRepository(exerciseContext);
- var userInput = new UserInput();
- var exerciseService = new ExerciseService(exerciseRepository, userInput);
- var exerciseController = new ExerciseController(exerciseService, exerciseRepository);
-
- while (true)
- {
- var choice = AnsiConsole.Prompt(
- new SelectionPrompt()
- .Title("What would you like to do?")
- .AddChoices(
- MenuOption.ViewAllExerciseEntries,
- MenuOption.ViewSpecificExerciseEntry,
- MenuOption.AddExerciseEntry,
- MenuOption.UpdateExerciseEntry,
- MenuOption.DeleteExerciseEntry,
- MenuOption.Quit));
-
- switch (choice)
- {
- case MenuOption.ViewAllExerciseEntries:
- exerciseController.ViewAllExerciseEntries();
- break;
- case MenuOption.ViewSpecificExerciseEntry:
- exerciseController.ViewSpecificExerciseEntry();
- break;
- case MenuOption.AddExerciseEntry:
- exerciseController.AddExerciseEntry();
- break;
- case MenuOption.UpdateExerciseEntry:
- exerciseController.UpdateExerciseEntry();
- break;
- case MenuOption.DeleteExerciseEntry:
- exerciseController.DeleteExerciseEntry();
- break;
- case MenuOption.Quit:
- Environment.Exit(0);
- break;
- default:
- AnsiConsole.WriteLine("Invalid choice. Please try again.");
- break;
- }
- }
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.Designer.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.Designer.cs
deleted file mode 100644
index cbba33c2..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.Designer.cs
+++ /dev/null
@@ -1,56 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data;
-
-#nullable disable
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- [Migration("20240519223411_Initial-Create")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.4")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("STUDY.ConsoleProjects.ExerciseTrackerFour.Models.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Duration")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("EndTime")
- .HasColumnType("datetime2");
-
- b.Property("StarTime")
- .HasColumnType("datetime2");
-
- b.HasKey("Id");
-
- b.ToTable("Exercises");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.cs
deleted file mode 100644
index d1069b30..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/20240519223411_Initial-Create.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Exercises",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- StarTime = table.Column(type: "datetime2", nullable: false),
- EndTime = table.Column(type: "datetime2", nullable: false),
- Duration = table.Column(type: "nvarchar(max)", nullable: false),
- Comments = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Exercises", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Exercises");
- }
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/ExerciseDbContextModelSnapshot.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/ExerciseDbContextModelSnapshot.cs
deleted file mode 100644
index bb830b0d..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Migrations/ExerciseDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,53 +0,0 @@
-//
-using System;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data;
-
-#nullable disable
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Migrations
-{
- [DbContext(typeof(ExerciseDbContext))]
- partial class ExerciseDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.4")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("STUDY.ConsoleProjects.ExerciseTrackerFour.Models.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasColumnType("nvarchar(max)");
-
- b.Property("Duration")
- .IsRequired()
- .HasColumnType("nvarchar(max)");
-
- b.Property("EndTime")
- .HasColumnType("datetime2");
-
- b.Property("StarTime")
- .HasColumnType("datetime2");
-
- b.HasKey("Id");
-
- b.ToTable("Exercises");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Models/Exercise.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Models/Exercise.cs
deleted file mode 100644
index d30c6197..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Models/Exercise.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-public class Exercise
-{
- public int Id { get; set; }
- public DateTime StarTime { get; set; }
- public DateTime EndTime { get; set; }
- public string Duration { get; set; } = null!;
- public string? Comments { get; set; }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Program.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Program.cs
deleted file mode 100644
index e609dab7..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Program.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour;
-internal class Program
-{
- public static void Main(string[] args)
- {
- MainMenu.ShowMainMenu();
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Properties/launchSettings.json b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Properties/launchSettings.json
deleted file mode 100644
index b87a31ba..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Properties/launchSettings.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
- "profiles": {
- "STUDY.ConsoleProjects.ExerciseTrackerFour": {
- "commandName": "Project",
- "workingDirectory": "C:\\MEGA\\WIP\\02-GitWIP\\CodeReviews.Console.ExerciseTracker\\ExerciseTracker.Bata13"
- }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/STUDY.ConsoleProjects.ExerciseTrackerFour.csproj b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/STUDY.ConsoleProjects.ExerciseTrackerFour.csproj
deleted file mode 100644
index bbd3db80..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/STUDY.ConsoleProjects.ExerciseTrackerFour.csproj
+++ /dev/null
@@ -1,22 +0,0 @@
-
-
-
- Exe
- net8.0
- enable
- enable
-
-
-
-
-
-
- all
- runtime; build; native; contentfiles; analyzers; buildtransitive
-
-
-
-
-
-
-
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/ExerciseService.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/ExerciseService.cs
deleted file mode 100644
index 8d726cca..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/ExerciseService.cs
+++ /dev/null
@@ -1,77 +0,0 @@
-using Spectre.Console;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Data.Repository;
-using STUDY.ConsoleProjects.ExerciseTrackerFour.Models;
-
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-public class ExerciseService : IExerciseService
-{
- private readonly IExerciseRepository _exerciseRepository;
- private readonly IUserInput _UserInput;
- public ExerciseService(IExerciseRepository exerciseRepository, IUserInput userInput)
- {
- _exerciseRepository = exerciseRepository;
- _UserInput = userInput;
- }
- public void AddExerciseEntry()
- {
- var (startTime, endTime, duration, comments) = _UserInput.GetUserInputForExcerciseEntry();
-
- Exercise exercise = new Exercise
- {
- StarTime = startTime,
- EndTime = endTime,
- Duration = duration.ToString(@"hh\:mm\:ss"),
- Comments = comments
- };
-
- _exerciseRepository.AddExerciseEntry(exercise);
-
- Console.WriteLine("Added Exercise Entry");
- }
- public void UpdateExerciseEntry()
- {
- Console.WriteLine("Enter the ID of the exercise entry you want to Update:");
- int checkExerciseId = int.Parse(Console.ReadLine());
-
- Exercise? selectedExercise = _exerciseRepository.GetExerciseEntryById(checkExerciseId);
-
- if (selectedExercise is null)
- {
- AnsiConsole.MarkupLine("404 - Cannot be found");
- MainMenu.ShowMainMenu();
- }
-
- var (newStartTime, newEndTime, newDuration, newComments, exerciseId) = _UserInput.GetUserInputForUpdatedExcerciseEntry();
-
- Exercise newExercise = new Exercise
- {
- StarTime = newStartTime,
- EndTime = newEndTime,
- Duration = newDuration.ToString(@"hh\:mm\:ss"),
- Comments = newComments
- };
-
- _exerciseRepository.UpdateExerciseEntry(exerciseId, newExercise);
-
- Console.WriteLine($"Exercise entry with ID {exerciseId} updated successfully.");
- }
- public void DeleteExerciseEntry()
- {
- Console.WriteLine("Enter the ID of the exercise entry you want to Delete:");
- int checkExerciseId = int.Parse(Console.ReadLine());
-
- Exercise? selectedExercise = _exerciseRepository.GetExerciseEntryById(checkExerciseId);
-
- if (selectedExercise is null)
- {
- AnsiConsole.MarkupLine("404 - Cannot be found");
- MainMenu.ShowMainMenu();
- }
-
- int exerciseId = _UserInput.GetUserInputToDelete();
-
- _exerciseRepository.DeleteExerciseEntry(exerciseId);
-
- Console.WriteLine($"Exercise entry with ID {exerciseId} deleted successfully.");
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IExerciseService.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IExerciseService.cs
deleted file mode 100644
index 34793fcd..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IExerciseService.cs
+++ /dev/null
@@ -1,7 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-public interface IExerciseService
-{
- void AddExerciseEntry();
- void UpdateExerciseEntry();
- void DeleteExerciseEntry();
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IUserInput.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IUserInput.cs
deleted file mode 100644
index 55148aec..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/IUserInput.cs
+++ /dev/null
@@ -1,8 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-public interface IUserInput
-{
- (DateTime startTime, DateTime endTime, TimeSpan duration, string comments) GetUserInputForExcerciseEntry();
-
- (DateTime newStartTime, DateTime newEndTime, TimeSpan newDuration, string newComments, int exerciseId) GetUserInputForUpdatedExcerciseEntry();
- int GetUserInputToDelete();
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/UserInput.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/UserInput.cs
deleted file mode 100644
index 53ea1705..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Service/UserInput.cs
+++ /dev/null
@@ -1,85 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour.Service;
-public class UserInput : IUserInput
-{
- public (DateTime startTime, DateTime endTime, TimeSpan duration, string comments) GetUserInputForExcerciseEntry()
- {
- Console.WriteLine("Enter the new start time (yyyy-MM-dd HH:mm:ss):");
- DateTime startTime;
-
- while (!DateTime.TryParseExact(Console.ReadLine(), "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out startTime))
- {
- Console.WriteLine("Invalid input. Please enter a valid start time (yyyy-MM-dd HH:mm:ss):");
- }
-
- Console.WriteLine("Enter the new end time (yyyy-MM-dd HH:mm:ss):");
-
- DateTime endTime;
-
- while (!DateTime.TryParseExact(Console.ReadLine(), "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out endTime))
- {
- Console.WriteLine("Invalid input. Please enter a valid end time (yyyy-MM-dd HH:mm:ss):");
- }
-
- Console.WriteLine("Enter the end time of the exercise (yyyy-MM-dd HH:mm:ss):");
-
- Console.WriteLine("Enter Any Comments");
- string comments = Console.ReadLine();
-
- TimeSpan duration = endTime - startTime;
-
- Validation.isEndTimeBeforeStartTime(startTime, endTime);
- Validation.isPositiveNumber(startTime, endTime);
-
- return (startTime, endTime, duration, comments);
- }
- public (DateTime newStartTime, DateTime newEndTime, TimeSpan newDuration, string newComments, int exerciseId) GetUserInputForUpdatedExcerciseEntry()
- {
- Console.WriteLine("Enter the ID of the exercise entry you want to update:");
-
- int exerciseId;
-
- while (!int.TryParse(Console.ReadLine(), out exerciseId))
- {
- Console.WriteLine("Invalid input. Please enter a valid ID:");
- }
-
- Console.WriteLine("Enter the new start time (yyyy-MM-dd HH:mm:ss):");
-
- DateTime newStartTime;
-
- while (!DateTime.TryParseExact(Console.ReadLine(), "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out newStartTime))
- {
- Console.WriteLine("Invalid input. Please enter a valid start time (yyyy-MM-dd HH:mm:ss):");
- }
-
- Console.WriteLine("Enter the new end time (yyyy-MM-dd HH:mm:ss):");
-
- DateTime newEndTime;
-
- while (!DateTime.TryParseExact(Console.ReadLine(), "yyyy-MM-dd HH:mm:ss", null, System.Globalization.DateTimeStyles.None, out newEndTime))
- {
- Console.WriteLine("Invalid input. Please enter a valid end time (yyyy-MM-dd HH:mm:ss):");
- }
-
- Console.WriteLine("Enter Any Comments");
- string newComments = Console.ReadLine();
-
- TimeSpan newDuration = newEndTime - newStartTime;
-
- Validation.isEndTimeBeforeStartTime(newStartTime, newEndTime);
- Validation.isPositiveNumber(newStartTime, newEndTime);
-
- return (newStartTime, newEndTime, newDuration, newComments, exerciseId);
- }
- public int GetUserInputToDelete()
- {
- Console.WriteLine("Enter the ID of the exercise entry you want to delete:");
- int exerciseId;
- while (!int.TryParse(Console.ReadLine(), out exerciseId))
- {
- Console.WriteLine("Invalid input. Please enter a valid ID:");
- }
-
- return (exerciseId);
- }
-}
diff --git a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Validation.cs b/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Validation.cs
deleted file mode 100644
index f6fed9ef..00000000
--- a/ExerciseTracker.Bata13/STUDY.ConsoleProjects.ExerciseTrackerFour/Validation.cs
+++ /dev/null
@@ -1,36 +0,0 @@
-namespace STUDY.ConsoleProjects.ExerciseTrackerFour;
-public class Validation
-{
- public static void isEndTimeBeforeStartTime(DateTime startTimeInput, DateTime endTimeInput)
- {
- if (endTimeInput < startTimeInput)
- {
- Console.WriteLine("Not in chronological order");
- Console.WriteLine("Going Back To The Main Menu");
- MainMenu.ShowMainMenu();
- }
- else
- {
- Console.WriteLine("Correctly in chronological order");
- }
- }
- public static void isPositiveNumber(DateTime startTimeInput, DateTime endTimeInput)
- {
- if (endTimeInput < DateTime.MinValue)
- {
- Console.WriteLine("Date and time cannot be negative");
- Console.WriteLine("Going Back To The Main Menu");
- MainMenu.ShowMainMenu();
- }
- else if (startTimeInput < DateTime.MinValue)
- {
- Console.WriteLine("Date and time cannot be negative");
- Console.WriteLine("Going Back To The Main Menu");
- MainMenu.ShowMainMenu();
- }
- else
- {
- Console.WriteLine("Correctly in positive number");
- }
- }
-}
diff --git a/ExerciseTracker.Bkohler93/Data/Data.csproj b/ExerciseTracker.Bkohler93/Data/Data.csproj
deleted file mode 100644
index 8a5dee05..00000000
--- a/ExerciseTracker.Bkohler93/Data/Data.csproj
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
- net8.0
- enable
- enable
-
-
-
-
-
-
-
diff --git a/ExerciseTracker.Bkohler93/Data/Entities/Exercise.cs b/ExerciseTracker.Bkohler93/Data/Entities/Exercise.cs
deleted file mode 100644
index 1335381e..00000000
--- a/ExerciseTracker.Bkohler93/Data/Entities/Exercise.cs
+++ /dev/null
@@ -1,9 +0,0 @@
-namespace Data.Entities;
-
-public class Exercise {
- public int Id { get; set; }
- public DateTime DateStart { get; set; }
- public DateTime DateEnd { get; set; }
- public TimeSpan Duration { get; set; }
- public string? Comments { get; set; }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/Data/ExerciseEFDbContext.cs b/ExerciseTracker.Bkohler93/Data/ExerciseEFDbContext.cs
deleted file mode 100644
index d68b56b9..00000000
--- a/ExerciseTracker.Bkohler93/Data/ExerciseEFDbContext.cs
+++ /dev/null
@@ -1,13 +0,0 @@
-using Data.Entities;
-using Microsoft.EntityFrameworkCore;
-
-namespace Data;
-
-public class ExerciseEFDbContext : DbContext
-{
- public DbSet Runs { get; set; }
- public ExerciseEFDbContext(DbContextOptions options):base(options)
- {
-
- }
-}
diff --git a/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.Designer.cs b/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.Designer.cs
deleted file mode 100644
index 8ac4ba14..00000000
--- a/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.Designer.cs
+++ /dev/null
@@ -1,55 +0,0 @@
-//
-using System;
-using Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Migrations;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Data.Migrations
-{
- [DbContext(typeof(ExerciseEFDbContext))]
- [Migration("20240804040335_InitialCreate")]
- partial class InitialCreate
- {
- ///
- protected override void BuildTargetModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.7")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Data.Entities.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.HasKey("Id");
-
- b.ToTable("Runs");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.cs b/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.cs
deleted file mode 100644
index 2f0182e9..00000000
--- a/ExerciseTracker.Bkohler93/Data/Migrations/20240804040335_InitialCreate.cs
+++ /dev/null
@@ -1,38 +0,0 @@
-using System;
-using Microsoft.EntityFrameworkCore.Migrations;
-
-#nullable disable
-
-namespace Data.Migrations
-{
- ///
- public partial class InitialCreate : Migration
- {
- ///
- protected override void Up(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.CreateTable(
- name: "Runs",
- columns: table => new
- {
- Id = table.Column(type: "int", nullable: false)
- .Annotation("SqlServer:Identity", "1, 1"),
- DateStart = table.Column(type: "datetime2", nullable: false),
- DateEnd = table.Column(type: "datetime2", nullable: false),
- Duration = table.Column(type: "time", nullable: false),
- Comments = table.Column(type: "nvarchar(max)", nullable: true)
- },
- constraints: table =>
- {
- table.PrimaryKey("PK_Runs", x => x.Id);
- });
- }
-
- ///
- protected override void Down(MigrationBuilder migrationBuilder)
- {
- migrationBuilder.DropTable(
- name: "Runs");
- }
- }
-}
diff --git a/ExerciseTracker.Bkohler93/Data/Migrations/ExerciseDbContextModelSnapshot.cs b/ExerciseTracker.Bkohler93/Data/Migrations/ExerciseDbContextModelSnapshot.cs
deleted file mode 100644
index 525138f3..00000000
--- a/ExerciseTracker.Bkohler93/Data/Migrations/ExerciseDbContextModelSnapshot.cs
+++ /dev/null
@@ -1,52 +0,0 @@
-//
-using System;
-using Data;
-using Microsoft.EntityFrameworkCore;
-using Microsoft.EntityFrameworkCore.Infrastructure;
-using Microsoft.EntityFrameworkCore.Metadata;
-using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
-
-#nullable disable
-
-namespace Data.Migrations
-{
- [DbContext(typeof(ExerciseEFDbContext))]
- partial class ExerciseDbContextModelSnapshot : ModelSnapshot
- {
- protected override void BuildModel(ModelBuilder modelBuilder)
- {
-#pragma warning disable 612, 618
- modelBuilder
- .HasAnnotation("ProductVersion", "8.0.7")
- .HasAnnotation("Relational:MaxIdentifierLength", 128);
-
- SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);
-
- modelBuilder.Entity("Data.Entities.Exercise", b =>
- {
- b.Property("Id")
- .ValueGeneratedOnAdd()
- .HasColumnType("int");
-
- SqlServerPropertyBuilderExtensions.UseIdentityColumn(b.Property("Id"));
-
- b.Property("Comments")
- .HasColumnType("nvarchar(max)");
-
- b.Property("DateEnd")
- .HasColumnType("datetime2");
-
- b.Property("DateStart")
- .HasColumnType("datetime2");
-
- b.Property("Duration")
- .HasColumnType("time");
-
- b.HasKey("Id");
-
- b.ToTable("Runs");
- });
-#pragma warning restore 612, 618
- }
- }
-}
diff --git a/ExerciseTracker.Bkohler93/Data/Repositories/EFRepository.cs b/ExerciseTracker.Bkohler93/Data/Repositories/EFRepository.cs
deleted file mode 100644
index 8cd1b4cb..00000000
--- a/ExerciseTracker.Bkohler93/Data/Repositories/EFRepository.cs
+++ /dev/null
@@ -1,72 +0,0 @@
-using Data.Entities;
-using Microsoft.EntityFrameworkCore;
-
-namespace Data.Repositories;
-
-public class EFRepository : IRepository where TEntity : class, new()
- {
- protected readonly ExerciseEFDbContext ExerciseDbContext;
-
- public EFRepository(ExerciseEFDbContext exerciseDbContext)
- {
- ExerciseDbContext = exerciseDbContext;
- }
-
- public IQueryable GetAll()
- {
- try
- {
- return ExerciseDbContext.Set();
- }
- catch (Exception ex)
- {
- throw new Exception($"Couldn't retrieve entities: {ex.Message}");
- }
- }
-
- public async Task AddAsync(TEntity entity)
- {
- if (entity == null)
- {
- throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
- }
-
- try
- {
- await ExerciseDbContext.AddAsync(entity);
- await ExerciseDbContext.SaveChangesAsync();
-
- return entity;
- }
- catch (Exception ex)
- {
- throw new Exception($"{nameof(entity)} could not be saved: {ex.Message}");
- }
- }
-
- public async Task UpdateAsync(TEntity entity)
- {
- if (entity == null)
- {
- throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null");
- }
-
- try
- {
- ExerciseDbContext.Update(entity);
- await ExerciseDbContext.SaveChangesAsync();
-
- return entity;
- }
- catch (Exception ex)
- {
- throw new Exception($"{nameof(entity)} could not be updated: {ex.Message}");
- }
- }
-
- public async Task DeleteAsync(TEntity entity)
- {
- ExerciseDbContext.Remove(entity);
- await ExerciseDbContext.SaveChangesAsync();
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/Data/Repositories/ExerciseEFRepository.cs b/ExerciseTracker.Bkohler93/Data/Repositories/ExerciseEFRepository.cs
deleted file mode 100644
index e11673af..00000000
--- a/ExerciseTracker.Bkohler93/Data/Repositories/ExerciseEFRepository.cs
+++ /dev/null
@@ -1,21 +0,0 @@
-using Data.Entities;
-using Microsoft.EntityFrameworkCore;
-
-namespace Data.Repositories;
-
-public class ExerciseEFRepository : EFRepository, IExerciseRepository
- {
- public ExerciseEFRepository(ExerciseEFDbContext exerciseDbContext) : base(exerciseDbContext)
- {
- }
-
- public Task> GetAllExercisesAsync()
- {
- return GetAll().ToListAsync();
- }
-
- public Task GetExerciseByIdAsync(int id)
- {
- return GetAll().FirstOrDefaultAsync(r => r.Id == id);
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IExerciseRepository.cs b/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IExerciseRepository.cs
deleted file mode 100644
index e8807d0b..00000000
--- a/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IExerciseRepository.cs
+++ /dev/null
@@ -1,10 +0,0 @@
-using Data.Entities;
-
-namespace Data.Repositories;
-
-public interface IExerciseRepository : IRepository
-{
- Task GetExerciseByIdAsync(int id);
-
- Task> GetAllExercisesAsync();
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IRepository.cs b/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IRepository.cs
deleted file mode 100644
index 80ae16b1..00000000
--- a/ExerciseTracker.Bkohler93/Data/Repositories/Interfaces/IRepository.cs
+++ /dev/null
@@ -1,11 +0,0 @@
-namespace Data.Repositories;
-
-public interface IRepository where TEntity : class, new()
-{
- IQueryable GetAll();
-
- Task AddAsync(TEntity entity);
-
- Task UpdateAsync(TEntity entity);
- Task DeleteAsync(TEntity entity);
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/ExerciseTracker.Bkohler93.sln b/ExerciseTracker.Bkohler93/ExerciseTracker.Bkohler93.sln
deleted file mode 100644
index 06114c9f..00000000
--- a/ExerciseTracker.Bkohler93/ExerciseTracker.Bkohler93.sln
+++ /dev/null
@@ -1,28 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 12.00
-# Visual Studio Version 17
-VisualStudioVersion = 17.0.31903.59
-MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ExerciseTracker.Console", "ExerciseTracker.Console\ExerciseTracker.Console.csproj", "{8AF9E851-572B-4AED-815F-A6243395FE02}"
-EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Data", "Data\Data.csproj", "{59183EDC-D2C5-417A-82C6-CFCBCE291665}"
-EndProject
-Global
- GlobalSection(SolutionConfigurationPlatforms) = preSolution
- Debug|Any CPU = Debug|Any CPU
- Release|Any CPU = Release|Any CPU
- EndGlobalSection
- GlobalSection(SolutionProperties) = preSolution
- HideSolutionNode = FALSE
- EndGlobalSection
- GlobalSection(ProjectConfigurationPlatforms) = postSolution
- {8AF9E851-572B-4AED-815F-A6243395FE02}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {8AF9E851-572B-4AED-815F-A6243395FE02}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {8AF9E851-572B-4AED-815F-A6243395FE02}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {8AF9E851-572B-4AED-815F-A6243395FE02}.Release|Any CPU.Build.0 = Release|Any CPU
- {59183EDC-D2C5-417A-82C6-CFCBCE291665}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {59183EDC-D2C5-417A-82C6-CFCBCE291665}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {59183EDC-D2C5-417A-82C6-CFCBCE291665}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {59183EDC-D2C5-417A-82C6-CFCBCE291665}.Release|Any CPU.Build.0 = Release|Any CPU
- EndGlobalSection
-EndGlobal
diff --git a/ExerciseTracker.Bkohler93/ExerciseTracker.Console/App.cs b/ExerciseTracker.Bkohler93/ExerciseTracker.Console/App.cs
deleted file mode 100644
index ac7b9c7d..00000000
--- a/ExerciseTracker.Bkohler93/ExerciseTracker.Console/App.cs
+++ /dev/null
@@ -1,29 +0,0 @@
-using ExerciseTracker.Controllers;
-
-namespace ExerciseTracker;
-
-public class App {
- private readonly MainMenuController Controller;
- public App(MainMenuController controller)
- {
- Controller = controller;
- }
-
- public async Task Run() {
- while(true)
- {
- UI.Clear();
- var option = UI.MenuSelection("[green]Exercise Tracker[/] Main Menu", [
- "Exit",
- ..MainMenuController.Options
- ]);
-
- if (option == "Exit")
- {
- break;
- }
-
- await Controller.HandleChoice(option);
- }
- }
-}
\ No newline at end of file
diff --git a/ExerciseTracker.Bkohler93/ExerciseTracker.Console/Controllers/MainMenuController.cs b/ExerciseTracker.Bkohler93/ExerciseTracker.Console/Controllers/MainMenuController.cs
deleted file mode 100644
index 724cf62c..00000000
--- a/ExerciseTracker.Bkohler93/ExerciseTracker.Console/Controllers/MainMenuController.cs
+++ /dev/null
@@ -1,98 +0,0 @@
-using Data.Entities;
-using ExerciseTracker.Services;
-using Microsoft.IdentityModel.Tokens;
-
-namespace ExerciseTracker.Controllers;
-
-public class MainMenuController {
- private readonly ExerciseService Service;
- public static readonly string[] Options = ["View logged exercises", "Log an exercise", "Edit a logged exercise", "Delete exercise log"];
- private readonly Dictionary> OptionHandlers;
- public MainMenuController(ExerciseService service)
- {
- Service = service;
- OptionHandlers = new Dictionary