/// <summary> /// Gets the <see cref="Product"/> collection object that matches the selection criteria. /// </summary> /// <param name="args">The Args (see <see cref="ProductArgs"/>).</param> /// <param name="paging">The <see cref="PagingArgs"/>.</param> /// <returns>A <see cref="ProductCollectionResult"/>.</returns> public Task <ProductCollectionResult> GetByArgsAsync(ProductArgs 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(ProductArgsValidator.Default)) .Additional((__mv) => _getByArgsOnValidate?.Invoke(__mv, args, paging)) .Run().ThrowOnError(); if (_getByArgsOnBeforeAsync != null) { await _getByArgsOnBeforeAsync(args, paging); } var __result = await ProductDataSvc.GetByArgsAsync(args, paging); if (_getByArgsOnAfterAsync != null) { await _getByArgsOnAfterAsync(__result, args, paging); } Cleaner.Clean(__result); return __result; })); }
/// <summary> /// Gets the <see cref="Product"/> object that matches the selection criteria. /// </summary> /// <param name="id">The <see cref="Product"/> identifier.</param> /// <returns>The selected <see cref="Product"/> object where found; otherwise, <c>null</c>.</returns> public Task <Product> GetAsync(int id) { return(ManagerInvoker.Default.InvokeAsync(this, async() => { ExecutionContext.Current.OperationType = OperationType.Read; EntityBase.CleanUp(id); if (_getOnPreValidateAsync != null) { await _getOnPreValidateAsync(id); } MultiValidator.Create() .Add(id.Validate(nameof(id)).Mandatory()) .Additional((__mv) => _getOnValidate?.Invoke(__mv, id)) .Run().ThrowOnError(); if (_getOnBeforeAsync != null) { await _getOnBeforeAsync(id); } var __result = await ProductDataSvc.GetAsync(id); if (_getOnAfterAsync != null) { await _getOnAfterAsync(__result, id); } Cleaner.Clean(__result); return __result; })); }