Exemplo n.º 1
0
 private IEnumerable <JsonDocument> GetDocumentsWithoutBuffering(
     int take, bool hasEntityNames, HashSet <string> entityNames)
 {
     while (Api.TryMovePrevious(session, Documents) && take >= 0)
     {
         take--;
         yield return(ReadDocument(hasEntityNames, entityNames)());
     }
 }
Exemplo n.º 2
0
        public async Task <HttpResponseMessage> Students(int id, int courseId)
        {
            var course = await db.Courses.Where(c => c.CourseID == courseId).Include(c => c.Enrollments).SingleAsync();

            var enrollments = course.Enrollments;

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(string.Format(Url.Link <InstructorController>(c => c.Index()) + "/courses/{0}/students", courseId)),
                    Version = "1.0"
                }
            };

            foreach (var item in enrollments.Select(e => new Item
            {
                Data = new List <Data>
                {
                    new Data {
                        Name = "full-name", Prompt = "Name", Value = e.Student.FullName
                    },
                    new Data {
                        Name = "grade", Prompt = "Grade", Value = e.Grade.ToString()
                    },
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc.ToHttpResponseMessage());
        }
        public async Task <HttpResponseMessage> GetProjects(int page = 0, string containsName = "")
        {
            var document = new ReadDocument();

            var collectionSelfUri = MakeUri <ProjectsController>(c => c.GetProjects(page, containsName));

            //root object
            var allProjectsCollection = new Collection {
                Version = "1.0", Href = collectionSelfUri
            };

            //partial representation of all the projects
            const string idProperty = "id", nameProperty = "name";
            var          allProjectsFound   = Context.Projects.Where(p => p.Name.Contains(containsName)).OrderBy(p => p.Name);
            var          projectsConsidered = await allProjectsFound.Skip(PageSize *page).Take(PageSize).ToListAsync();

            foreach (var project in projectsConsidered)
            {
                var particularProjectUri = MakeUri <ProjectsController>(c => c.FindSingleProject(project.Name));
                var item = new Item {
                    Href = particularProjectUri
                };
                item.Data.Add(new Data {
                    Name = idProperty, Value = project.Id.ToString(), Prompt = "ID of project"
                });
                item.Data.Add(new Data {
                    Name = nameProperty, Value = project.Name, Prompt = "name of project"
                });
                allProjectsCollection.Items.Add(item);
            }

            //template to insert new project
            var template = allProjectsCollection.Template.Data;

            template.Add(new Data {
                Name = Rels.Template.ProjectsPropertyName, Prompt = "name of project"
            });
            template.Add(new Data {
                Name = Rels.Template.ProjectsPropertyTags, Prompt = "Each Tag's name separated by a plus sign"
            });

            //queries para obter uma lista de projetos onde expression está contido no nome
            allProjectsCollection.Queries.Add(new Query
            {
                Href   = MakeUri <ProjectsController>(c => c.GetProjects(page, "")),
                Rel    = "search",
                Prompt = "Search for projects with a name that contains the given expression.",
                Data   = new List <Data> {
                    new Data {
                        Name = Rels.Search.ContainsName, Prompt = "The keyword to look for inside the names of each project."
                    }
                }
            });


            SetupPaginationLinks(allProjectsCollection, allProjectsFound.Count(), page, previousPageUri(page), nextPageUri(page));

            document.Collection = allProjectsCollection;
            return(Request.SetupResponse <IReadDocument>(HttpStatusCode.OK, document, CollectionResourceMediatype));
        }
Exemplo n.º 4
0
        public async Task <ReadDocument> Students(int id, int courseId)
        {
            var course = await db.Courses.Where(c => c.CourseID == courseId).Include(c => c.Enrollments).ThenInclude(e => e.Student).SingleAsync();

            var enrollments = course.Enrollments;

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(Url.Action("Students", "Instructor", new { id, courseId }, Request.GetUri().Scheme, null)),
                    Version = "1.0"
                }
            };

            foreach (var item in enrollments.Select(e => new Item
            {
                Data = new List <Data>
                {
                    new Data {
                        Name = "full-name", Prompt = "Name", Value = e.Student.FullName
                    },
                    new Data {
                        Name = "grade", Prompt = "Grade", Value = e.Grade.ToString()
                    },
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc);
        }
Exemplo n.º 5
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var window = new MainWindow();

            var welcomeText = new ReadDocument((FlowDocument)Application.Current.Resources["WelcomeDocument"])
            {
                Name = "Welcome"
            };

            var docMan = new ReadDocumentManager(new List <ReadDocument>()
            {
                welcomeText
            });

            // Create the ViewModel to which the main window binds
            var viewModel = new MainWindowViewModel(docMan);

            // When the ViewModel asks to be closed, close the window
            viewModel.RequestClose += delegate { window.Close(); };

            // set the DataContext to the viewModel
            window.DataContext = viewModel;

            window.Show();
        }
Exemplo n.º 6
0
        public async Task <ReadDocument> Index()
        {
            var instructors = await db
                              .Instructors
                              .Include(i => i.OfficeAssignment)
                              .ToListAsync();

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(Url.Action("Index", "Instructor", null, Request.GetUri().Scheme, null)),
                    Version = "1.0"
                }
            };

            foreach (var item in instructors.Select(i => new Item
            {
                Href = new Uri(Url.Action("Details", "Instructor", new { id = i.ID }, Request.GetUri().Scheme, null)),
                Data = new List <Data>
                {
                    new Data
                    {
                        Name = "last-name",
                        Prompt = "Last Name",
                        Value = i.LastName
                    },
                    new Data
                    {
                        Name = "first-name",
                        Prompt = "First Name",
                        Value = i.FirstMidName
                    },
                    new Data
                    {
                        Name = "hire-date",
                        Prompt = "Hire Date",
                        Value = i.HireDate.ToShortDateString()
                    },
                    new Data
                    {
                        Name = "office",
                        Prompt = "Office",
                        Value = i.OfficeAssignment?.Location
                    },
                },
                Links = new List <Link>
                {
                    new Link {
                        Href = new Uri(Url.Action("Courses", "Instructor", new { id = i.ID }, Request.GetUri().Scheme, null)), Prompt = "Courses", Rel = "courses"
                    }
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc);
        }
        public void WhenToObjectContentIsInvokedThenObjectContentIsReturned()
        {
            var document = new ReadDocument();
            var content  = document.ToObjectContent() as ObjectContent <IReadDocument>;

            content.ShouldNotBeNull();
            content.Value.ShouldEqual(document);
        }
Exemplo n.º 8
0
 public ReadDocumentViewModel(ReadDocument doc)
 {
     _doc = doc;
     // Watch for property changes in the ReadDocument so they can be send along.
     _doc.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(_doc_PropertyChanged);
     _readWord             = new TextRange(_doc.Document.ContentStart, _doc.Document.ContentStart);
     _reading              = false;
 }
    public static IEnumerable <TeamSnapApi.Team> UnpackTeams(this ReadDocument doc)
    {
        return(doc.Collection.Items.Select(x => new TeamSnapApi.Team
        {
            Id = int.Parse(x.Data.GetDataByName("id").Value.ToString()),

            Name = x.Data.GetDataByName("name").Value.ToString()
        }));
    }
        public void WhenToHttpResponseMessageIsInvokedOnReadDocumentThenResponseMessageIsReturned()
        {
            var document = new ReadDocument();
            var response = document.ToHttpResponseMessage();

            response.ShouldNotBeNull();
            response.Content.ShouldNotBeNull();
            response.Content.ShouldBeType <ObjectContent <IReadDocument> >();
        }
Exemplo n.º 11
0
        public override async Task Run(ReadDocument <TDocument> message, IContext context)
        {
            var document = await Data.Context.LoadAsync <TDocument>(message.Id);

            await context.Emit(new ReadDocumentResult <TDocument> {
                 
                Document = document
            });
        }
Exemplo n.º 12
0
        public async Task <ReadDocument> Index()
        {
            var instructors = await db.Instructors.Include(i => i.OfficeAssignment).ToListAsync();

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(Url.Action("Index")),
                    Version = "1.0"
                }
            };

            foreach (var item in instructors.Select(i => new Item
            {
                Href = Url.Link <InstructorController>(c => c.Details(i.ID)),
                Data = new List <Data>
                {
                    new Data
                    {
                        Name = "last-name",
                        Prompt = "Last Name",
                        Value = i.LastName
                    },
                    new Data
                    {
                        Name = "first-name",
                        Prompt = "First Name",
                        Value = i.FirstMidName
                    },
                    new Data
                    {
                        Name = "hire-date",
                        Prompt = "Hire Date",
                        Value = i.HireDate.ToShortDateString()
                    },
                    new Data
                    {
                        Name = "office",
                        Prompt = "Office",
                        Value = i.OfficeAssignment == null ? null : i.OfficeAssignment.Location
                    },
                },
                Links = new List <Link>
                {
                    new Link {
                        Href = new Uri(Url.Link <InstructorController>(c => c.Courses(i.ID)) + "/courses"), Prompt = "Courses", Rel = "courses"
                    }
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc.ToHttpResponseMessage());
        }
Exemplo n.º 13
0
        private static List <SpeakerDTO> ParseSpeakers(ReadDocument readDocument)
        {
            var speakers = readDocument.Collection.Items.Select(item =>
                                                                new SpeakerDTO
            {
                Name = item.Data[0].Value
            }).ToList();

            return(speakers);
        }
Exemplo n.º 14
0
        private void addDocToRDVMs(ReadDocument doc)
        {
            var docvm = new ReadDocumentViewModel(doc);

            _rdvms.Add(docvm);

            // When remove is requested remove the document from the manager, whih will inturn remove the docvm
            docvm.RequestClose = (s, e) => { _docsMan.Remove(doc); };

            //set the new document as selected
            Document = docvm;
        }
    public async Task <IEnumerable <Team> > GetActiveTeamsForUser(int userId)
    {
        if (userId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(userId));
        }

        string str = await _httpClient.GetStringAsync(string.Format(ActiveTeamsQueryTemplate, userId));

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        return(doc.UnpackTeams().ToList());
    }
    public async Task <long> GetTeamOwner(long teamId)
    {
        if (teamId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(teamId));
        }

        string str = await _httpClient.GetStringAsync(string.Format(TeamOwnerQueryTemplate, teamId));

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        return(doc.Collection.Items.Select(x => long.Parse(x.Data.GetDataByName("id").Value.ToString())).First());
    }
    public async Task <Team> GetTeamAsync(long teamId)
    {
        if (teamId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(teamId));
        }

        string str = await _httpClient.GetStringAsync(string.Format(TeamByIdQueryTemplate, teamId));

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        return(doc.UnpackTeams().FirstOrDefault());
    }
    public async Task <IEnumerable <TeamMember> > GetTeamMembers(long teamId)
    {
        if (teamId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(teamId));
        }

        string str = await _httpClient.GetStringAsync(string.Format(TeamMembersQueryTemplate, teamId));

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        return(doc.UnpackTeamMembers().ToList());
    }
        public CollectionJsonControllerTest()
        {
            reader = new Mock <ICollectionJsonDocumentReader <string> >();
            writer = new Mock <ICollectionJsonDocumentWriter <string> >();

            testReadDocument = new ReadDocument();
            testReadDocument.Collection.Href = new Uri("http://test.com");
            testWriteDocument = new WriteDocument();

            writer.Setup(w => w.Write(It.IsAny <IEnumerable <string> >())).Returns(testReadDocument);
            reader.Setup(r => r.Read(It.IsAny <WriteDocument>())).Returns("Test");
            controller = new TestController(writer.Object, reader.Object);
            controller.ConfigureForTesting(new HttpRequestMessage(HttpMethod.Get, "http://localhost/test/"));
        }
    public async Task <User> GetMe()
    {
        string str = await _httpClient.GetStringAsync(MeQuery);

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        return(doc.Collection.Items.Select(x => new User
        {
            Id = long.Parse(x.Data.GetDataByName("id").Value.ToString()),
            Email = x.Data.GetDataByName("email").Value.ToString(),
            FirstName = x.Data.GetDataByName("first_name").Value.ToString(),
            LastName = x.Data.GetDataByName("last_name").Value.ToString(),
        }).First());
    }
 public static IEnumerable <TeamSnapApi.TeamMember> UnpackTeamMembers(this ReadDocument doc)
 {
     return(doc.Collection.Items.Select(x => new TeamSnapApi.TeamMember
     {
         MemberId = long.Parse(x.Data.GetDataByName("id").Value.ToString()),
         FirstName = x.Data.GetDataByName("first_name").Value?.ToString(),
         LastName = x.Data.GetDataByName("last_name").Value?.ToString(),
         EmailAddress = ((JArray)(x.Data.GetDataByName("email_addresses")?.Value))?.ToArray().FirstOrDefault()?.ToString(),
         PrimaryPhoneNumber = ((JArray)(x.Data.GetDataByName("phone_numbers")?.Value))?.ToArray().FirstOrDefault()?.ToString(),
         IsManager = x.Data.GetDataByName("is_manager").Value.ToObject <bool>(),
         IsNonPlayer = x.Data.GetDataByName("is_non_player").Value.ToObject <bool>(),
         JerseyNumber = x.Data.GetDataByName("jersey_number")?.Value?.ToObject <string>()
     }));
 }
        public CollectionJsonContent(Collection collection)
        {
            _serializer = JsonSerializer.Create(new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting = Formatting.Indented,
                ContractResolver = new CollectionJsonContractResolver()
            });

            collection.Version = "1.0";
            _readDocument = new ReadDocument();
            _readDocument.Collection = collection;

            Headers.ContentType = new MediaTypeHeaderValue(Collection.MediaType);
        }
