/// <summary> /// Creates the <see cref="Robot"/> object. /// </summary> /// <param name="value">The <see cref="Robot"/> object.</param> /// <returns>A refreshed <see cref="Robot"/> object.</returns> public Task <Robot> CreateAsync(Robot value) { return(ManagerInvoker.Default.InvokeAsync(this, async() => { ExecutionContext.Current.OperationType = OperationType.Create; EntityBase.CleanUp(value); if (_createOnPreValidateAsync != null) { await _createOnPreValidateAsync(value); } MultiValidator.Create() .Add(value.Validate(nameof(value)).Mandatory().Entity(RobotValidator.Default)) .Additional((__mv) => _createOnValidate?.Invoke(__mv, value)) .Run().ThrowOnError(); if (_createOnBeforeAsync != null) { await _createOnBeforeAsync(value); } var __result = await RobotDataSvc.CreateAsync(value); if (_createOnAfterAsync != null) { await _createOnAfterAsync(__result); } Cleaner.Clean(__result); return __result; })); }
/// <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; })); }
/// <summary> /// Gets the <see cref="Robot"/> object that matches the selection criteria. /// </summary> /// <param name="id">The <see cref="Robot"/> identifier.</param> /// <returns>The selected <see cref="Robot"/> object where found; otherwise, <c>null</c>.</returns> public Task <Robot> GetAsync(Guid 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 RobotDataSvc.GetAsync(id); if (_getOnAfterAsync != null) { await _getOnAfterAsync(__result, id); } Cleaner.Clean(__result); return __result; })); }
/// <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); } })); }