예제 #1
0
        public Task <PersonCollectionResult> GetAll2Async()
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                if (_getAll2OnPreValidateAsync != null)
                {
                    await _getAll2OnPreValidateAsync().ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Additional((__mv) => _getAll2OnValidate?.Invoke(__mv))
                .Run().ThrowOnError();

                if (_getAll2OnBeforeAsync != null)
                {
                    await _getAll2OnBeforeAsync().ConfigureAwait(false);
                }
                var __result = await _dataService.GetAll2Async().ConfigureAwait(false);
                if (_getAll2OnAfterAsync != null)
                {
                    await _getAll2OnAfterAsync(__result).ConfigureAwait(false);
                }
                return Cleaner.Clean(__result);
            }));
        }
예제 #2
0
        /// <summary>
        /// Updates the <see cref="Robot"/> object.
        /// </summary>
        /// <param name="value">The <see cref="Robot"/> object.</param>
        /// <param name="id">The <see cref="Robot"/> identifier.</param>
        /// <returns>A refreshed <see cref="Robot"/> object.</returns>
        public Task <Robot> UpdateAsync(Robot value, Guid id)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                if (value != null)
                {
                    value.Id = id;
                }
                EntityBase.CleanUp(value, id);
                if (_updateOnPreValidateAsync != null)
                {
                    await _updateOnPreValidateAsync(value, id);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Mandatory().Entity(RobotValidator.Default))
                .Additional((__mv) => _updateOnValidate?.Invoke(__mv, value, id))
                .Run().ThrowOnError();

                if (_updateOnBeforeAsync != null)
                {
                    await _updateOnBeforeAsync(value, id);
                }
                var __result = await RobotDataSvc.UpdateAsync(value);
                if (_updateOnAfterAsync != null)
                {
                    await _updateOnAfterAsync(__result, id);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #3
0
        /// <summary>
        /// Deletes the <see cref="CustomerGroup"/> object.
        /// </summary>
        /// <param name="id">The <see cref="CustomerGroup"/> identifier.</param>
        /// <param name="company">The Company (see <see cref="RefDataNamespace.Company"/>).</param>
        public Task DeleteAsync(string id, RefDataNamespace.Company company)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Delete;
                EntityBase.CleanUp(id);
                if (_deleteOnPreValidateAsync != null)
                {
                    await _deleteOnPreValidateAsync(id, company).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Add(company.Validate(nameof(company)).Mandatory().IsValid())
                .Additional((__mv) => _deleteOnValidate?.Invoke(__mv, id, company))
                .Run().ThrowOnError();

                if (_deleteOnBeforeAsync != null)
                {
                    await _deleteOnBeforeAsync(id, company).ConfigureAwait(false);
                }
                await CustomerGroupDataSvc.DeleteAsync(id, company).ConfigureAwait(false);
                if (_deleteOnAfterAsync != null)
                {
                    await _deleteOnAfterAsync(id, company).ConfigureAwait(false);
                }
            }));
        }
예제 #4
0
        public Task <Person> MergeAsync(Guid fromId, Guid toId)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                Cleaner.CleanUp(fromId, toId);
                if (_mergeOnPreValidateAsync != null)
                {
                    await _mergeOnPreValidateAsync(fromId, toId).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(fromId.Validate(nameof(fromId)).Mandatory())
                .Add(toId.Validate(nameof(toId)).Mandatory().CompareValue(CompareOperator.NotEqual, fromId, nameof(fromId).ToSentenceCase() !))
                .Additional((__mv) => _mergeOnValidate?.Invoke(__mv, fromId, toId))
                .Run().ThrowOnError();

                if (_mergeOnBeforeAsync != null)
                {
                    await _mergeOnBeforeAsync(fromId, toId).ConfigureAwait(false);
                }
                var __result = await _dataService.MergeAsync(fromId, toId).ConfigureAwait(false);
                if (_mergeOnAfterAsync != null)
                {
                    await _mergeOnAfterAsync(__result, fromId, toId).ConfigureAwait(false);
                }
                return Cleaner.Clean(__result);
            }));
