コード例 #1
0
        public async Task <IActionResult> SearchTroubleAsync([FromQuery] Client.TroubleSearchInfo searchInfo,
                                                             CancellationToken cancellationToken)
        {
            cancellationToken.ThrowIfCancellationRequested();

            var modelSearchInfo =
                Converter.TroubleSearchInfoConverter.Convert(searchInfo ?? new Client.TroubleSearchInfo());
            var modelTroubleList =
                await troubleRepository.SearchAsync(modelSearchInfo, cancellationToken).ConfigureAwait(false);

            var clientTroubleList = modelTroubleList
                                    .Select(Converter.TroubleConverter.Convert)
                                    .ToImmutableList();

            return(Ok(clientTroubleList));
        }
コード例 #2
0
        public static Model.TroubleSearchInfo Convert(Client.TroubleSearchInfo clientSearchInfo)
        {
            if (clientSearchInfo == null)
            {
                throw new ArgumentNullException(nameof(clientSearchInfo));
            }

            Model.TroubleStatus?[] statuses = null;

            if (clientSearchInfo.Status != null)
            {
                statuses = clientSearchInfo.Status.Select(TroubleConverterUtils.ConvertStatus).ToArray();
            }

            var modelSearchInfo = new Model.TroubleSearchInfo
            {
                Offset   = clientSearchInfo.Offset,
                Limit    = clientSearchInfo.Limit,
                Tags     = clientSearchInfo.Tag,
                Statuses = statuses
            };

            return(modelSearchInfo);
        }