Skip to Main Content
ASP.NET Core MVC 2.0 Cookbook
book

ASP.NET Core MVC 2.0 Cookbook

by Jason De Oliveira, Engin Polat, Stephane Belkheraz
February 2018
Intermediate to advanced content levelIntermediate to advanced
668 pages
15h 18m
English
Packt Publishing
Content preview from ASP.NET Core MVC 2.0 Cookbook

How to do it...

Now we can dive deep into dependency injection in views:

  1. First, we add an AddProduct action method with the corresponding view and associated repository to this template web project. In this example, the Product list and the Category list come from hardcoded code, but in the real world, it should come from a database (relational or not), a service, or any other data source:
    • Following code is the Dto and ViewModel classes:
public class ProductDto{  public int Id { get; set; }  public string Name { get; set; }  public decimal Price { get; set; }}public class ProductViewModel{  public int Id { get; set; }  [Required]  [MaxLength(50)]  public string Name { get; set; }  [Required]  [Range(0.01, double.MaxValue, ErrorMessage = "Please ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

ASP.NET Core and Vue.js

ASP.NET Core and Vue.js

Devlin Basilan Duldulao
Mastering ASP.NET Web API

Mastering ASP.NET Web API

Mithun Pattankar, Malendra Hurbuns

Publisher Resources

ISBN: 9781785886751Other