Exemplo n.º 23
0
        public CollectionJsonContent(Collection collection)
        {
           
            _serializer = JsonSerializer.Create(new JsonSerializerSettings
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    Formatting = Formatting.Indented,
                    ContractResolver = new CamelCasePropertyNamesContractResolver()
                });

            collection.Version = "1.0";
            _readDocument = new ReadDocument(collection);
            
            Headers.ContentType = new MediaTypeHeaderValue("application/vnd.collection+json");
        }
        public CollectionJsonContent(Collection collection)
        {
            _serializer = JsonSerializer.Create(new JsonSerializerSettings
            {
                NullValueHandling = NullValueHandling.Ignore,
                Formatting        = Formatting.Indented,
                ContractResolver  = new CollectionJsonContractResolver()
            });

            collection.Version       = "1.0";
            _readDocument            = new ReadDocument();
            _readDocument.Collection = collection;

            Headers.ContentType = new MediaTypeHeaderValue("application/vnd.collection+json");
        }
    public async Task <long> FindOrCreateLocationIdByName(string locationName, long teamId)
    {
        if (teamId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(teamId));
        }

        string str = await _httpClient.GetStringAsync($"/locations/search?team_id={teamId}");

        ReadDocument rdoc = JsonConvert.DeserializeObject <ReadDocument>(str);


        var target = rdoc.Collection.Items
                     .Select(x => new { Id = long.Parse(x.Data.GetDataByName("id").Value.ToString()), Name = x.Data.GetDataByName("name").Value.ToString() })
                     .Where(x => x.Name.Equals(locationName, StringComparison.InvariantCultureIgnoreCase)).FirstOrDefault();

        if (target != null)
        {
            return(target.Id);
        }
        else
        {
            WriteDocument doc = new WriteDocument
            {
                Template = new Template()
            };

            doc.Template.Data.Add(new Data()
            {
                Name = "name", Value = locationName
            });

            doc.Template.Data.Add(new Data()
            {
                Name = "team_id", Value = teamId
            });

            HttpResponseMessage resp = await _httpClient.PostAsJsonAsync("/locations", doc);

            string str2 = await resp.Content.ReadAsStringAsync();

            ReadDocument rdoc2 = JsonConvert.DeserializeObject <ReadDocument>(str2);

            resp.EnsureSuccessStatusCode();

            return(rdoc2.Collection.Items.Select(x => long.Parse(x.Data.GetDataByName("id").Value.ToString())).First());
        }
    }
