Beispiel #1
0
        /// <summary>
        /// Gets the <see cref="Robot"/> collection object that matches the selection criteria.
        /// </summary>
        /// <param name="args">The Args (see <see cref="RobotArgs"/>).</param>
        /// <param name="paging">The <see cref="PagingArgs"/>.</param>
        /// <returns>A <see cref="RobotCollectionResult"/>.</returns>
        public Task <RobotCollectionResult> GetByArgsAsync(RobotArgs args, PagingArgs paging)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                EntityBase.CleanUp(args);
                if (_getByArgsOnPreValidateAsync != null)
                {
                    await _getByArgsOnPreValidateAsync(args, paging);
                }

                MultiValidator.Create()
                .Add(args.Validate(nameof(args)).Entity(RobotArgsValidator.Default))
                .Additional((__mv) => _getByArgsOnValidate?.Invoke(__mv, args, paging))
                .Run().ThrowOnError();

                if (_getByArgsOnBeforeAsync != null)
                {
                    await _getByArgsOnBeforeAsync(args, paging);
                }
                var __result = await RobotDataSvc.GetByArgsAsync(args, paging);
                if (_getByArgsOnAfterAsync != null)
                {
                    await _getByArgsOnAfterAsync(__result, args, paging);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
Beispiel #2
0
        public IActionResult GetByArgs(string modelNo = default(string), string serialNo = default(string))
        {
            var args = new RobotArgs {
                ModelNo = modelNo, SerialNo = serialNo
            };

            return(new WebApiGet <RobotCollectionResult, RobotCollection, Robot>(this, () => Factory.Create <IRobotManager>().GetByArgsAsync(args, WebApiQueryString.CreatePagingArgs(this)),
                                                                                 operationType: OperationType.Read, statusCode: HttpStatusCode.OK, alternateStatusCode: HttpStatusCode.NoContent));
        }
Beispiel #3
0
        public IActionResult GetByArgs([FromQuery(Name = "model-no")] string?modelNo = default, [FromQuery(Name = "serial-no")] string?serialNo = default, [FromQuery(Name = "power-sources")] List <string>?powerSources = default)
        {
            var args = new RobotArgs {
                ModelNo = modelNo, SerialNo = serialNo, PowerSourcesSids = powerSources
            };

            return(new WebApiGet <RobotCollectionResult, RobotCollection, Robot>(this, () => Factory.Create <IRobotManager>().GetByArgsAsync(args, WebApiQueryString.CreatePagingArgs(this)),
                                                                                 operationType: OperationType.Read, statusCode: HttpStatusCode.OK, alternateStatusCode: HttpStatusCode.NoContent));
        }
Beispiel #4
0
 /// <summary>
 /// Gets the <see cref="Robot"/> collection object that matches the selection criteria.
 /// </summary>
 /// <param name="args">The Args (see <see cref="RobotArgs"/>).</param>
 /// <param name="paging">The <see cref="PagingArgs"/>.</param>
 /// <returns>A <see cref="RobotCollectionResult"/>.</returns>
 public Task <RobotCollectionResult> GetByArgsAsync(RobotArgs args, PagingArgs paging)
 {
     return(DataInvoker.Default.InvokeAsync(this, async() =>
     {
         RobotCollectionResult __result = new RobotCollectionResult(paging);
         var __dataArgs = CosmosDbArgs.Create("Items", PartitionKey.None, __result.Paging);
         if (_getByArgsOnBeforeAsync != null)
         {
             await _getByArgsOnBeforeAsync(args, __dataArgs);
         }
         __result.Result = CosmosDb.Default.Query <Robot>(__dataArgs, q => _getByArgsOnQuery == null ? q : _getByArgsOnQuery(q, args, __dataArgs)).SelectQuery <RobotCollection>();
         if (_getByArgsOnAfterAsync != null)
         {
             await _getByArgsOnAfterAsync(__result, args);
         }
         return __result;
     }, new BusinessInvokerArgs {
         ExceptionHandler = _getByArgsOnException
     }));
 }
Beispiel #5
0
 /// <summary>
 /// Gets the <see cref="Robot"/> collection object that matches the selection criteria.
 /// </summary>
 /// <param name="args">The Args (see <see cref="RobotArgs"/>).</param>
 /// <param name="paging">The <see cref="PagingArgs"/>.</param>
 /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param>
 /// <returns>A <see cref="WebApiAgentResult"/>.</returns>
 public Task <WebApiAgentResult <RobotCollectionResult> > GetByArgsAsync(RobotArgs args, PagingArgs paging = null, WebApiRequestOptions requestOptions = null)
 {
     return(RobotServiceAgent.GetByArgsAsync(args, paging, requestOptions));
 }
Beispiel #6
0
 private IQueryable <Model.Robot> GetByArgsOnQuery(IQueryable <Model.Robot> q, RobotArgs args, ICosmosDbArgs dbArgs)
 {
     q = q.WhereWildcard(x => x.ModelNo, args?.ModelNo);
     q = q.WhereWildcard(x => x.SerialNo, args?.SerialNo);
     q = q.WhereWith(args?.PowerSources, x => args.PowerSources.ToCodeList().Contains(x.PowerSource));
     return(q.OrderBy(x => x.SerialNo));
 }
Beispiel #7
0
 private IQueryable <Robot> GetByArgsOnQuery(IQueryable <Robot> q, RobotArgs args, ICosmosDbArgs dbArgs)
 {
     q = q.WhereWildcard(x => x.ModelNo, args?.ModelNo);
     q = q.WhereWildcard(x => x.SerialNo, args?.SerialNo);
     return(q.OrderBy(x => x.SerialNo));
 }
Beispiel #8
0
 /// <summary>
 /// Gets the <see cref="Robot"/> collection object that matches the selection criteria.
 /// </summary>
 /// <param name="args">The Args (see <see cref="RobotArgs"/>).</param>
 /// <param name="paging">The <see cref="PagingArgs"/>.</param>
 /// <param name="requestOptions">The optional <see cref="WebApiRequestOptions"/>.</param>
 /// <returns>A <see cref="WebApiAgentResult"/>.</returns>
 public Task <WebApiAgentResult <RobotCollectionResult> > GetByArgsAsync(RobotArgs args, PagingArgs paging = null, WebApiRequestOptions requestOptions = null)
 {
     return(base.GetCollectionResultAsync <RobotCollectionResult, RobotCollection, Robot>("api/v1/robots", requestOptions: requestOptions,
                                                                                          args: new WebApiArg[] { new WebApiArg <RobotArgs>("args", args, WebApiArgType.FromUriUseProperties), new WebApiPagingArgsArg("paging", paging) }));
 }