From the course: C#: Design Patterns Part 1

Unlock the full course today

Join today to access over 22,600 courses taught by industry experts or purchase this course individually.

Adapter pattern for ViewModel mapping

Adapter pattern for ViewModel mapping - Python Tutorial

From the course: C#: Design Patterns Part 1

Start my 1-month free trial

Adapter pattern for ViewModel mapping

- [Instructor] Let's add an adapter to further the improvement of our HPlusSports application. We'll start by looking at the order index view. Web, views, order, index. You can see online one that it's using an order list ViewModel. If we open the ViewModels folder and look at that, we can see it's a list of order which is our shared type. If we go back again to the view, we can see that for each column here, we're doing some sort of adapting from the shared type to something we can display. Mostly it's string formatting. For example, we're combining the first name and last name. We'll want to encapsulate all of this logic in a ViewModel that will adapt our shared object to the view. We'll create the new ViewModel in the ViewModel folder and call it OrderItemViewModel. We'll use the system collections to iterate through our list. We'll use the core project for the filter select we created before. And we'll use the…

Contents