-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Addition of Sqlite and Simple.data to start allowing data retrieval a…
…nd insertion for the feature switches and messages
- Loading branch information
Showing
45 changed files
with
348 additions
and
2,990 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using System.Web.Mvc; | ||
|
||
namespace BuildMonitor.Areas.Admin | ||
{ | ||
public class AdminAreaRegistration : AreaRegistration | ||
{ | ||
public override string AreaName | ||
{ | ||
get | ||
{ | ||
return "Admin"; | ||
} | ||
} | ||
|
||
public override void RegisterArea(AreaRegistrationContext context) | ||
{ | ||
context.MapRoute( | ||
"Admin_default", | ||
"Admin/{controller}/{action}/{id}", | ||
new { controller="Home", action = "Index", id = UrlParameter.Optional } | ||
); | ||
} | ||
} | ||
} |
115 changes: 115 additions & 0 deletions
115
TeamCityMonitor/Areas/Admin/Controllers/HomeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Mvc; | ||
using BuildMonitor.Models; | ||
using Simple.Data; | ||
|
||
namespace BuildMonitor.Areas.Admin.Controllers | ||
{ | ||
public class HomeController : Controller | ||
{ | ||
// | ||
// GET: /Admin/Default1/ | ||
|
||
private dynamic GetDatabase() | ||
{ | ||
var dbFile = Server.MapPath("~/App_Data/ApplicationData.db"); | ||
var db = Database.OpenFile(dbFile); | ||
|
||
return db; | ||
} | ||
|
||
public ActionResult Index() | ||
{ | ||
var features = GetDatabase().Feature.All(); | ||
return View(features); | ||
} | ||
|
||
// | ||
// GET: /Admin/Default1/Details/5 | ||
|
||
public ActionResult Details(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// GET: /Admin/Default1/Create | ||
|
||
public ActionResult Create() | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// POST: /Admin/Default1/Create | ||
|
||
[HttpPost] | ||
public ActionResult Create(Feature feature) | ||
{ | ||
try | ||
{ | ||
|
||
GetDatabase().Feature.Insert(FeatureName: feature.FeatureName, Enabled: feature.Enabled); | ||
return RedirectToAction("Index"); | ||
} | ||
catch (Exception ex) | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// | ||
// GET: /Admin/Default1/Edit/5 | ||
|
||
public ActionResult Edit(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// POST: /Admin/Default1/Edit/5 | ||
|
||
[HttpPost] | ||
public ActionResult Edit(int id, FormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add update logic here | ||
|
||
|
||
return RedirectToAction("Index"); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// | ||
// GET: /Admin/Default1/Delete/5 | ||
|
||
public ActionResult Delete(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// POST: /Admin/Default1/Delete/5 | ||
|
||
[HttpPost] | ||
public ActionResult Delete(int id, FormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add delete logic here | ||
|
||
return RedirectToAction("Index"); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
@model BuildMonitor.Models.Feature | ||
|
||
@{ | ||
ViewBag.Title = "Create"; | ||
} | ||
|
||
<h2>Create</h2> | ||
|
||
<script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script> | ||
<script src="@Url.Content("~/Scripts/jquery.validate.unobtrusive.min.js")" type="text/javascript"></script> | ||
|
||
@using (Html.BeginForm()) { | ||
@Html.ValidationSummary(true) | ||
<fieldset> | ||
<legend>Feature</legend> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(model => model.FeatureName) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.EditorFor(model => model.FeatureName) | ||
@Html.ValidationMessageFor(model => model.FeatureName) | ||
</div> | ||
|
||
<div class="editor-label"> | ||
@Html.LabelFor(model => model.Enabled) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.EditorFor(model => model.Enabled) | ||
@Html.ValidationMessageFor(model => model.Enabled) | ||
</div> | ||
|
||
<p> | ||
<input type="submit" value="Create" /> | ||
</p> | ||
</fieldset> | ||
} | ||
|
||
<div> | ||
@Html.ActionLink("Back to List", "Index") | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
@model dynamic | ||
@{ | ||
ViewBag.Title = "Index"; | ||
} | ||
|
||
<h2>Index</h2> | ||
@Html.ActionLink("Add new feature", "Create") | ||
|
||
@if (Model != null) | ||
{ | ||
<table> | ||
<tr> | ||
<th>Id</th> | ||
<th>Feature Name</th> | ||
<th>Enabled</th> | ||
@foreach (var feature in Model) | ||
{ | ||
<tr> | ||
<td>@feature.FeatureId</td> | ||
<td>@feature.FeatureName</td> | ||
<td>@feature.Enabled</td> | ||
</tr> | ||
} | ||
</tr> | ||
</table> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<?xml version="1.0"?> | ||
|
||
<configuration> | ||
<configSections> | ||
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> | ||
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" /> | ||
</sectionGroup> | ||
</configSections> | ||
|
||
<system.web.webPages.razor> | ||
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> | ||
<pages pageBaseType="System.Web.Mvc.WebViewPage"> | ||
<namespaces> | ||
<add namespace="System.Web.Mvc" /> | ||
<add namespace="System.Web.Mvc.Ajax" /> | ||
<add namespace="System.Web.Mvc.Html" /> | ||
<add namespace="System.Web.Routing" /> | ||
</namespaces> | ||
</pages> | ||
</system.web.webPages.razor> | ||
|
||
<appSettings> | ||
<add key="webpages:Enabled" value="false" /> | ||
</appSettings> | ||
|
||
<system.web> | ||
<httpHandlers> | ||
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/> | ||
</httpHandlers> | ||
|
||
<!-- | ||
Enabling request validation in view pages would cause validation to occur | ||
after the input has already been processed by the controller. By default | ||
MVC performs request validation before a controller processes the input. | ||
To change this behavior apply the ValidateInputAttribute to a | ||
controller or action. | ||
--> | ||
<pages | ||
validateRequest="false" | ||
pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" | ||
pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" | ||
userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"> | ||
<controls> | ||
<add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" /> | ||
</controls> | ||
</pages> | ||
</system.web> | ||
|
||
<system.webServer> | ||
<validation validateIntegratedModeConfiguration="false" /> | ||
|
||
<handlers> | ||
<remove name="BlockViewHandler"/> | ||
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" /> | ||
</handlers> | ||
</system.webServer> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
namespace BuildMonitor.Models | ||
{ | ||
public class Feature | ||
{ | ||
public int FeatureId { get; set; } | ||
public string FeatureName { get; set; } | ||
public bool Enabled { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
using System.ComponentModel.DataAnnotations; | ||
|
||
namespace BuildMonitor.Models | ||
{ | ||
public class Message | ||
{ | ||
public int MessageId { get; set; } | ||
public string MessageDetail { get; set; } | ||
|
||
public virtual Feature Feature { get; set; } | ||
} | ||
} |
Oops, something went wrong.