From af14e5772548fa6caa43d74812f0ff88f39d3c30 Mon Sep 17 00:00:00 2001 From: "chris.watts90@outlook.com" Date: Mon, 26 Jun 2017 16:47:04 +0100 Subject: [PATCH] fix upload bug (another one) where it goes to delete the old picture. rename file. --- .../IrDaemonNotifier/IrDaemonNotifier.csproj | 2 +- ...ctory.cs => IrDaemonTransponderUtilityFactory.cs} | 0 .../RaceLapTimer/ApiControllers/PilotApiModule.cs | 12 ++++++++++-- 3 files changed, 11 insertions(+), 3 deletions(-) rename RaceLapTimer/IrDaemonNotifier/{IdDaemonTransponderUtilityFactory.cs => IrDaemonTransponderUtilityFactory.cs} (100%) diff --git a/RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj b/RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj index e8b9ad1..1a56da8 100644 --- a/RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj +++ b/RaceLapTimer/IrDaemonNotifier/IrDaemonNotifier.csproj @@ -40,7 +40,7 @@ - + diff --git a/RaceLapTimer/IrDaemonNotifier/IdDaemonTransponderUtilityFactory.cs b/RaceLapTimer/IrDaemonNotifier/IrDaemonTransponderUtilityFactory.cs similarity index 100% rename from RaceLapTimer/IrDaemonNotifier/IdDaemonTransponderUtilityFactory.cs rename to RaceLapTimer/IrDaemonNotifier/IrDaemonTransponderUtilityFactory.cs diff --git a/RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs b/RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs index 28f2001..79da9d9 100644 --- a/RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs +++ b/RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs @@ -23,13 +23,21 @@ namespace RaceLapTimer.ApiControllers Post["/create"] = args => EditCreatePilot(); Get["/delete/{id}"] = args => DeletePilot(args); Post["/upload/{id}"] = args => UploadPicture(args); + Delete["/transponder/{id}"] = args => RemoveTransponderToken(args); + } + + private dynamic RemoveTransponderToken(dynamic args) + { + var pilotId = args.Id; + //_provider. + return Context.GetRedirect("/pilots"); } private dynamic UploadPicture(dynamic args) { var pilotId = args.Id; var pilot = (Pilot)_provider.GetPilot(pilotId); - var oldImagePath = pilot.ImageUrl; + var oldImageName = Path.GetFileName(pilot.ImageUrl); var uploadDirectory = Path.Combine(_rootPathProvider.GetRootPath(), "images"); @@ -57,7 +65,7 @@ namespace RaceLapTimer.ApiControllers pilot.ImageUrl = "/images/" + generatedFileName; _provider.UpdatePilot(pilot); - File.Delete(Path.Combine(uploadDirectory, oldImagePath)); + File.Delete(Path.Combine(uploadDirectory, oldImageName)); } string returnurl = "/pilot/edit/" + pilotId;