-
-
Save tuannguyenssu/818bc252d88a67adbeae689af9e295ec to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using AutoMapper; | |
using AutoMapperTest.Models; | |
using Microsoft.AspNetCore.Mvc; | |
namespace AutoMapperTest.Controllers | |
{ | |
public class UserController : Controller | |
{ | |
private readonly IMapper _mapper; | |
public UserController(IMapper mapper) | |
{ | |
_mapper = mapper; | |
} | |
public IActionResult Index() | |
{ | |
var user = new User() | |
{ | |
FirstName = "Tuan", | |
LastName = "Nguyen" | |
}; | |
var model = _mapper.Map<UserViewModel>(user); | |
return View(model); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment