inBloomApiLibrary.SectionDataService.GetSectionsAsync C# (CSharp) Method

GetSectionsAsync() public method

Gets sections details asyncronously.
public GetSectionsAsync ( string accessToken, string userId, int limit, int offset ) : Task
accessToken string Access token has to send
userId string User id has to send
limit int
offset int
return Task
        public async Task<JArray> GetSectionsAsync(string accessToken, string userId, int? limit, int? offset)
        {
            Uri apiEndPoint = new Uri(String.Format(ApiHelper.BaseUrl + "/sections", userId));
            if (limit != null) { apiEndPoint = apiEndPoint.AddQuery("limit", limit.ToString()); }
            if (offset != null) { apiEndPoint = apiEndPoint.AddQuery("offset", offset.ToString()); }
            return (await ApiHelper.CallApiForGetAsync(apiEndPoint.ToString(), accessToken));
        }

Usage Example

示例#1
0
 public async Task<ActionResult> IndexAsync(int? limit, int? offset)
 {
     ViewBag.Title = "Classes";
     var sectionService = new SectionDataService();
     var sections = await sectionService.GetSectionsAsync(SessionInfo.Current.AccessToken, SessionInfo.Current.UserId, limit, offset)
                                         .ContinueWith(t => new SectionListViewModel { Sections = t.Result });
     return View("Index", sections);
 }