Skip to content

Commit

Permalink
Addition of Sqlite and Simple.data to start allowing data retrieval a…
Browse files Browse the repository at this point in the history
…nd insertion for the feature switches and messages
  • Loading branch information
stack72 committed Jul 8, 2012
1 parent 3dd78ac commit 87fd442
Show file tree
Hide file tree
Showing 45 changed files with 348 additions and 2,990 deletions.
Binary file added TeamCityMonitor/App_Data/ApplicationData.db
Binary file not shown.
24 changes: 24 additions & 0 deletions TeamCityMonitor/Areas/Admin/AdminAreaRegistration.cs
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 TeamCityMonitor/Areas/Admin/Controllers/HomeController.cs
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();
}
}
}
}
41 changes: 41 additions & 0 deletions TeamCityMonitor/Areas/Admin/Views/Home/Create.cshtml
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>
26 changes: 26 additions & 0 deletions TeamCityMonitor/Areas/Admin/Views/Home/Index.cshtml
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>
}
58 changes: 58 additions & 0 deletions TeamCityMonitor/Areas/Admin/Views/Web.config
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>
6 changes: 1 addition & 5 deletions TeamCityMonitor/Global.asax.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Mvc;
using System.Web.Routing;

namespace BuildMonitor
Expand Down
9 changes: 9 additions & 0 deletions TeamCityMonitor/Models/Feature.cs
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; }
}
}
12 changes: 12 additions & 0 deletions TeamCityMonitor/Models/Message.cs
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; }
}
}
Loading

0 comments on commit 87fd442

Please sign in to comment.