public IHttpActionResult Get(int businessCategoryId, string sort = "businessName", string fields = null) { try { List <string> lstOfFields = new List <string>(); if (fields != null) { lstOfFields = fields.ToLower().Split(',').ToList(); } var businesses = _repository.GetBusinesses(businessCategoryId); if (businesses == null) { return(NotFound()); } var businessesResult = businesses.ApplySort(sort).ToList().Select(b => _businessFactory.CreateDataShapedObject(b, lstOfFields)); return(Ok(businessesResult)); } catch (Exception) { return(InternalServerError()); } }