예제 #5
0
        /// <summary>
        /// Creates the <see cref="Gender"/> object.
        /// </summary>
        /// <param name="value">The <see cref="Gender"/> object.</param>
        /// <returns>A refreshed <see cref="Gender"/> object.</returns>
        public Task <Gender> CreateAsync(Gender value)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Create;
                EntityBase.CleanUp(value);
                if (_createOnPreValidateAsync != null)
                {
                    await _createOnPreValidateAsync(value).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Mandatory().Entity(new ReferenceDataValidator <Gender>()))
                .Additional((__mv) => _createOnValidate?.Invoke(__mv, value))
                .Run().ThrowOnError();

                if (_createOnBeforeAsync != null)
                {
                    await _createOnBeforeAsync(value).ConfigureAwait(false);
                }
                var __result = await GenderDataSvc.CreateAsync(value).ConfigureAwait(false);
                if (_createOnAfterAsync != null)
                {
                    await _createOnAfterAsync(__result).ConfigureAwait(false);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #6
0
        public Task <PersonDetailCollectionResult> GetDetailByArgsAsync(PersonArgs?args, PagingArgs?paging)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                Cleaner.CleanUp(args);
                if (_getDetailByArgsOnPreValidateAsync != null)
                {
                    await _getDetailByArgsOnPreValidateAsync(args, paging).ConfigureAwait(false);
                }

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

                if (_getDetailByArgsOnBeforeAsync != null)
                {
                    await _getDetailByArgsOnBeforeAsync(args, paging).ConfigureAwait(false);
                }
                var __result = await _dataService.GetDetailByArgsAsync(args, paging).ConfigureAwait(false);
                if (_getDetailByArgsOnAfterAsync != null)
                {
                    await _getDetailByArgsOnAfterAsync(__result, args, paging).ConfigureAwait(false);
                }
                return Cleaner.Clean(__result);
            }));
        }
예제 #7
0
        public Task <TransactionCollectionResult> GetTransactionsAsync(string?accountId, TransactionArgs?args, PagingArgs?paging)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                EntityBase.CleanUp(accountId, args);
                if (_getTransactionsOnPreValidateAsync != null)
                {
                    await _getTransactionsOnPreValidateAsync(accountId, args, paging).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(accountId.Validate(nameof(accountId)).Mandatory().Common(Validators.AccountId))
                .Add(args.Validate(nameof(args)).Entity(TransactionArgsValidator.Default))
                .Additional((__mv) => _getTransactionsOnValidate?.Invoke(__mv, accountId, args, paging))
                .Run().ThrowOnError();

                if (_getTransactionsOnBeforeAsync != null)
                {
                    await _getTransactionsOnBeforeAsync(accountId, args, paging).ConfigureAwait(false);
                }
                var __result = await TransactionDataSvc.GetTransactionsAsync(accountId, args, paging).ConfigureAwait(false);
                if (_getTransactionsOnAfterAsync != null)
                {
                    await _getTransactionsOnAfterAsync(__result, accountId, args, paging).ConfigureAwait(false);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #8
0
        /// <summary>
        /// Deletes the <see cref="Robot"/> object.
        /// </summary>
        /// <param name="id">The <see cref="Robot"/> identifier.</param>
        public Task DeleteAsync(Guid id)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Delete;
                EntityBase.CleanUp(id);
                if (_deleteOnPreValidateAsync != null)
                {
                    await _deleteOnPreValidateAsync(id);
                }

                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Additional((__mv) => _deleteOnValidate?.Invoke(__mv, id))
                .Run().ThrowOnError();

                if (_deleteOnBeforeAsync != null)
                {
                    await _deleteOnBeforeAsync(id);
                }
                await RobotDataSvc.DeleteAsync(id);
                if (_deleteOnAfterAsync != null)
                {
                    await _deleteOnAfterAsync(id);
                }
            }));
        }
