コード例 #1
0
        //[Authorize]
        public IActionResult GetUsers(string firstName, string lastName)
        {
            IActionResult result = Unauthorized();

            try
            {
                IList <UserItem> users = _db.GetUsersByName(firstName, lastName);
                var dtoArr             = users.Select(x => MapToDTO(x)).ToArray();
                result = Ok(dtoArr);

                // We don't return the domain object, use DTO
                // result = Ok(users);
            }
            catch (Exception)
            {
                result = BadRequest(new { Message = "Get users failed." });
            }

            return(result);
        }