public async Task OnLoaded() { IsBusy = true; var navParam = (SnapshotsViewNavParams)NavigationParam; _groupByCriteria = navParam.GroupByCriteria; var payload = navParam.SnapshotsIdsource; Parent = payload; IEnumerable <LocationSnapshot> snapshots = null; RaisePropertyChanged(nameof(CanAddSnapshot)); if (payload is Location location) { snapshots = await _locationSnapshotDataService.GetSnapshotsByLocationIdAsync(location.Id); } else if (payload is SnapshotGroup group) { snapshots = await _locationSnapshotDataService.GetSnapshotsByIdsAsync(group.SnapshotIds); } var miniatures = await _pictureService.GetSnapshotMiniaturesAsync(snapshots); foreach (var miniature in miniatures) { var thumbnail = await _bitmapConverter.GetBitmapAsync(miniature.Data); SnapshotThumbnails.Add(new SnapshotThumbnail { Snapshot = miniature.Snapshot, Thumbnail = thumbnail }); } IsBusy = false; }
private async Task <IEnumerable <SnapshotGroup> > GetSnapshotGroups(GroupByCriteria groupBy) { var groupsUrl = await GetGroupsUrl(); groupsUrl = $"{groupsUrl}?groupBy={groupBy.ToString()}"; var result = await _webClient.GetAsync <IEnumerable <SnapshotGroup> >(groupsUrl); return(result); }
public async Task <IActionResult> GroupSnapshots(GroupByCriteria groupBy) { if (groupBy == GroupByCriteria.None) { _logger.LogWarning("Bad request. Invalid group by criteria."); return(BadRequest()); } var dataFetchOperation = _locationSnapshotDataService.ChooseGroupByOperation(groupBy); var snapshotGroups = await dataFetchOperation(); var result = Mapper.Map <IEnumerable <SnapshotGroup>, IEnumerable <SnapshotGroupDto> >(snapshotGroups); return(Ok(result)); }
public void GroupByTest() { var testCriteria = new GroupByCriteria { GroupBy = new [] { "Houses.OwnerId", "Houses.Category" }, SelectClause = new SelectClause { Select = "Count(1) , Houses.OwnerId , Houses.Category", IsExpression = true } }; var builder = new TestQueryBuilder <GroupByCriteria>(testCriteria); var query = builder.Build(); Assert.AreEqual( "Select Count(1) , Houses.OwnerId , Houses.Category from Houses GROUP BY Houses.OwnerId , Houses.Category", SimplifyString(query.Sql)); }
public Func <Task <IEnumerable <SnapshotGroup> > > ChooseGroupByOperation(GroupByCriteria groupBy) { switch (groupBy) { case GroupByCriteria.CreatedDate: return(new Func <Task <IEnumerable <SnapshotGroup> > >(() => GroupSnapshotsByCreatedDateAsync(DateTime.Now))); case GroupByCriteria.Longitude: return(new Func <Task <IEnumerable <SnapshotGroup> > >(() => GroupSnapshotsByLongitudeAsync())); case GroupByCriteria.Latitude: return(new Func <Task <IEnumerable <SnapshotGroup> > >(() => GroupSnapshotsByLatitudeAsync())); case GroupByCriteria.Altitude: return(new Func <Task <IEnumerable <SnapshotGroup> > >(() => GroupSnapshotsByAltitudeAsync())); default: throw new ArgumentOutOfRangeException("Could not recognize the specified group by criteria."); } }
public Func <Task <IEnumerable <SnapshotGroup> > > ChooseGroupByOperation(GroupByCriteria groupBy) { var groups = Task.Run(async() => await GetSnapshotGroups(groupBy).ConfigureAwait(false)).Result; return(new Func <Task <IEnumerable <SnapshotGroup> > >(() => Task.FromResult(groups))); }