public void TestSyncQueryProperties() { ExpandQuery expandQuery = new ExpandQuery("attachments"); Assert.AreEqual( "$expand=attachments", expandQuery.Query); }
public void TestExpandQueryArray() { ExpandQuery expandQueryAttach = new ExpandQuery("attachments"); ExpandQuery expandQuerySubject = new ExpandQuery("subject"); ExpandQuery expandQueryArray = new ExpandQuery( expandQuerySubject, expandQueryAttach); Assert.AreEqual( "$expand=subject,attachments", expandQueryArray.Query); }
public void TestExpandSingleValueProperties() { SingleValueLegacyExtendedProperty prop = new SingleValueLegacyExtendedProperty(); prop.PropertyId = "String 0x4001001E"; SearchFilter filter = new SearchFilter.IsEqualTo( SingleValueLegacyExtendedPropertyObjectSchema.PropertyId, $"{{{prop.PropertyId}}}"); ExpandQuery expand = new ExpandQuery($"singleValueExtendedProperties({filter.Query})"); Assert.AreEqual( "$expand=singleValueExtendedProperties($filter=PropertyId eq '{String 0x4001001E}')", expand.Query); }
public void TestExpandQueryArrayWithExtendedProperties() { ExtendedPropertyDefinition extendedProperty1 = new ExtendedPropertyDefinition( MapiPropertyType.Boolean, 3092); ExtendedPropertyDefinition extendedProperty2 = new ExtendedPropertyDefinition( MapiPropertyType.String, 1153); SearchFilter.SearchFilterCollection filterCollection = new SearchFilter.SearchFilterCollection(FilterOperator.and); filterCollection.AddFilter( new SearchFilter.IsEqualTo( SingleValueLegacyExtendedPropertyObjectSchema.PropertyId, extendedProperty1.Definition)); filterCollection.AddFilter( new SearchFilter.IsEqualTo( SingleValueLegacyExtendedPropertyObjectSchema.PropertyId, extendedProperty2.Definition)); ExpandQuery expandQueryAttach = new ExpandQuery("attachments"); Assert.AreEqual( "$expand=attachments", expandQueryAttach.Query); ExpandExtendedPropertyQuery extendedPropertyExpandQuery = new ExpandExtendedPropertyQuery( filterCollection, PropertyValueType.SingleValueExtendedProperties); Assert.AreEqual( "$expand=SingleValueExtendedProperties($filter=PropertyId eq 'Boolean 0x0C14' and PropertyId eq 'String 0x0481')", extendedPropertyExpandQuery.Query); ExpandQuery arrayExpandQuery = new ExpandQuery( expandQueryAttach, extendedPropertyExpandQuery); Assert.AreEqual( "$expand=attachments,SingleValueExtendedProperties($filter=PropertyId eq 'Boolean 0x0C14' and PropertyId eq 'String 0x0481')", arrayExpandQuery.Query); }
public override async Task <BookResource> ConvertToResourceAsync(Book model, ExpandQuery expand) { var resource = new BookResource(); resource.Href = GetSingleResourceLink(model.Id); resource.Title = model.Title; resource.ISBN = model.ISBN; resource.Published = model.Published; resource.Condition = model.Condition.ToString(); if (expand.Contains(() => resource.Author)) { resource.Author = await AuthorAssembler.GetResourceByIdAsync(model.AuthorId); } else { resource.Author = UrlProvider.UriStringFor <AuthorController>(c => c.GetByIdAsync(model.AuthorId, null)); } if (!string.IsNullOrEmpty(model.LendingRecordId)) { if (expand.Contains(() => resource.LendingRecord)) { resource.LendingRecord = await LendingRecordAssembler.GetResourceByIdAsync(model.LendingRecordId); } else { resource.LendingRecord = UrlProvider.UriStringFor <LendingRecordController>(c => c.GetByIdAsync(model.LendingRecordId, null)); } } if (model.IsAvailable) { resource.Checkout = UrlProvider.UriStringFor <BorrowController>(c => c.CheckoutAsync(model.Id)); } else { resource.Checkin = UrlProvider.UriStringFor <BorrowController>(c => c.CheckinAsync(model.Id)); } return(resource); }
public ActionResult <Tuple <HashSet <Node>, HashSet <Edge> > > Expand([FromBody] ExpandQuery expandQuery) //informing front { var output = new List <Tuple <HashSet <Node>, HashSet <Edge> > >(); var nodes = new HashSet <Node>(); var edges = new HashSet <Edge>(); var accs = String.Join(' ', expandQuery.Accounts); var incomingEdgeSearchQuery = new EdgeSearchQuery() { DestinationAccount = accs }; var outcomingEdgeSearchQuery = new EdgeSearchQuery() { SourceAccount = accs }; incomingEdgeSearchQuery.SetFiltersFrom(expandQuery); outcomingEdgeSearchQuery.SetFiltersFrom(expandQuery); var nodesId = new HashSet <string>(); foreach (var edge in elasticService.Search <Edge>(incomingEdgeSearchQuery)) { nodesId.Add(edge.SourceAccount); edges.Add(edge); } foreach (var edge in elasticService.Search <Edge>(outcomingEdgeSearchQuery)) { nodesId.Add(edge.DestinationAccount); edges.Add(edge); } nodes.UnionWith(elasticService .Search <Node>( new NodeSearchQuery() { AccountId = String.Join(' ', nodesId) } ) ); return(new Tuple <HashSet <Node>, HashSet <Edge> >(nodes, edges)); }
public override async Task <LendingRecordResource> ConvertToResourceAsync(LendingRecord model, ExpandQuery expand) { var resource = new LendingRecordResource(); resource.Href = UrlProvider.UriStringFor <LendingRecordController>(c => c.GetByIdAsync(model.Id, expand.Value)); resource.CheckoutDate = model.CheckoutDate; resource.DueDate = model.DueDate; resource.ReturnedDate = model.ReturnedDate; resource.Span = model.Span; resource.UserId = model.UserId; resource.State = model.State.ToString(); if (expand.Contains(() => resource.Book)) { var book = await BookService.GetBookByIdAsync(model.BookId); resource.Book = await BookAssembler.ConvertToResourceAsync(book); } else { resource.Book = UrlProvider.UriStringFor <BookController>(c => c.GetByIdAsync(model.BookId, null)); } return(resource); }
public override async Task <AuthorResource> ConvertToResourceAsync(Author model, ExpandQuery expand) { var resource = new AuthorResource(); resource.Href = UrlProvider.UriStringFor <AuthorController>(c => c.GetByIdAsync(model.Id, expand.Value)); resource.FirstName = model.FirstName; resource.LastName = model.LastName; IEnumerable <Hyperlink <BookResource> > booksCollection; if (expand.Contains(() => resource.Books)) { var books = await BookService.GetBooksByIdsAsync(model.BookIds.ToArray()); booksCollection = await BookAssembler.ConvertToResourceEnumerableAsync(books); } else { //unexpanded hyperlinks var linksCollection = new List <Hyperlink <BookResource> >(); foreach (var bookId in model.BookIds) { string href = BookAssembler.GetSingleResourceLink(bookId); linksCollection.Add(href); } booksCollection = linksCollection; } resource.Books = booksCollection; return(resource); }