/// <inheritdoc /> public async Task <IActionResult> GetSingleAsync(string filter) { try { var filtered = filter != null; IGetSingleBasket <T> basket; if (filtered) { var parsedFilter = new FilterParser <T>(filter).Parse(); basket = new GetSingleBasket <T>(new GetSingleRequest <T>(parsedFilter)); } else { basket = new GetSingleBasket <T>(); } await _shaft.SendAsync(basket); return(new OkObjectResult(basket.AscentPayload)); } catch (Exception ex) { return(GetErrorResult(ex)); } }
private void PrintOrganismCounts() { var frogCountBasket = new GetSingleBasket <FrogCount>(); var tadpoleCountBasket = new GetSingleBasket <TadpoleCount>(); var tasks = new Task[] { _frogCountMine.SendAsync(frogCountBasket), _tadpoleCountMine.SendAsync(tadpoleCountBasket) }; Task.WaitAll(tasks); System.Console.WriteLine( $"There are {frogCountBasket.AscentPayload.Count} frogs and {tadpoleCountBasket.AscentPayload.Count} tadpoles"); }
public void Construct() { var filter = new Filter <Frog>(new[] { new FilterTerm(nameof(Frog.Name), FilterOperators.StartsWith, "Fr") }); var request = new GetSingleRequest <Frog>(filter); Assert.Same(filter, request.Filter); var basket = new GetSingleBasket <Frog>(request); Assert.Equal(typeof(Frog), basket.DataType); Assert.Same(request, basket.DescentPayload); basket = new GetSingleBasket <Frog>(new GetSingleRequest <Frog>()); Assert.Equal(typeof(Frog), basket.DataType); Assert.Null(basket.DescentPayload.Filter); }
public async Task GetSingle() { var mine = new FrogMine("allowed"); var basket = new GetSingleBasket <Frog>(); await mine.SendAsync(basket); Assert.Equal(465, basket.AscentPayload.Id); mine = new FrogMine("GetSingle"); basket = new GetSingleBasket <Frog>(); await mine.SendAsync(basket); Assert.Equal(465, basket.AscentPayload.Id); mine = new FrogMine("not-allowed"); basket = new GetSingleBasket <Frog>(); await Assert.ThrowsAnyAsync <ShaftException>(() => mine.SendAsync(basket)); }