Skip to content

Commit

Permalink
Preparation of person edit view.
Browse files Browse the repository at this point in the history
  • Loading branch information
deap82 committed May 20, 2017
1 parent f477461 commit 40f174f
Show file tree
Hide file tree
Showing 5 changed files with 84 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/FooBar.Web/Controllers/HomeController.cs
Expand Up @@ -3,6 +3,7 @@
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using FooBar.Web.Models;

namespace FooBar.Web.Controllers
{
Expand Down Expand Up @@ -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();
}
Expand Down
19 changes: 19 additions & 0 deletions src/FooBar.Web/Models/PersonModel.cs
@@ -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; }
}
}
39 changes: 39 additions & 0 deletions src/FooBar.Web/Views/Home/Person.cshtml
@@ -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>
1 change: 1 addition & 0 deletions src/FooBar.Web/app/app.html
Expand Up @@ -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>
Expand Down
11 changes: 11 additions & 0 deletions src/FooBar.Web/app/views/home/home-person.ts
@@ -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.