From e486908b2c0cf5f6cc3424be7f17a73a36448594 Mon Sep 17 00:00:00 2001 From: Thomas Hounsell Date: Fri, 10 Apr 2015 23:48:19 +0100 Subject: [PATCH] Refresh Pt b4a --- BuildFeed.csproj | 1 + Controllers/frontController.cs | 15 ++- Views/front/viewBuild.cshtml | 168 +++++++++++++++++++++++++++++++++ Views/front/viewGroup.cshtml | 2 +- 4 files changed, 182 insertions(+), 4 deletions(-) create mode 100644 Views/front/viewBuild.cshtml diff --git a/BuildFeed.csproj b/BuildFeed.csproj index 97a6d3c..44bf2b3 100644 --- a/BuildFeed.csproj +++ b/BuildFeed.csproj @@ -296,6 +296,7 @@ + diff --git a/Controllers/frontController.cs b/Controllers/frontController.cs index 0a90cd7..355446e 100644 --- a/Controllers/frontController.cs +++ b/Controllers/frontController.cs @@ -37,7 +37,7 @@ bg.Key.Revision descending [Route("group/{major}.{minor}.{number}.{revision}")] public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? revision = null) { - var builds = from b in Build.Select() + var builds = (from b in Build.Select() group b by new BuildGroup() { Major = b.MajorVersion, @@ -49,9 +49,18 @@ public ActionResult viewGroup(byte major, byte minor, ushort number, ushort? rev where bg.Key.Minor == minor where bg.Key.Build == number where bg.Key.Revision == revision - select bg; + select bg).Single(); - return builds.Count() == 1 ? View(builds.Single()) as ActionResult : Redirect("~/") as ActionResult; + return builds.Count() == 1 ? + RedirectToAction("viewBuild", new { id = builds.Single().Id }) as ActionResult : + View(builds); + } + + [Route("build/{id}")] + public ActionResult viewBuild(long id) + { + Build b = Build.SelectById(id); + return View(b); } } } \ No newline at end of file diff --git a/Views/front/viewBuild.cshtml b/Views/front/viewBuild.cshtml new file mode 100644 index 0000000..b8d92ea --- /dev/null +++ b/Views/front/viewBuild.cshtml @@ -0,0 +1,168 @@ +@model BuildFeed.Models.Build + +@{ + ViewBag.Title = Model.FullBuildString + " | BuildFeed"; +} + +@section head +{ + + + + + @if (Model.BuildTime.HasValue) + { + + + } + else + { + + + } +} + +

@Model.FullBuildString

+ +
+
+
+ @if (User.Identity.IsAuthenticated) + { +
+ +
+

+ @Html.ActionLink("Edit", "edit", new { id = Model.Id }, new { @class = "btn btn-default btn-xs" }) + + @if (Roles.IsUserInRole("Administrators")) + { + @Html.ActionLink("Delete", "delete", new { id = Model.Id }, new { @class = "btn btn-danger btn-xs" }) + } +

+
+
+ } +
+ @Html.LabelFor(model => model.MajorVersion, new { @class = "control-label col-sm-4" }) +
+

@Html.DisplayFor(model => model.MajorVersion)

+
+
+ +
+ @Html.LabelFor(model => model.MinorVersion, new { @class = "control-label col-sm-4" }) +
+

@Html.DisplayFor(model => model.MinorVersion)

+
+
+ +
+ @Html.LabelFor(model => model.Number, new { @class = "control-label col-sm-4" }) +
+

@Html.DisplayFor(model => model.Number)

+
+
+ +
+ @Html.LabelFor(model => model.Revision, new { @class = "control-label col-sm-4" }) +
+

@Html.DisplayFor(model => model.Revision)

+
+
+ +
+ @Html.LabelFor(model => model.Lab, new { @class = "control-label col-sm-4" }) +
+

+ @Model.Lab
+ Find more builds from @Model.Lab +

+
+
+ +
+ @Html.LabelFor(model => model.BuildTime, new { @class = "control-label col-sm-4" }) +
+

+ @if (Model.BuildTime.HasValue) + { + +
+ Find more builds compiled in @Model.BuildTime.Value.Year + } +

+
+
+
+
+
+
+
+ @Html.LabelFor(model => model.SourceType, new { @class = "control-label" }) +

+ @Html.DisplayFor(model => model.SourceType, "Enumeration")
+ Find more builds sourced from @Html.DisplayFor(model => model.SourceType, "Enumeration") +

+
+ + @if (Model.LeakDate.HasValue) + { +
+ @Html.LabelFor(model => model.LeakDate, new { @class = "control-label" }) +
+
+ } + + @if ((Model.MajorVersion == 6 && Model.MinorVersion == 4) || (Model.MajorVersion == 10 && Model.MinorVersion == 0) && Model.FlightLevel != BuildFeed.Models.LevelOfFlight.None) + { +
+ @Html.LabelFor(model => model.FlightLevel, new { @class = "control-label" }) +

@Html.DisplayFor(model => model.FlightLevel, "Enumeration")

+
+ } + +
+ +
+
+
+ @Html.LabelFor(model => model.SourceDetails, new { @class = "control-label" }) +
@Html.Raw(Model.SourceDetails)
+
+
+
+
+ +
+
+ +
+
+ + +
+
+ + +
+ +@section scripts +{ + +} diff --git a/Views/front/viewGroup.cshtml b/Views/front/viewGroup.cshtml index c79b5e2..22b69c8 100644 --- a/Views/front/viewGroup.cshtml +++ b/Views/front/viewGroup.cshtml @@ -20,7 +20,7 @@ }

- Info + Info Edit Delete