Пример #1
0
        public async Task <Models.Assignment> CreateAssignment(string projectId, string taskId, string assetId, string userId)
        {
            Models.Assignment assignment = null;
            //var baseAddress = new Uri("http://localhost:8080");
            var baseAddress     = new Uri("http://" + host + ":" + port);
            var cookieContainer = new CookieContainer();

            using (var handler = new HttpClientHandler()
            {
                CookieContainer = cookieContainer
            })
                using (var client = new HttpClient(handler)
                {
                    BaseAddress = baseAddress
                })
                {
                    cookieContainer.Add(baseAddress, new Cookie(projectId + "_user_id", userId));

                    HttpResponseMessage response = await client.GetAsync("/projects/" + projectId + "/tasks/" + taskId + "/assets/" + assetId + "/assignments");

                    if (response.IsSuccessStatusCode)
                    {
                        var str = await response.Content.ReadAsStringAsync();

                        JToken token = JObject.Parse(str);
                        assignment = ((Models.Assignment)JsonConvert.DeserializeObject <Models.Assignment>(token.ToString()));
                    }
                }
            return(assignment);
        }
Пример #2
0
        public async Task <Models.Assignment> GetAssignmentData(string projectId, string assignmentId)
        {
            string state = "";

            Models.Assignment   assignment = null;
            HttpResponseMessage response   = await client.GetAsync("/projects/" + projectId + "/assignments/" + assignmentId);

            if (response.IsSuccessStatusCode)
            {
                var str = await response.Content.ReadAsStringAsync();

                JToken token = JObject.Parse(str);
                //state = token.Value<string>("name");
                assignment = ((Models.Assignment)JsonConvert.DeserializeObject <Models.Assignment>(token.First.First.ToString()));
            }
            return(assignment);
        }