Skip to content

Commit

Permalink
Added first Admin pages (Index and Create)
Browse files Browse the repository at this point in the history
  • Loading branch information
gmobydick committed Aug 3, 2011
1 parent 44891f3 commit 68bc6f7
Show file tree
Hide file tree
Showing 54 changed files with 3,896 additions and 134 deletions.
8 changes: 8 additions & 0 deletions TaskDO/DAO/ProjectDAO.cs
@@ -0,0 +1,8 @@
using TaskDO.Entities;

namespace TaskDO.DAO
{
public class ProjectDAO : BaseDAO<Project>
{
}
}
2 changes: 1 addition & 1 deletion TaskDO/Entities/Entity.cs
Expand Up @@ -28,7 +28,7 @@ public abstract class Entity

public virtual DateTime? CreatedAt { get; set; }
public virtual string CreatedBy { get; set; }
public virtual DateTime UpdatedAt { get; set; }
public virtual DateTime? UpdatedAt { get; set; }
public virtual string UpdatedBy { get; set; }
}
}
67 changes: 0 additions & 67 deletions TaskDO/Entities/TimeStampEventListener.cs

This file was deleted.

8 changes: 3 additions & 5 deletions TaskDO/Mapping/EntityMap.cs
Expand Up @@ -7,17 +7,15 @@ public abstract class EntityMap<T> : ClassMap<T> where T : Entity
{
public EntityMap()
{
//Id(x => x.Id).GeneratedBy.GuidComb().UnsavedValue("00000000-0000-0000-0000-000000000000");
Id(x => x.Id);
Version(x => x.Version);
Map(x => x.Name).Length(80);
Map(x => x.Description).Length(100);
//Map(x => x.Name).Unique("UnKeyiqueKey_TCountry_CName").Length(30);

Map(x => x.CreatedBy).Nullable().Length(50);
Map(x => x.CreatedAt).Nullable();
//.Generated.Insert().CustomSqlType("datetime")
//Map(x => x.UpdatedBy).Nullable().Length(50);
//Map(x => x.UpdatedDate).Nullable().Generated.Insert().CustomSqlType("timestamp");
Map(x => x.UpdatedBy).Nullable().Length(50);
Map(x => x.UpdatedAt).Nullable();
}
}
}
2 changes: 1 addition & 1 deletion TaskDO/TaskDO.csproj
Expand Up @@ -48,6 +48,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="DAO\BaseDAO.cs" />
<Compile Include="DAO\ProjectDAO.cs" />
<Compile Include="Entities\RecurrencePeriode.cs" />
<Compile Include="Entities\TaskTemplate.cs" />
<Compile Include="Entities\TaskRecurrence.cs" />
Expand All @@ -56,7 +57,6 @@
<Compile Include="Entities\TaskTime.cs" />
<Compile Include="Entities\Entity.cs" />
<Compile Include="Entities\Task.cs" />
<Compile Include="Entities\TimeStampEventListener.cs" />
<Compile Include="Mapping\AbstractTaskMap.cs" />
<Compile Include="Mapping\TaskTimeMap.cs" />
<Compile Include="Mapping\TaskRecurrenceMap.cs" />
Expand Down
2 changes: 1 addition & 1 deletion TaskMVC/Areas/Admin/AdminAreaRegistration.cs
Expand Up @@ -17,7 +17,7 @@ public override void RegisterArea(AreaRegistrationContext context)
context.MapRoute(
"Admin_default",
"Admin/{controller}/{action}/{id}",
new { action = "Index", id = UrlParameter.Optional }
new { controller = "Project", action = "Index", id = UrlParameter.Optional }
);
}
}
Expand Down
122 changes: 122 additions & 0 deletions TaskMVC/Areas/Admin/Controllers/ProjectController.cs
@@ -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();
}
}
}
}
20 changes: 0 additions & 20 deletions TaskMVC/Areas/Admin/Controllers/ProjectTaskController.cs

This file was deleted.

19 changes: 19 additions & 0 deletions TaskMVC/Areas/Admin/Models/AdminModel.cs
@@ -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
{

}
}
30 changes: 30 additions & 0 deletions TaskMVC/Areas/Admin/Views/Project/Create.cshtml
@@ -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>
}
34 changes: 34 additions & 0 deletions TaskMVC/Areas/Admin/Views/Project/Index.cshtml
@@ -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")
))*@
3 changes: 3 additions & 0 deletions TaskMVC/Areas/Admin/Views/_ViewStart.cshtml
@@ -0,0 +1,3 @@
@{
Layout = "~/Views/Shared/_Layout.cshtml";
}
Binary file added TaskMVC/Content/Menues.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 68bc6f7

Please sign in to comment.