예제 #1
0
        public async Task <ActionResult <StatementResponse> > GetStatement([FromQuery] StatementArguments args, CancellationToken cancellation)
        {
            var serverTime = DateTimeOffset.UtcNow;
            var result     = await _service.GetStatement(args, cancellation);

            // Flatten and Trim
            var relatedEntities = Flatten(result.Data, cancellation);

            var response = new StatementResponse
            {
                Closing              = result.Closing,
                ClosingQuantity      = result.ClosingQuantity,
                ClosingMonetaryValue = result.ClosingMonetaryValue,
                Opening              = result.Opening,
                OpeningQuantity      = result.OpeningQuantity,
                OpeningMonetaryValue = result.OpeningMonetaryValue,
                TotalCount           = result.Count,
                CollectionName       = ControllerUtilities.GetCollectionName(typeof(DetailsEntry)),
                RelatedEntities      = relatedEntities,
                Result     = result.Data,
                ServerTime = serverTime,
                Skip       = args.Skip,
                Top        = result.Data.Count
            };

            return(Ok(response));
        }
예제 #2
0
        public async Task <ActionResult <StatementResponse> > GetStatement([FromQuery] StatementArguments args, CancellationToken cancellation)
        {
            return(await ControllerUtilities.InvokeActionImpl(async() =>
            {
                var serverTime = DateTimeOffset.UtcNow;
                var(data, opening, openingQuantity, openingMonetaryValue, closing, closingQuantity, closingMonetaryValue, count) = await _service.GetStatement(args, cancellation);

                // Flatten and Trim
                var relatedEntities = FlattenAndTrim(data, cancellation);

                var response = new StatementResponse
                {
                    Closing = closing,
                    ClosingQuantity = closingQuantity,
                    ClosingMonetaryValue = closingMonetaryValue,
                    Opening = opening,
                    OpeningQuantity = openingQuantity,
                    OpeningMonetaryValue = openingMonetaryValue,
                    TotalCount = count,
                    CollectionName = ControllerUtilities.GetCollectionName(typeof(DetailsEntry)),
                    RelatedEntities = relatedEntities,
                    Result = data,
                    ServerTime = serverTime,
                    Skip = args.Skip,
                    Top = data.Count
                };

                return Ok(response);
            }
                                                              , _logger));
        }