Inheritance: EntityBase
示例#1
0
        public Container CreateContainer(string name, Status status)
        {
            var request = new RestRequest("containers/", Method.POST)
            {
                RootElement = "Container"
            };
            request.AddParameter("Name", name);
            request.AddParameter("Status", status);
            PrepareCall(request);

            var container = new Container();
            _client.PostAsync<Container>(request,
                (response, restRequestAsyncHandle) =>
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                        if (response.Data != null) container = response.Data;
                        else
                            if (response.ErrorException != null)
                                throw response.ErrorException;
                }
            );
            return container;
        }
示例#2
0
        public Container UpdateContainer(int containerId, string name)
        {
            var request = new RestRequest("containers/{containerid}", Method.PUT)
            {
                RootElement = "Container"
            };
            request.AddUrlSegment("containerid", containerId.ToString(CultureInfo.InvariantCulture));
            request.AddParameter("Name", name);
            PrepareCall(request);

            var container = new Container();
            _client.PutAsync<Container>(request,
                (response, restRequestAsyncHandle) =>
                {
                    if (response.StatusCode == HttpStatusCode.OK)
                        if (response.Data != null) container = response.Data;
                        else
                            if (response.ErrorException != null)
                                throw response.ErrorException;
                }
            );
            return container;
        }