Permalink
Browse files

Preparation of person edit view.

  • Loading branch information...
deap82 committed May 20, 2017
1 parent f477461 commit 40f174f69228990d46b8d31cf01653dbe45bdfa6
@@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using FooBar.Web.Models;
namespace FooBar.Web.Controllers
{
@@ -32,7 +33,19 @@ public IActionResult Contact()
return View();
}
public IActionResult Error()
public IActionResult Person()
{
PersonModel model = new PersonModel
{
FirstName = "John",
LastName = "Doe",
Occupation = "Developer",
Age = 35
};
return View(model);
}
public IActionResult Error()
{
return View();
}
@@ -0,0 +1,19 @@
using System.ComponentModel.DataAnnotations;
namespace FooBar.Web.Models
{
public class PersonModel
{
[Display(Name = "First name")]
public string FirstName { get; set; }
[Display(Name = "Last name")]
public string LastName { get; set; }
[Display(Name = "Occupation")]
public string Occupation { get; set; }
[Display(Name = "Age [this year]")]
public int Age { get; set; }
}
}
@@ -0,0 +1,39 @@
@{
ViewData["Title"] = "Person";
}
@model FooBar.Web.Models.PersonModel
<div th-aurelia-enhance-module="app/views/home/home-person">
<h1>Edit Person</h1>
<div class="form-group">
<label asp-for="FirstName"></label>
<input asp-for="FirstName" class="form-control" value.bind="firstName" />
</div>
<div class="form-group">
<label asp-for="LastName"></label>
<input asp-for="LastName" class="form-control" value.bind="lastName" />
</div>
<div class="form-group">
<label>Full name</label>
<div>${firstName} ${lastName}</div>
</div>
<div class="form-group">
<label asp-for="Occupation"></label>
<input asp-for="Occupation" class="form-control" />
</div>
<div class="form-group">
<label asp-for="Age"></label>
<input asp-for="Age" class="form-control" value.bind="age" />
</div>
<div class="form-group">
<label>Year of birth</label>
<div>${ currentYear - age }</div>
</div>
</div>
@@ -15,6 +15,7 @@
<li><a route-href="route: MvcRoute; params.bind: { mvcController: 'Home', mvcAction: 'Start' }">Home</a></li>
<li><a route-href="route: MvcRoute; params.bind: { mvcController: 'Home', mvcAction: 'About' }">About</a></li>
<li><a route-href="route: MvcRoute; params.bind: { mvcController: 'Home', mvcAction: 'Contact' }">Contact</a></li>
<li><a route-href="route: MvcRoute; params.bind: { mvcController: 'Home', mvcAction: 'Person' }">Person</a></li>
</ul>
</div>
</div>
@@ -0,0 +1,11 @@
export function create() {
return new HomePersonClientModel();
}
class HomePersonClientModel {
currentYear: number;
constructor() {
this.currentYear = new Date().getFullYear();
}
}

0 comments on commit 40f174f

Please sign in to comment.