예제 #9
0
        #pragma warning restore CS0649
        #endregion

        /// <summary>
        /// Gets the <see cref="Gender"/> object that matches the selection criteria.
        /// </summary>
        /// <param name="id">The <see cref="Gender"/> identifier.</param>
        /// <returns>The selected <see cref="Gender"/> object where found; otherwise, <c>null</c>.</returns>
        public Task <Gender> GetAsync(Guid id)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                EntityBase.CleanUp(id);
                if (_getOnPreValidateAsync != null)
                {
                    await _getOnPreValidateAsync(id).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Additional((__mv) => _getOnValidate?.Invoke(__mv, id))
                .Run().ThrowOnError();

                if (_getOnBeforeAsync != null)
                {
                    await _getOnBeforeAsync(id).ConfigureAwait(false);
                }
                var __result = await GenderDataSvc.GetAsync(id).ConfigureAwait(false);
                if (_getOnAfterAsync != null)
                {
                    await _getOnAfterAsync(__result, id).ConfigureAwait(false);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #10
0
        public Task <TripPerson> UpdateAsync(TripPerson value, string?id)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                value.Id = id;
                EntityBase.CleanUp(value, id);
                if (_updateOnPreValidateAsync != null)
                {
                    await _updateOnPreValidateAsync(value, id).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)))
                .Additional((__mv) => _updateOnValidate?.Invoke(__mv, value, id))
                .Run().ThrowOnError();

                if (_updateOnBeforeAsync != null)
                {
                    await _updateOnBeforeAsync(value, id).ConfigureAwait(false);
                }
                var __result = await TripPersonDataSvc.UpdateAsync(value).ConfigureAwait(false);
                if (_updateOnAfterAsync != null)
                {
                    await _updateOnAfterAsync(__result, id).ConfigureAwait(false);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #11
0
        /// <summary>
        /// Gets the <see cref="CustomerGroup"/> object that matches the selection criteria.
        /// </summary>
        /// <param name="id">The <see cref="CustomerGroup"/> identifier.</param>
        /// <param name="company">The Company (see <see cref="RefDataNamespace.Company"/>).</param>
        /// <returns>The selected <see cref="CustomerGroup"/> object where found; otherwise, <c>null</c>.</returns>
        public Task <CustomerGroup> GetAsync(string id, RefDataNamespace.Company company)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                EntityBase.CleanUp(id);
                if (_getOnPreValidateAsync != null)
                {
                    await _getOnPreValidateAsync(id, company);
                }

                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Add(company.Validate(nameof(company)).Mandatory().IsValid())
                .Additional((__mv) => _getOnValidate?.Invoke(__mv, id, company))
                .Run().ThrowOnError();

                if (_getOnBeforeAsync != null)
                {
                    await _getOnBeforeAsync(id, company);
                }
                var __result = await CustomerGroupDataSvc.GetAsync(id, company);
                if (_getOnAfterAsync != null)
                {
                    await _getOnAfterAsync(__result, id, company);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #12
0
        /// <summary>
        /// Upserts a <see cref="CustomerGroupCollection"/> as a batch.
        /// </summary>
        /// <param name="value">The Value (see <see cref="CustomerGroupCollection"/>).</param>
        /// <param name="company">The Company (see <see cref="RefDataNamespace.Company"/>).</param>
        public Task UpdateBatchAsync(CustomerGroupCollection value, RefDataNamespace.Company company)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Unspecified;
                if (value != null)
                {
                    value?.ForEach(__item => __item.Company = company);
                }
                EntityBase.CleanUp(value);
                if (_updateBatchOnPreValidateAsync != null)
                {
                    await _updateBatchOnPreValidateAsync(value, company);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Mandatory().Collection(minCount: 1, maxCount: 1, item: new Beef.Validation.Rules.CollectionRuleItem <CustomerGroup>(CustomerGroupValidator.Default)))
                .Add(company.Validate(nameof(company)).Mandatory().IsValid())
                .Additional((__mv) => _updateBatchOnValidate?.Invoke(__mv, value, company))
                .Run().ThrowOnError();

                if (_updateBatchOnBeforeAsync != null)
                {
                    await _updateBatchOnBeforeAsync(value, company);
                }
                await CustomerGroupDataSvc.UpdateBatchAsync(value);
                if (_updateBatchOnAfterAsync != null)
                {
                    await _updateBatchOnAfterAsync(value, company);
                }
            }));
        }
예제 #13
0
        /// <summary>
        /// Updates the <see cref="CustomerGroup"/> object.
        /// </summary>
        /// <param name="value">The <see cref="CustomerGroup"/> object.</param>
        /// <param name="id">The <see cref="CustomerGroup"/> identifier.</param>
        /// <param name="company">The Company (see <see cref="RefDataNamespace.Company"/>).</param>
        /// <returns>A refreshed <see cref="CustomerGroup"/> object.</returns>
        public Task <CustomerGroup> UpdateAsync(CustomerGroup value, string id, RefDataNamespace.Company company)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                if (value != null)
                {
                    value.Id = id; value.Company = company;
                }
                EntityBase.CleanUp(value, id);
                if (_updateOnPreValidateAsync != null)
                {
                    await _updateOnPreValidateAsync(value, id, company);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Mandatory().Entity(CustomerGroupValidator.Default))
                .Add(company.Validate(nameof(company)).IsValid())
                .Additional((__mv) => _updateOnValidate?.Invoke(__mv, value, id, company))
                .Run().ThrowOnError();

                if (_updateOnBeforeAsync != null)
                {
                    await _updateOnBeforeAsync(value, id, company);
                }
                var __result = await CustomerGroupDataSvc.UpdateAsync(value);
                if (_updateOnAfterAsync != null)
                {
                    await _updateOnAfterAsync(__result, id, company);
                }
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #14
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;
            }));
        }
