Пример #1
0
        public async Task <bool> UpdateProject(string accessToken, Project project)
        {
            StringBuilder requestUri = new StringBuilder()
                                       .Append(this.SiteUrl)
                                       .Append("/_api/web/lists/getbyTitle('")
                                       .Append(this.ProjectsListName)
                                       .Append("')/getItemByStringId('")
                                       .Append(project.Id.ToString())
                                       .Append("')");

            XElement entry = project.ToXElement();

            StringContent       requestContent = new StringContent(entry.ToString());
            HttpResponseMessage response       = await this.Patch(requestUri.ToString(), accessToken, project.__eTag, requestContent);

            return(response.IsSuccessStatusCode);
        }
Пример #2
0
        public async Task <Project> CreateProject(string accessToken, Project project)
        {
            StringBuilder requestUri = new StringBuilder()
                                       .Append(this.SiteUrl)
                                       .Append("/_api/web/lists/getbyTitle('")
                                       .Append(this.ProjectsListName)
                                       .Append("')/items");

            XElement entry = project.ToXElement();

            StringContent       requestContent = new StringContent(entry.ToString());
            HttpResponseMessage response       = await this.Post(requestUri.ToString(), accessToken, requestContent);

            string responseString = await response.Content.ReadAsStringAsync();

            return(XElement.Parse(responseString).ToProject());
        }
        public async Task<Project> CreateProject(string accessToken, Project project)
        {
            StringBuilder requestUri = new StringBuilder()
                 .Append(this.SiteUrl)
                 .Append("/_api/web/lists/getbyTitle('")
                 .Append(this.ProjectsListName)
                 .Append("')/items");

            XElement entry = project.ToXElement();

            StringContent requestContent = new StringContent(entry.ToString());
            HttpResponseMessage response = await this.Post(requestUri.ToString(), accessToken, requestContent);
            string responseString = await response.Content.ReadAsStringAsync();

            return XElement.Parse(responseString).ToProject();

        }
        public async Task<bool> UpdateProject(string accessToken, Project project)
        {
            StringBuilder requestUri = new StringBuilder()
                .Append(SiteUrl)
                .Append("/_api/web/lists/getbyTitle('")
                .Append(ProjectsListName)
                .Append("')/getItemByStringId('")
                .Append(project.Id)
                .Append("')");

            XElement entry = project.ToXElement();

            StringContent requestContent = new StringContent(entry.ToString());
            HttpResponseMessage response = await Patch(requestUri.ToString(), accessToken, project.__eTag, requestContent);
            return response.IsSuccessStatusCode;
        }