Created
January 6, 2020 19:20
-
-
Save sumitkharche/128ec5ae078db9a66b6860b9b280b899 to your computer and use it in GitHub Desktop.
StudentController
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 Microsoft.AspNetCore.Mvc; | |
namespace automapper_sample.Controllers | |
{ | |
[Route("api/[controller]")] | |
public class StudentController : Controller | |
{ | |
private readonly IMapper _mapper; | |
public StudentController(IMapper mapper) | |
{ | |
_mapper = mapper; | |
} | |
// GET: api/<controller> | |
[HttpGet] | |
public Student Get() | |
{ | |
StudentDTO studentDTO = new StudentDTO() | |
{ | |
Name = "Student 1", | |
Age = 25, | |
City = "New York" | |
}; | |
return _mapper.Map<Student>(studentDTO); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment