public async Task<IEnumerable<Site>> RegisterSiteAsync(Site site)
        {
            var client = new RestClient(baseUrl);

            var request = new RestRequest
            {
                Resource = "Sites",
                Method = Method.POST,
                RequestFormat = DataFormat.Json,
            };

            request.AddBody(site);

            var response = await client.ExecuteTaskAsync<List<Site>>(request);
            if (response.ErrorException != null)
            {
                const string message = "Error retrieving response.  Check inner details for more info.";
                var ex = new ApplicationException(message, response.ErrorException);
                throw ex;
            }

            return response.Data;
        }
예제 #2
0
 /// <summary>
 /// Registers or updates a <see cref="Site"/> and returns a list of registered <see cref="Site">Sites</see>.
 /// </summary>
 /// <param name="site">The <see cref="Site"/> being registered</param>
 /// <returns>All registered <see cref="Site">Sites</see></returns>
 public IEnumerable<Site> Post(Site site)
 {
     return server.RegisterSite(site);
 }