Skip to content

Instantly share code, notes, and snippets.

@tuannguyenssu
Created August 5, 2019 13:34
Show Gist options
  • Save tuannguyenssu/818bc252d88a67adbeae689af9e295ec to your computer and use it in GitHub Desktop.
Save tuannguyenssu/818bc252d88a67adbeae689af9e295ec to your computer and use it in GitHub Desktop.
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