예제 #15
0
        public Task <Person> CreateAsync(Person value)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Create;
                Cleaner.CleanUp(value);
                if (_createOnPreValidateAsync != null)
                {
                    await _createOnPreValidateAsync(value).ConfigureAwait(false);
                }

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Entity(PersonValidator.Default))
                .Additional((__mv) => _createOnValidate?.Invoke(__mv, value))
                .Run().ThrowOnError();

                if (_createOnBeforeAsync != null)
                {
                    await _createOnBeforeAsync(value).ConfigureAwait(false);
                }
                var __result = await _dataService.CreateAsync(value).ConfigureAwait(false);
                if (_createOnAfterAsync != null)
                {
                    await _createOnAfterAsync(__result).ConfigureAwait(false);
                }
                return Cleaner.Clean(__result);
            }));
        }
예제 #16
0
        public Task <Person?> GetAsync(Guid id) => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            Cleaner.CleanUp(id);
            await MultiValidator.Create()
            .Add(id.Validate(nameof(id)).Mandatory())
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            return(Cleaner.Clean(await _dataService.GetAsync(id).ConfigureAwait(false)));
        }, BusinessInvokerArgs.Read);
예제 #17
0
        public async Task <TransactionCollectionResult> GetTransactionsAsync(string?accountId, TransactionArgs?args, PagingArgs?paging) => await ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            Cleaner.CleanUp(accountId, args);
            await MultiValidator.Create()
            .Add(accountId.Validate(nameof(accountId)).Mandatory().Common(Validators.AccountId))
            .Add(args.Validate(nameof(args)).Entity().With <IValidator <TransactionArgs> >())
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            return(Cleaner.Clean(await _dataService.GetTransactionsAsync(accountId, args, paging).ConfigureAwait(false)));
        }, BusinessInvokerArgs.Read).ConfigureAwait(false);
예제 #18
0
        public Task <PostalInfo?> GetPostCodesAsync(RefDataNamespace.Country?country, string?state, string?city) => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            Cleaner.CleanUp(country, state, city);
            await MultiValidator.Create()
            .Add(country.Validate(nameof(country)).Mandatory().IsValid())
            .Add(state.Validate(nameof(state)).Mandatory())
            .Add(city.Validate(nameof(city)).Mandatory())
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            return(Cleaner.Clean(await _dataService.GetPostCodesAsync(country, state, city).ConfigureAwait(false)));
        }, BusinessInvokerArgs.Read);
예제 #19
0
        public Task DeleteAsync(Guid id)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Delete;
                Cleaner.CleanUp(id);
                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Run().ThrowOnError();

                await _dataService.DeleteAsync(id).ConfigureAwait(false);
            }));
        }
예제 #20
0
        public Task <ProductCollectionResult> GetByArgsAsync(ProductArgs?args, PagingArgs?paging)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                Cleaner.CleanUp(args);
                MultiValidator.Create()
                .Add(args.Validate(nameof(args)).Entity(ProductArgsValidator.Default))
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.GetByArgsAsync(args, paging).ConfigureAwait(false));
            }));
        }
예제 #21
0
        public Task <Product?> GetAsync(int id)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                Cleaner.CleanUp(id);
                MultiValidator.Create()
                .Add(id.Validate(nameof(id)).Mandatory())
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.GetAsync(id).ConfigureAwait(false));
            }));
        }
예제 #22
0
        public Task <Balance?> GetBalanceAsync(string?accountId)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                Cleaner.CleanUp(accountId);
                MultiValidator.Create()
                .Add(accountId.Validate(nameof(accountId)).Mandatory())
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.GetBalanceAsync(accountId).ConfigureAwait(false));
            }));
        }
