Пример #1
0
        public async Task <Robot> CreateAsync(Robot value) => await ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            await value.Validate().Mandatory().RunAsync(throwOnError: true).ConfigureAwait(false);

            value.Id = await _guidIdentifierGenerator.GenerateIdentifierAsync <Robot>().ConfigureAwait(false);
            Cleaner.CleanUp(value);
            await value.Validate().Entity().With <IValidator <Robot> >().RunAsync(throwOnError: true).ConfigureAwait(false);
            return(Cleaner.Clean(await _dataService.CreateAsync(value).ConfigureAwait(false)));
        }, BusinessInvokerArgs.Create).ConfigureAwait(false);
Пример #2
0
        public Task <Person> CreateAsync(Person value) => ManagerInvoker.Current.InvokeAsync(this, async() =>
        {
            await value.Validate().Mandatory().RunAsync(throwOnError: true).ConfigureAwait(false);

            value.Id = await _guidIdGen.GenerateIdentifierAsync <Person>().ConfigureAwait(false);
            Cleaner.CleanUp(value);
            await(_createOnPreValidateAsync?.Invoke(value) ?? Task.CompletedTask).ConfigureAwait(false);

            await MultiValidator.Create()
            .Add(value.Validate(nameof(value)).Entity().With <IValidator <Person> >())
            .Additional((__mv) => _createOnValidate?.Invoke(__mv, value))
            .RunAsync(throwOnError: true).ConfigureAwait(false);

            await(_createOnBeforeAsync?.Invoke(value) ?? Task.CompletedTask).ConfigureAwait(false);
            var __result = await _dataService.CreateAsync(value).ConfigureAwait(false);
            await(_createOnAfterAsync?.Invoke(__result) ?? Task.CompletedTask).ConfigureAwait(false);
            return(Cleaner.Clean(__result));
        }, BusinessInvokerArgs.Create);