コード例 #1
0
        public async Task <IActionResult> GetPeople(
            [FromRoute] string organizationId,
            [FromQuery(Name = "$filter")] string filter   = "",
            [FromQuery(Name = "$orderby")] string orderBy = "",
            [FromQuery(Name = "$top")] int top            = 100,
            [FromQuery(Name = "$skip")] int skip          = 0)
        {
            try
            {
                ODataHelper <TeamMemberViewModel> oData = new ODataHelper <TeamMemberViewModel>();
                string queryString = "";

                if (HttpContext != null &&
                    HttpContext.Request != null &&
                    HttpContext.Request.QueryString != null &&
                    HttpContext.Request.QueryString.HasValue)
                {
                    queryString = HttpContext.Request.QueryString.Value;
                }

                var newNode = oData.ParseOrderByQuery(queryString);
                if (newNode == null)
                {
                    newNode = new OrderByNode <TeamMemberViewModel>();
                }

                Guid orgId  = Guid.Parse(organizationId);
                var  result = _membershipManager.GetPeopleInOrganization(orgId, newNode.PropertyName, newNode.Direction, skip, top);

                return(Ok(result));
            }
            catch (Exception ex)
            {
                return(ex.GetActionResult());
            }
        }