Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

updated templates

  • Loading branch information...
commit 34d539fcc1a18c27f2da6e9454de953854f16d17 1 parent ebf7214
@nicholascloud authored
View
9 kcdc12/nancyfx/demo/HamstringFX/Fake.cs
@@ -15,8 +15,15 @@ private class Route {
public static dynamic HamstringModel (IHamstringData db) {
var model = new {
+ BestRouteTime = TimeSpan.FromMinutes(25).ToString(),
RunningRoutes = db.Routes.OrderBy(r => r.Name),
- Runs = new List<dynamic>(),
+ Runs = db.Runs.OrderByDescending(r => r.ScheduledAt).Select(r => new {
+ r.Id,
+ r.Duration,
+ r.ScheduledAt,
+ RouteName = r.Route.Name,
+ r.Route.Distance
+ }),
Playlists = new List<dynamic>()
};
View
2  kcdc12/nancyfx/demo/HamstringFX/data/Route.cs
@@ -1,8 +1,10 @@
using System;
+using System.ComponentModel.DataAnnotations;
namespace HamstringFX.data {
public class Route {
+ [Key]
public Guid Id { get; set; }
public String Name { get; set; }
public Decimal Distance { get; set; }
View
11 kcdc12/nancyfx/demo/HamstringFX/data/Run.cs
@@ -1,14 +1,17 @@
using System;
+using System.ComponentModel.DataAnnotations;
namespace HamstringFX.data {
public class Run {
+ [Key]
public Guid Id { get; set; }
+ public Guid RouteId { get; set; }
public DateTime ScheduledAt { get; set; }
- public Int32 Hours { get; set; }
- public Int32 Minutes { get; set; }
- public Int32 Seconds { get; set; }
+ public String Duration { get; set; }
- public Route Route { get; set; }
+
+ [ForeignKey("RouteId")]
+ public virtual Route Route { get; set; }
}
}
View
12 kcdc12/nancyfx/demo/HamstringFX/views/_runs.sshtml
@@ -1,13 +1,13 @@
<!-- _runs.sshtml -->
@Each.Runs
<div class="run">
- <h2>@Current.When</h2>
+ <h2>@Current.ScheduledAt</h2>
<dl>
- <dt>Your time:</dt><dd>@Current.YourTime</dd>
- <dt>Best time:</dt><dd>@Current.BestRouteTime</dd>
- <dt>Difference:</dt><dd>@Current.Difference</dd>
+ <dt>Your time:</dt><dd>@Current.Duration</dd>
+ <dt>Best time:</dt><dd>00:00:00</dd>
+ <dt>Difference:</dt><dd>00:00:00</dd>
</dl>
- <p>@Current.Distance</p>
- <p>@Current.Where</p>
+ <p>@Current.Distance miles</p>
+ <p>@Current.RouteName</p>
</div>
@EndEach
View
24 kcdc12/nancyfx/demo/schema.sql
@@ -30,13 +30,17 @@ create table Runs (
Id uniqueidentifier not null primary key,
RouteId uniqueidentifier not null,
ScheduledAt datetime not null,
- Hours int not null default 0,
- Minutes int not null default 0,
- Seconds int not null default 0,
+ Duration varchar(20) not null default '00:00:00',
foreign key (RouteId) references Routes(Id)
);
go
+--create table RunTimes (
+-- RunId uniqueidentifier not null,
+-- RouteId uniqueidentifier not null,
+--);
+--go
+
if object_id('Playlists') > 0
drop table Playlists;
go
@@ -60,11 +64,11 @@ insert into Routes (Id, Name, Distance) values
('00281890-28A4-4486-853C-F32BFFE3F4E0', 'Rockwood Reservation', 13.9);
go
-insert into Runs (Id, RouteId, ScheduledAt, Hours, Minutes, Seconds) values
- ('96F7610C-B64C-4E82-99CA-EF5B1ABD48EE', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-23', 0, 25, 0),
- ('D567007B-EAF5-4661-A0F3-487F4B925B88', '00281890-28A4-4486-853C-F32BFFE3F4E0', '2012-03-21', 0, 25, 0),
- ('F1D4BD5F-D5CF-44C5-9AEE-98B2579512A4', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-19', 0, 25, 0),
- ('627965C5-321D-4C3C-9F9F-7AAFF6B976A3', '519002C9-6CA5-4B02-9572-4BA7A3FD8ADD', '2012-03-17', 0, 20, 0),
- ('44DDF1BA-09B9-4AD2-9A81-CD1660A2EF7A', '519002C9-6CA5-4B02-9572-4BA7A3FD8ADD', '2012-03-15', 0, 20, 0),
- ('F85246BB-3C34-4856-97B8-FB44C9424EAE', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-15', 0, 20, 0);
+insert into Runs (Id, RouteId, ScheduledAt, Duration) values
+ ('96F7610C-B64C-4E82-99CA-EF5B1ABD48EE', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-23', '00:25:00'),
+ ('D567007B-EAF5-4661-A0F3-487F4B925B88', '00281890-28A4-4486-853C-F32BFFE3F4E0', '2012-03-21', '00:25:00'),
+ ('F1D4BD5F-D5CF-44C5-9AEE-98B2579512A4', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-19', '00:25:00'),
+ ('627965C5-321D-4C3C-9F9F-7AAFF6B976A3', '519002C9-6CA5-4B02-9572-4BA7A3FD8ADD', '2012-03-17', '00:20:00'),
+ ('44DDF1BA-09B9-4AD2-9A81-CD1660A2EF7A', '519002C9-6CA5-4B02-9572-4BA7A3FD8ADD', '2012-03-15', '00:20:00'),
+ ('F85246BB-3C34-4856-97B8-FB44C9424EAE', 'BB94B932-2D05-465B-800A-1E6AC505CFD1', '2012-03-15', '00:20:00');
go
Please sign in to comment.
Something went wrong with that request. Please try again.