fix upload bug (another one) where it goes to delete the old picture.
rename file.
This commit is contained in:
parent
7fbcba58ba
commit
af14e57725
@ -40,7 +40,7 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="IdDaemonTransponderUtilityFactory.cs" />
|
||||
<Compile Include="IrDaemonTransponderUtilityFactory.cs" />
|
||||
<Compile Include="IrDaemonCommunicator.cs" />
|
||||
<Compile Include="IrDaemonController.cs" />
|
||||
<Compile Include="IrDaemonControllerProviderFactory.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;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user