Permalink
Browse files

Made the client side instance of PersonModel typed using a typescript…

… interface and excluded the Occupation property from json serialization.
  • Loading branch information...
deap82 committed May 20, 2017
1 parent a0e90f0 commit eb8b7bf309fe36c7a75e25450e0e5f0e9976fbbe
Showing with 12 additions and 4 deletions.
  1. +3 −1 src/FooBar.Web/Models/PersonModel.cs
  2. +9 −3 src/FooBar.Web/app/views/home/home-person.ts
@@ -1,4 +1,5 @@
using System.ComponentModel.DataAnnotations;
using Newtonsoft.Json;
using System.ComponentModel.DataAnnotations;
namespace FooBar.Web.Models
{
@@ -10,6 +11,7 @@ public class PersonModel
[Display(Name = "Last name")]
public string LastName { get; set; }
[JsonIgnore]
[Display(Name = "Occupation")]
public string Occupation { get; set; }
@@ -1,13 +1,19 @@
export function create(data: any) {
export function create(data: HomePersonModel) {
return new HomePersonClientModel(data);
}
class HomePersonClientModel {
data: any;
data: HomePersonModel;
currentYear: number;
constructor(data: any) {
constructor(data: HomePersonModel) {
this.data = data;
this.currentYear = new Date().getFullYear();
}
}
interface HomePersonModel {
firstName: string;
lastName: string;
age: number;
}

0 comments on commit eb8b7bf

Please sign in to comment.