Example #1
0
        public HttpResponseMessage Get()
        {
            var users = _usersDomain.GetAll();

            var usersDto = _mapper.Map <IEnumerable <Entity.User>, IEnumerable <UserDto> >(users);

            IContentNegotiator negotiator = Configuration.Services.GetContentNegotiator();

            ContentNegotiationResult result = negotiator.Negotiate(
                usersDto.GetType(), Request, Configuration.Formatters);

            if (result == null)
            {
                var response = new HttpResponseMessage(HttpStatusCode.NotAcceptable);
                throw new HttpResponseException(response);
            }

            return(new HttpResponseMessage()
            {
                Content = new ObjectContent <IEnumerable <UserDto> >(
                    usersDto,
                    result.Formatter,
                    result.MediaType.MediaType
                    )
            });
        }
Example #2
0
 public IActionResult Index()
 {
     return(View(_usersDomain.GetAll()));
 }
Example #3
0
 public IEnumerable <UserDto> Get()
 {
     return(_usersDomain.GetAll());
 }