Exemplo n.º 26
0
        public async Task <ReadDocument> Courses(int id)
        {
            var courses = await db.CourseInstructors
                          .Where(i => i.InstructorID == id)
                          .Include(ci => ci.Course)
                          .ThenInclude(c => c.Department)
                          .ToListAsync();

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(Url.Action("Courses", "Instructor", new { id }, Request.GetUri().Scheme, null)),
                    Version = "1.0"
                }
            };

            foreach (var item in courses.Select(c => new Item
            {
                Data = new List <Data>
                {
                    new Data {
                        Name = "number", Prompt = "Number", Value = c.CourseID.ToString()
                    },
                    new Data {
                        Name = "title", Prompt = "Title", Value = c.Course.Title
                    },
                    new Data {
                        Name = "dept", Prompt = "Department", Value = c.Course.Department?.Name
                    }
                },
                Links = new List <Link>
                {
                    new Link
                    {
                        Href = new Uri(Url.Action("Students", "Instructor", new { id, courseId = c.CourseID }, Request.GetUri().Scheme, null)),
                        Prompt = "Students",
                        Rel = "students"
                    }
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc);
        }
Exemplo n.º 27
0
        public async Task <HttpResponseMessage> Courses(int id)
        {
            var instructor = await db.Instructors.Where(i => i.ID == id).Include(i => i.Courses).SingleAsync();

            var courses = instructor.Courses;

            var doc = new ReadDocument
            {
                Collection =
                {
                    Href    = new Uri(Url.Link <InstructorController>(c => c.Courses(id)) + "/courses"),
                    Version = "1.0"
                }
            };

            foreach (var item in courses.Select(c => new Item
            {
                Data = new List <Data>
                {
                    new Data {
                        Name = "number", Prompt = "Number", Value = c.CourseID.ToString()
                    },
                    new Data {
                        Name = "title", Prompt = "Title", Value = c.Title
                    },
                    new Data {
                        Name = "dept", Prompt = "Department", Value = c.Department.Name
                    }
                },
                Links = new List <Link>
                {
                    new Link
                    {
                        Href = new Uri(string.Format(Url.Link <InstructorController>(x => x.Index()) + "{0}/courses/{1}/students", id, c.CourseID)),
                        Prompt = "Students",
                        Rel = "students"
                    }
                }
            }))
            {
                doc.Collection.Items.Add(item);
            }

            return(doc.ToHttpResponseMessage());
        }
    public async Task <long> CreateTeam(CreateTeamRequest team)
    {
        WriteDocument doc = new WriteDocument
        {
            Template = new Template()
        };

        doc.Template.Data.Add(new Data()
        {
            Name = "name", Value = team.Name
        });
        doc.Template.Data.Add(new Data()
        {
            Name = "sport_id", Value = team.SportId
        });
        doc.Template.Data.Add(new Data()
        {
            Name = "location_country", Value = team.LocationCountry
        });
        doc.Template.Data.Add(new Data()
        {
            Name = "time_zone", Value = team.IANATimeZone
        });
        doc.Template.Data.Add(new Data()
        {
            Name = "location_postal_code", Value = team.LocationPostalCode
        });

        HttpResponseMessage resp = await _httpClient.PostAsJsonAsync("/teams", doc);

        string str = await resp.Content.ReadAsStringAsync();

        ReadDocument rDoc = JsonConvert.DeserializeObject <ReadDocument>(str);

        if (resp.IsSuccessStatusCode)
        {
            return(rDoc.UnpackTeams().First().Id);
        }
        else
        {
            throw new HttpRequestException(rDoc.Collection.Error.Message);
        }
    }
Exemplo n.º 29
0
        private static List <SessionDTO> ParseSessions(ReadDocument readDocument)
        {
            var sessions = readDocument.Collection.Items.Select(item =>
            {
                var session = new SessionDTO();
                foreach (var data in item.Data)
                {
                    switch (data.Name)
                    {
                    case "Title": session.Title = data.Value; break;

                    case "SpeakerName": session.SpeakerName = data.Value; break;
                    }
                }
                return(session);
            }
                                                                ).ToList();

            return(sessions);
        }
        public async Task <HttpResponseMessage> GetTags(string projectName)
        {
            var document = new ReadDocument();

            var collectionSelfUri = MakeUri <TagController>(c => c.GetTags(projectName));

            //root object
            var tagsCollection = new Collection {
                Version = "1.0", Href = collectionSelfUri
            };

            //partial rep of each tag
            var tags = await Context.ProjectTagSet.Where(t => t.ProjectName.Equals(projectName)).ToListAsync();

            foreach (var tag in tags)
            {
                var particularProjectUri = MakeUri <TagController>(c => c.GetTagByName(projectName, tag.TagName));
                var item = new Item {
                    Href = particularProjectUri
                };
                item.Data.Add(new Data {
                    Name = "name", Value = tag.TagName, Prompt = "name of tag"
                });
                tagsCollection.Items.Add(item);
            }

            //template to insert new project
            var template = tagsCollection.Template.Data;

            template.Add(new Data {
                Name = "name", Prompt = "name of tag"
            });
            template.Add(new Data {
                Name = "top_entity", Prompt = "name of project", Value = projectName
            });


            document.Collection = tagsCollection;
            return(Request.SetupResponse <IReadDocument>(HttpStatusCode.OK, document, CollectionResourceMediatype));
        }
    public static IEnumerable <TeamSnapApi.Event> UnpackEvents(this ReadDocument doc)
    {
        return(doc.Collection.Items.Select(x =>
        {
            TeamSnapApi.Event r = new TeamSnapApi.Event
            {
                Id = long.Parse(x.Data.GetDataByName("id").Value.ToString()),

                TeamId = long.Parse(x.Data.GetDataByName("team_id").Value.ToString()),

                Name = x.Data.GetDataByName("name").Value.ToString(),

                IsTimeTBD = bool.Parse(x.Data.GetDataByName("is_tbd").Value.ToString()),

                StartDate = x.Data.GetDataByName("start_date").Value.ToObject <DateTime>(),

                IsCancelled = bool.Parse(x.Data.GetDataByName("is_canceled").Value.ToString()),

                IsGame = bool.Parse(x.Data.GetDataByName("is_game").Value.ToString()),

                LocationName = x.Data.GetDataByName("location_name").Value.ToString(),

                OpponentName = x.Data.GetDataByName("opponent_name").Value.ToString(),

                Notes = x.Data.GetDataByName("notes").Value.ToString()
            };

            int.TryParse(x.Data.GetDataByName("duration_in_minutes").Value.ToString(), out int duration);

            r.DurationMinutes = duration;


            int.TryParse(x.Data.GetDataByName("minutes_to_arrive_early").Value.ToString(), out int arriveEarlyMin);

            r.ArriveEarlyMinutes = arriveEarlyMin;

            return r;
        }));
    }
    public async Task <long?> FindTeamMemberIdByEmailAddress(long teamId, string emailAddress)
    {
        if (teamId <= 0)
        {
            throw new ArgumentOutOfRangeException(nameof(teamId));
        }

        if (string.IsNullOrWhiteSpace(emailAddress))
        {
            throw new ArgumentException("must provide valid email address!", nameof(emailAddress));
        }

        string str = await _httpClient.GetStringAsync(string.Format(FindTeamMemberIdByEmailTemplate, emailAddress, teamId));

        ReadDocument doc = JsonConvert.DeserializeObject <ReadDocument>(str);

        if (doc.Collection.Items.Any())
        {
            doc.Collection.Items.Select(x => long.Parse(x.Data.GetDataByName("member_id").Value.ToString())).First();
        }
        return(null);
    }
Exemplo n.º 33
0
 /// <summary>
 /// Reads a <see cref="HttpWebResponse"/> response.
 /// </summary>
 /// <param name="response">
 /// The <see cref="HttpWebResponse"/> object being read.
 /// </param>
 /// <param name="read">
 /// A <see cref="ReadDocument"/> delagate that can be used to put the response into a <see cref="XmlDocument"/>
 /// object.
 /// </param>
 private void ReadResponse(HttpWebResponse response, ReadDocument read)
 {
     using (StreamReader reader = new StreamReader(response.GetResponseStream()))
     {
         // create new XmlDocument, load the XML response into it, then run the delagate if one is specified
         XmlDocument doc = new XmlDocument();
         doc.Load(reader);
         if (read != null)
         {
             read(doc);
         }
     }
 }
Exemplo n.º 34
0
 /// <summary>
 /// Reads the response.
 /// </summary>
 /// <param name="response">The response.</param>
 private void ReadResponse(HttpWebResponse response, ReadDocument read)
 {
     using (StreamReader reader = new StreamReader(response.GetResponseStream()))
     {
         XmlDocument doc = new XmlDocument();
         doc.Load(reader);
         if (read != null)
         {
             read(doc);
         }
     }
 }