Recently, I've been delving into various JavaScript frameworks and made the decision to rework an ASP.Net Core MVC frontend using Aurelia. To kick things off, I utilized the SPA template.
Everything has been smooth sailing so far - I’ve integrated my DAL and BLL projects, established a connection to my database with EF Core, and successfully retrieved data for presentation in my Aurelia front end.
However, at present, my TypeScript files consist of interfaces that bear a striking resemblance to the models set up in my BLL.
Take, for example, my model:
public class staff
{
[Key]
public short StaffId { get; set; }
[DisplayName("First name *")]
public string FirstName { get; set; }
[DisplayName("Family name *")]
public string FamilyName { get; set; }
[DisplayName("Phone")]
public string PhoneNumber { get; set; }
[DisplayName("Birth Date"), DisplayFormat(DataFormatString = "{0:dd MMM yyyy}", ApplyFormatInEditMode = true)]
public DateTime? BirthDate { get; set; }
}
Now, let’s shift our focus to the Aurelia interface in my TypeScript file:
interface staff{
firstname: string;
familyname: string;
phone: string;
date: date;
}
I'm keen on minimizing redundancy by directly utilizing the models. Can this be achieved through importing or injecting the models into my TypeScript files? Furthermore, is it possible to leverage annotations for table titles in HTML or formatting/validation purposes?
Many thanks,
Sylvain