Viewing and creating new people implemented
This commit is contained in:
4
MVCUI/Content/bootstrap.css
vendored
4
MVCUI/Content/bootstrap.css
vendored
@ -10801,7 +10801,7 @@ a.text-dark:hover, a.text-dark:focus {
|
||||
}
|
||||
|
||||
.table {
|
||||
font-size: 0.875rem;
|
||||
font-size: 16px;
|
||||
}
|
||||
|
||||
.table .thead-dark th {
|
||||
@ -10919,7 +10919,7 @@ label,
|
||||
.radio label,
|
||||
.checkbox label,
|
||||
.help-block {
|
||||
font-size: 0.875rem;
|
||||
font-size: 18px;
|
||||
}
|
||||
|
||||
.nav-tabs .nav-link,
|
||||
|
||||
51
MVCUI/Controllers/PeopleController.cs
Normal file
51
MVCUI/Controllers/PeopleController.cs
Normal file
@ -0,0 +1,51 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Web;
|
||||
using System.Web.Mvc;
|
||||
using TrackerLibrary;
|
||||
using TrackerLibrary.Models;
|
||||
|
||||
namespace MVCUI.Controllers
|
||||
{
|
||||
public class PeopleController : Controller
|
||||
{
|
||||
// GET: People
|
||||
public ActionResult Index()
|
||||
{
|
||||
List<PersonModel> availablePeople = GlobalConfig.Connection.GetPerson_All();
|
||||
return View(availablePeople);
|
||||
}
|
||||
|
||||
|
||||
// GET: People/Create
|
||||
public ActionResult Create()
|
||||
{
|
||||
return View();
|
||||
}
|
||||
|
||||
// POST: People/Create
|
||||
[HttpPost]
|
||||
public ActionResult Create(PersonModel p)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (ModelState.IsValid)
|
||||
{
|
||||
GlobalConfig.Connection.CreatePerson(p);
|
||||
return RedirectToAction("Index");
|
||||
}
|
||||
else
|
||||
{
|
||||
return View();
|
||||
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
return View();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@ -123,6 +123,7 @@
|
||||
<Compile Include="App_Start\FilterConfig.cs" />
|
||||
<Compile Include="App_Start\RouteConfig.cs" />
|
||||
<Compile Include="Controllers\HomeController.cs" />
|
||||
<Compile Include="Controllers\PeopleController.cs" />
|
||||
<Compile Include="Global.asax.cs">
|
||||
<DependentUpon>Global.asax</DependentUpon>
|
||||
</Compile>
|
||||
@ -263,6 +264,8 @@
|
||||
<Content Include="Scripts\popper.js.map" />
|
||||
<Content Include="Scripts\popper-utils.min.js.map" />
|
||||
<Content Include="Scripts\popper-utils.js.map" />
|
||||
<Content Include="Views\People\Index.cshtml" />
|
||||
<Content Include="Views\People\Create.cshtml" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="App_Data\" />
|
||||
|
||||
64
MVCUI/Views/People/Create.cshtml
Normal file
64
MVCUI/Views/People/Create.cshtml
Normal file
@ -0,0 +1,64 @@
|
||||
@model TrackerLibrary.Models.PersonModel
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Create";
|
||||
}
|
||||
|
||||
<h2>Create New Person</h2>
|
||||
|
||||
|
||||
@using (Html.BeginForm())
|
||||
{
|
||||
@Html.AntiForgeryToken()
|
||||
|
||||
<div class="form-horizontal">
|
||||
<h4>PersonModel</h4>
|
||||
<hr />
|
||||
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.FirstName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.FirstName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.FirstName, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.LastName, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.LastName, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.LastName, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.EmailAddress, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.EmailAddress, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.EmailAddress, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
@Html.LabelFor(model => model.CellPhoneNumber, htmlAttributes: new { @class = "control-label col-md-2" })
|
||||
<div class="col-md-10">
|
||||
@Html.EditorFor(model => model.CellPhoneNumber, new { htmlAttributes = new { @class = "form-control" } })
|
||||
@Html.ValidationMessageFor(model => model.CellPhoneNumber, "", new { @class = "text-danger" })
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-offset-2 col-md-10">
|
||||
<input type="submit" value="Create" class="btn btn-default" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<div>
|
||||
@Html.ActionLink("Back to List", "Index")
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
@Scripts.Render("~/bundles/jqueryval")
|
||||
}
|
||||
45
MVCUI/Views/People/Index.cshtml
Normal file
45
MVCUI/Views/People/Index.cshtml
Normal file
@ -0,0 +1,45 @@
|
||||
@model IEnumerable<TrackerLibrary.Models.PersonModel>
|
||||
|
||||
@{
|
||||
ViewBag.Title = "Index";
|
||||
}
|
||||
|
||||
<h2>View All People</h2>
|
||||
|
||||
<p>
|
||||
@Html.ActionLink("Create New", "Create")
|
||||
</p>
|
||||
<table class="table">
|
||||
<tr>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.FirstName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.LastName)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.EmailAddress)
|
||||
</th>
|
||||
<th>
|
||||
@Html.DisplayNameFor(model => model.CellPhoneNumber)
|
||||
</th>
|
||||
</tr>
|
||||
|
||||
@foreach (var item in Model) {
|
||||
<tr>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.FirstName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.LastName)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.EmailAddress)
|
||||
</td>
|
||||
<td>
|
||||
@Html.DisplayFor(modelItem => item.CellPhoneNumber)
|
||||
</td>
|
||||
</tr>
|
||||
}
|
||||
|
||||
</table>
|
||||
@ -24,12 +24,15 @@
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("Home", "Index", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
@*<li class="nav-item">
|
||||
@Html.ActionLink("About", "About", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("Contact", "Contact", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>*@
|
||||
@Html.ActionLink("People", "Index", "People", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
@*<li class="nav-item">
|
||||
@Html.ActionLink("About", "About", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
@Html.ActionLink("Contact", "Contact", "Home", new { area = "" }, new { @class = "nav-link text-light" })
|
||||
</li>*@
|
||||
</ul>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
Reference in New Issue
Block a user