Move project to use NancyFx as Api controller in order to use the core dependency injection ability across the whole app.
should also make routing a damned sight easier!!!
This commit is contained in:
parent
ba91962eac
commit
834875aa5f
15
RaceLapTimer/Interfaces/CompetitionRace.cs
Normal file
15
RaceLapTimer/Interfaces/CompetitionRace.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public class CompetitionRace
|
||||
{
|
||||
public List<Pilot> Pilots { get; set; }
|
||||
public string Title { get; set; }
|
||||
public int MaxLaps { get; set; }
|
||||
public int NumberOfSatellites { get; set; }
|
||||
public int SatelliteTimePenaltyMicroS { get; set; }
|
||||
public bool HotSeatEnabled { get; set; }
|
||||
public int IdleTime { get; set; }
|
||||
}
|
||||
}
|
||||
13
RaceLapTimer/Interfaces/ConfigurationSetting.cs
Normal file
13
RaceLapTimer/Interfaces/ConfigurationSetting.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public class ConfigurationSetting
|
||||
{
|
||||
public string ConfigurationName { get; set; }
|
||||
public string ConfigurationValue { get; set; }
|
||||
}
|
||||
}
|
||||
@ -40,8 +40,13 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ConfigurationSetting.cs" />
|
||||
<Compile Include="CompetitionRace.cs" />
|
||||
<Compile Include="Pilot.cs" />
|
||||
<Compile Include="RaceSession.cs" />
|
||||
<Compile Include="IUserStorage.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="RaceMode.cs" />
|
||||
<Compile Include="User.cs" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
|
||||
10
RaceLapTimer/Interfaces/Pilot.cs
Normal file
10
RaceLapTimer/Interfaces/Pilot.cs
Normal file
@ -0,0 +1,10 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public class Pilot
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public int TransponderToken { get; set; }
|
||||
public string ThingyName { get; set; }
|
||||
public string TeamName { get; set; }
|
||||
}
|
||||
}
|
||||
8
RaceLapTimer/Interfaces/RaceMode.cs
Normal file
8
RaceLapTimer/Interfaces/RaceMode.cs
Normal file
@ -0,0 +1,8 @@
|
||||
namespace Interfaces
|
||||
{
|
||||
public enum RaceMode
|
||||
{
|
||||
STANDARD = 1,
|
||||
COMPETITION = 2
|
||||
}
|
||||
}
|
||||
24
RaceLapTimer/Interfaces/RaceSession.cs
Normal file
24
RaceLapTimer/Interfaces/RaceSession.cs
Normal file
@ -0,0 +1,24 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Interfaces
|
||||
{
|
||||
public class RaceSession
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
public string Title { get; set; }
|
||||
public bool Active { get; set; }
|
||||
public RaceMode Mode { get; set; }
|
||||
public int MaxLaps { get; set; }
|
||||
public DateTime DeletedAt { get; set; }
|
||||
public int SatelliteCount { get; set; }
|
||||
public int TimePenaltyPerSatellite { get; set; }
|
||||
public bool HotSeatEnabled { get; set; }
|
||||
public int IdleTimeSeconds { get; set; }
|
||||
}
|
||||
}
|
||||
12
RaceLapTimer/RaceLapTimer/ApiControllers/InfoApiModule.cs
Normal file
12
RaceLapTimer/RaceLapTimer/ApiControllers/InfoApiModule.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class InfoApiModule:NancyModule
|
||||
{
|
||||
public InfoApiModule() : base("/api/info")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,18 +0,0 @@
|
||||
using System;
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class InfoController:ApiController
|
||||
{
|
||||
/// <summary>
|
||||
/// returns the last transponder Id from the ir daemon.
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
[HttpGet]
|
||||
public IHttpActionResult LastScannedId()
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class LapTrackApiModule:NancyModule
|
||||
{
|
||||
public LapTrackApiModule() : base("/api/laptrack")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class LapTrackController:ApiController
|
||||
{
|
||||
}
|
||||
}
|
||||
12
RaceLapTimer/RaceLapTimer/ApiControllers/MonitorApiModule.cs
Normal file
12
RaceLapTimer/RaceLapTimer/ApiControllers/MonitorApiModule.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class MonitorApiModule:NancyModule
|
||||
{
|
||||
public MonitorApiModule() : base("api/monitor")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class MonitorController:ApiController
|
||||
{
|
||||
}
|
||||
}
|
||||
13
RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs
Normal file
13
RaceLapTimer/RaceLapTimer/ApiControllers/PilotApiModule.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Web.Http;
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class PilotApiModule:NancyModule
|
||||
{
|
||||
public PilotApiModule() : base("/api/pilot")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class PilotController:ApiController
|
||||
{
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
using Interfaces;
|
||||
using Nancy;
|
||||
using Nancy.ModelBinding;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class RaceSessionApiModule:NancyModule
|
||||
{
|
||||
public RaceSessionApiModule() : base("/api/racesession")
|
||||
{
|
||||
Post["/create"] = args => CreateRaceSession(args);
|
||||
}
|
||||
|
||||
private dynamic CreateRaceSession(dynamic args)
|
||||
{
|
||||
var postObject = this.Bind<RaceSession>();
|
||||
return Response.AsRedirect("/racedirector");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,9 +0,0 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class RaceSessionController:ApiController
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,12 @@
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class SatelliteApiModule:NancyModule
|
||||
{
|
||||
public SatelliteApiModule() : base("/api/satellite")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,6 +0,0 @@
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class SatelliteController
|
||||
{
|
||||
}
|
||||
}
|
||||
13
RaceLapTimer/RaceLapTimer/ApiControllers/SoundApiModule.cs
Normal file
13
RaceLapTimer/RaceLapTimer/ApiControllers/SoundApiModule.cs
Normal file
@ -0,0 +1,13 @@
|
||||
using System.Web.Http;
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class SoundApiModule:NancyModule
|
||||
{
|
||||
public SoundApiModule() : base("/api/sound")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1,8 +0,0 @@
|
||||
using System.Web.Http;
|
||||
|
||||
namespace RaceLapTimer
|
||||
{
|
||||
public class SoundController:ApiController
|
||||
{
|
||||
}
|
||||
}
|
||||
17
RaceLapTimer/RaceLapTimer/ApiControllers/SystemApiModule.cs
Normal file
17
RaceLapTimer/RaceLapTimer/ApiControllers/SystemApiModule.cs
Normal file
@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using Nancy;
|
||||
|
||||
namespace RaceLapTimer.ApiControllers
|
||||
{
|
||||
public class SystemApiModule:NancyModule
|
||||
{
|
||||
public SystemApiModule() : base("/api/system")
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -98,20 +98,21 @@
|
||||
<Reference Include="System.Xml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="ApiControllers\InfoController.cs" />
|
||||
<Compile Include="ApiControllers\LapTrackController.cs" />
|
||||
<Compile Include="ApiControllers\MonitorController.cs" />
|
||||
<Compile Include="ApiControllers\PilotController.cs" />
|
||||
<Compile Include="ApiControllers\RaceSessionController.cs" />
|
||||
<Compile Include="ApiControllers\SatelliteController.cs" />
|
||||
<Compile Include="ApiControllers\SoundController.cs" />
|
||||
<Compile Include="ApiControllers\LapTrackApiModule.cs" />
|
||||
<Compile Include="ApiControllers\MonitorApiModule.cs" />
|
||||
<Compile Include="ApiControllers\PilotApiModule.cs" />
|
||||
<Compile Include="ApiControllers\SatelliteApiModule.cs" />
|
||||
<Compile Include="ApiControllers\SoundApiModule.cs" />
|
||||
<Compile Include="ApiControllers\SystemApiModule.cs" />
|
||||
<Compile Include="AuthenticationBootstrapper.cs" />
|
||||
<Compile Include="Modules\HistoryModule.cs" />
|
||||
<Compile Include="ApiControllers\InfoApiModule.cs" />
|
||||
<Compile Include="Modules\LoginModule.cs" />
|
||||
<Compile Include="Modules\MonitorModule.cs" />
|
||||
<Compile Include="Modules\PilotModule.cs" />
|
||||
<Compile Include="Modules\PilotsModule.cs" />
|
||||
<Compile Include="Modules\RaceDirectorModule.cs" />
|
||||
<Compile Include="ApiControllers\RaceSessionApiModule.cs" />
|
||||
<Compile Include="Modules\SoundfileModule.cs" />
|
||||
<Compile Include="Modules\SystemModule.cs" />
|
||||
<Compile Include="Modules\UserModule.cs" />
|
||||
|
||||
@ -1,2 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=apicontrollers/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=apicontrollers/@EntryIndexedValue">False</s:Boolean></wpf:ResourceDictionary>
|
||||
@ -13,12 +13,12 @@ namespace RaceLapTimer
|
||||
config.IncludeErrorDetailPolicy = IncludeErrorDetailPolicy.Always;
|
||||
config.Routes.MapHttpRoute(
|
||||
name: "DefaultApi",
|
||||
routeTemplate: "api/{controller}/{id}",
|
||||
routeTemplate: "api/{controller}/{action}/{id}",
|
||||
defaults: new { id = RouteParameter.Optional }
|
||||
);
|
||||
config.EnsureInitialized();
|
||||
|
||||
app.UseWebApi(config);
|
||||
//app.UseWebApi(config);
|
||||
|
||||
app.UseNancy();
|
||||
}
|
||||
|
||||
@ -2,12 +2,6 @@
|
||||
@{
|
||||
Layout = "razor-layout.cshtml";
|
||||
}
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<title>Login</title>
|
||||
</head>
|
||||
<body>
|
||||
<form method="POST">
|
||||
Username <input type="text" name="Username" />
|
||||
<br />
|
||||
@ -21,5 +15,3 @@
|
||||
{
|
||||
<div id="errorBox" class="floatingError">Invalid Username or Password</div>
|
||||
}
|
||||
</body>
|
||||
</html>
|
||||
@ -26,7 +26,7 @@
|
||||
<div class='collapse navbar-collapse' id='navbar'>
|
||||
<ul class='nav navbar-nav navbar-right'>
|
||||
<li>
|
||||
<a href="/race_director">Race Director</a>
|
||||
<a href="/racedirector">Race Director</a>
|
||||
</li>
|
||||
<li class='dropdown'>
|
||||
<a aria-expanded='false' aria-haspopup='true' class='dropdown-toggle' data-toggle='dropdown' href='#' role='button'>
|
||||
@ -55,7 +55,7 @@
|
||||
<a href="/history">History</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href='#'>
|
||||
<a href="#">
|
||||
Version
|
||||
0.5.1
|
||||
</a>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user