예제 #23
0
        public Task <PersonCollectionResult> GetAll2Async() => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            await(_getAll2OnPreValidateAsync?.Invoke() ?? Task.CompletedTask).ConfigureAwait(false);

            await MultiValidator.Create()
            .Additional((__mv) => _getAll2OnValidate?.Invoke(__mv))
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            await(_getAll2OnBeforeAsync?.Invoke() ?? Task.CompletedTask).ConfigureAwait(false);
            var __result = await _dataService.GetAll2Async().ConfigureAwait(false);
            await(_getAll2OnAfterAsync?.Invoke(__result) ?? Task.CompletedTask).ConfigureAwait(false);
            return(Cleaner.Clean(__result));
        }, BusinessInvokerArgs.Read);
예제 #24
0
        public Task <TransactionCollectionResult> GetTransactionsAsync(string?accountId, TransactionArgs?args, PagingArgs?paging)
        {
            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Read;
                Cleaner.CleanUp(accountId, args);
                MultiValidator.Create()
                .Add(accountId.Validate(nameof(accountId)).Mandatory().Common(Validators.AccountId))
                .Add(args.Validate(nameof(args)).Entity(TransactionArgsValidator.Default))
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.GetTransactionsAsync(accountId, args, paging).ConfigureAwait(false));
            }));
        }
예제 #25
0
        public Task DeleteAsync(Guid id) => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            Cleaner.CleanUp(id);
            await(_deleteOnPreValidateAsync?.Invoke(id) ?? Task.CompletedTask).ConfigureAwait(false);

            await MultiValidator.Create()
            .Add(id.Validate(nameof(id)).Mandatory())
            .Additional((__mv) => _deleteOnValidate?.Invoke(__mv, id))
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            await(_deleteOnBeforeAsync?.Invoke(id) ?? Task.CompletedTask).ConfigureAwait(false);
            await _dataService.DeleteAsync(id).ConfigureAwait(false);
            await(_deleteOnAfterAsync?.Invoke(id) ?? Task.CompletedTask).ConfigureAwait(false);
        }, BusinessInvokerArgs.Delete);
예제 #26
0
        public Task <PersonDetailCollectionResult> GetDetailByArgsAsync(PersonArgs?args, PagingArgs?paging) => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            Cleaner.CleanUp(args);
            await(_getDetailByArgsOnPreValidateAsync?.Invoke(args, paging) ?? Task.CompletedTask).ConfigureAwait(false);

            await MultiValidator.Create()
            .Add(args.Validate(nameof(args)).Entity().With <IValidator <PersonArgs> >())
            .Additional((__mv) => _getDetailByArgsOnValidate?.Invoke(__mv, args, paging))
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            await(_getDetailByArgsOnBeforeAsync?.Invoke(args, paging) ?? Task.CompletedTask).ConfigureAwait(false);
            var __result = await _dataService.GetDetailByArgsAsync(args, paging).ConfigureAwait(false);
            await(_getDetailByArgsOnAfterAsync?.Invoke(__result, args, paging) ?? Task.CompletedTask).ConfigureAwait(false);
            return(Cleaner.Clean(__result));
        }, BusinessInvokerArgs.Read);
예제 #27
0
        public Task <Contact> CreateAsync(Contact value)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Create;
                Cleaner.CleanUp(value);
                MultiValidator.Create()
                .Add(value.Validate(nameof(value)))
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.CreateAsync(value).ConfigureAwait(false));
            }));
        }
예제 #28
0
        public Task <Contact> UpdateAsync(Contact value)
        {
            return(ManagerInvoker.Default.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                EntityBase.CleanUp(value);

                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Mandatory())
                .Run().ThrowOnError();

                var __result = await _dataService.UpdateAsync(value).ConfigureAwait(false);
                Cleaner.Clean(__result);
                return __result;
            }));
        }
예제 #29
0
        public Task <Gender> UpdateAsync(Gender value, Guid id)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                value.Id = id;
                Cleaner.CleanUp(value);
                MultiValidator.Create()
                .Add(value.Validate(nameof(value)).Entity(new ReferenceDataValidator <Gender>()))
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.UpdateAsync(value).ConfigureAwait(false));
            }));
        }
예제 #30
0
        public Task <TripPerson> UpdateAsync(TripPerson value, string?id)
        {
            value.Validate(nameof(value)).Mandatory().Run().ThrowOnError();

            return(ManagerInvoker.Current.InvokeAsync(this, async() =>
            {
                ExecutionContext.Current.OperationType = OperationType.Update;
                value.Id = id;
                Cleaner.CleanUp(value);
                MultiValidator.Create()
                .Add(value.Validate(nameof(value)))
                .Run().ThrowOnError();

                return Cleaner.Clean(await _dataService.UpdateAsync(value).ConfigureAwait(false));
            }));
        }