Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added first Admin pages (Index and Create)
- Loading branch information
gmobydick
committed
Aug 3, 2011
1 parent
44891f3
commit 68bc6f7
Showing
54 changed files
with
3,896 additions
and
134 deletions.
There are no files selected for viewing
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,8 @@ | ||
using TaskDO.Entities; | ||
|
||
namespace TaskDO.DAO | ||
{ | ||
public class ProjectDAO : BaseDAO<Project> | ||
{ | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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
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,122 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Web.Mvc; | ||
using NHibernate; | ||
using TaskDO.DAO; | ||
using TaskDO.Entities; | ||
using TaskMVC.Areas.Admin.Models; | ||
using log4net; | ||
|
||
namespace TaskMVC.Areas.Admin.Controllers | ||
{ | ||
public class ProjectController : Controller | ||
{ | ||
private static readonly ILog Log = LogManager.GetLogger(typeof(ProjectController)); | ||
private readonly ISession _session = MvcApplication.SessionFactory.GetCurrentSession(); | ||
private readonly ProjectDAO _projectDAO = new ProjectDAO(); | ||
public ProjectModel Model = new ProjectModel(); | ||
|
||
public ProjectController() | ||
{ | ||
Model.AllProjects = _projectDAO.GetAll(_session); | ||
} | ||
|
||
// | ||
// GET: /Admin/Project/ | ||
|
||
public ActionResult Index() | ||
{ | ||
return View(Model); | ||
} | ||
|
||
// | ||
// GET: /Admin/Project/Details/5 | ||
|
||
public ActionResult Details(int id) | ||
{ | ||
|
||
return View(Model.SelectedProject); | ||
} | ||
|
||
// | ||
// GET: /Admin/Project/Create | ||
|
||
public ActionResult Create() | ||
{ | ||
Model.SelectedProject = new Project(); | ||
return View(Model); | ||
} | ||
|
||
// | ||
// POST: /Admin/Project/Create | ||
|
||
[HttpPost] | ||
public ActionResult Create(ProjectModel model) | ||
{ | ||
try | ||
{ | ||
_projectDAO.SaveOrUpdate(_session, model.SelectedProject); | ||
|
||
return RedirectToAction("Index"); | ||
} | ||
catch (Exception exception) | ||
{ | ||
Log.Error(exception.Message, exception); | ||
ViewBag.Message = exception.Message; | ||
return View(model); | ||
} | ||
} | ||
|
||
// | ||
// GET: /Admin/Project/Edit/5 | ||
|
||
public ActionResult Edit(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// POST: /Admin/Project/Edit/5 | ||
|
||
[HttpPost] | ||
public ActionResult Edit(int id, FormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add update logic here | ||
|
||
return RedirectToAction("Index"); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
|
||
// | ||
// GET: /Admin/Project/Delete/5 | ||
|
||
public ActionResult Delete(int id) | ||
{ | ||
return View(); | ||
} | ||
|
||
// | ||
// POST: /Admin/Project/Delete/5 | ||
|
||
[HttpPost] | ||
public ActionResult Delete(int id, FormCollection collection) | ||
{ | ||
try | ||
{ | ||
// TODO: Add delete logic here | ||
|
||
return RedirectToAction("Index"); | ||
} | ||
catch | ||
{ | ||
return View(); | ||
} | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Web; | ||
using TaskDO.Entities; | ||
|
||
namespace TaskMVC.Areas.Admin.Models | ||
{ | ||
public class ProjectModel | ||
{ | ||
public IEnumerable<Project> AllProjects { get; set; } | ||
public Project SelectedProject { get; set; } | ||
} | ||
|
||
public class TaskModel | ||
{ | ||
|
||
} | ||
} |
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,30 @@ | ||
@model TaskMVC.Areas.Admin.Models.ProjectModel | ||
@{ | ||
ViewBag.Title = "Create project"; | ||
} | ||
<h2>Create project</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) | ||
@ViewBag.Message | ||
<fieldset><legend>Project</legend> | ||
<div class="editor-label"> | ||
@Html.LabelFor(model => model.SelectedProject.Name) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.EditorFor(model => model.SelectedProject.Name) | ||
</div> | ||
<div class="editor-label"> | ||
@Html.LabelFor(model => model.SelectedProject.Description) | ||
</div> | ||
<div class="editor-field"> | ||
@Html.EditorFor(model => model.SelectedProject.Description) | ||
</div> | ||
<p> | ||
<input type="submit" value="Create" class="button black" /> | ||
@Html.ActionLink("Back to List", "Index", null, new { @class = "button black" }) | ||
</p> | ||
</fieldset> | ||
} |
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,34 @@ | ||
@using TaskMVC.Areas.Admin.Models | ||
@model ProjectModel | ||
@{ | ||
ViewBag.Title = "Projects"; | ||
var grid = new WebGrid(Model.AllProjects, defaultSort: "Name"); | ||
} | ||
<h2>Projects</h2> | ||
<p> | ||
@Html.ActionLink("Create New", "Create", new { }, new { @class = "button black" }) | ||
</p> | ||
@grid.GetHtml( | ||
columns: grid.Columns( | ||
grid.Column(header: "", format: (item) => new HtmlString( | ||
Html.ActionLink("Edit", "Edit", new { id = item.id }).ToString() + " | " + | ||
Html.ActionLink("Delete", "Delete", new { id = item.id }).ToString()) | ||
), | ||
grid.Column(columnName: "Name"), | ||
grid.Column(columnName: "Description"), | ||
grid.Column(columnName: "CreatedAt", header: "Created"), | ||
grid.Column(columnName: "CreatedBy", header: "Created"), | ||
grid.Column(columnName: "UpdatedAt", header: "Updated"), | ||
grid.Column(columnName: "UpdatedBy", header: "Created") | ||
) | ||
) | ||
@*@grid.GetHtml( | ||
columns: grid.Columns( | ||
grid.Column(header: "", format: (item) => new HtmlString( | ||
Html.ActionLink("Edit", "Edit", new { id = item.id }).ToString() + " | " + | ||
Html.ActionLink("Delete", "Delete", new { id = item.id }).ToString()) | ||
), | ||
grid.Column(columnName: "Name", header: "Node"), | ||
grid.Column(columnName: "ElementType", header: "Type"), //, format: EnumExtra.GetEnumDescription(@item)), | ||
grid.Column(columnName: "Description") | ||
))*@ |
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,3 @@ | ||
@{ | ||
Layout = "~/Views/Shared/_Layout.cshtml"; | ||
} |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.