public Task<OperationResponse> DeleteUserAsync(Validated<int> id) { return id.Validate(new IdValidator()) .IfValidAsync(() => _unitOfWorkFactory.DoAsync(() => { _userRepository.Delete(id); })); }
private void Edit_Validated(object sender, EventArgs e) { Validated?.Invoke(this, e); }
/// <summary> /// Called when the object is validated. /// </summary> protected virtual void OnValidated() { Validated.SafeInvoke(this); }
private void RaiseValidated(IEnumerable <IValidationResult> validationResults) { Validated?.Invoke(this, new DataEventArgs <IEnumerable <IValidationResult> >(validationResults)); }
public CategoryService(IUnitOfWork unitOfWork) { Validated.NotNull(unitOfWork, nameof(unitOfWork)); this.unitOfWork = unitOfWork; }
private static void assertInvalid <E, A>(List <E> expected, Validated <E, A> v) { Assert.False(v.isValid); Assert.Equal(expected, v.getInvalid); }
public async Task<UserDto> GetByIdAsync(Validated<int> id) { var user = await _context.Users.FindAsync(id.Value); return user.ToDto<UserDto>(); }
public WebSiteController(IWebsiteService websiteService) { Validated.NotNull(websiteService, nameof(websiteService)); this.websiteService = websiteService; }
private void Validate_OnClick(object sender, RoutedEventArgs e) => Validated?.Invoke(this, EventArgs.Empty);
public EFRepository(MsSqlDbContext context) { Validated.NotNull(context, nameof(context)); this.context = context; }
public async Task<HttpResponseMessage> DeleteAsync(Validated<int> id) { await _userService.DeleteUserAsync(id); return Request.CreateResponse(HttpStatusCode.OK); }
public static Validated <string, A> invalid <A>(this string e) { return(Validated <string, A> .invalid(e)); }
public static Validated <E, A> invalid <E, A>(this E e) { return(Validated <E, A> .invalid(e)); }
public static Validated <string, A> valid <A>(this A a) { return(Validated <string, A> .valid(a)); }
/// <summary> /// Execute a validated command by sending the message to an aggregate. If the command is valid, the command will be processed /// by the aggregate. When the command has been handled successfully, and events are returned as a result, the events /// are aggregated to create the next state of the viewmodel, by calling the user defined Update function. /// Then a notification is sent to signal the state of the viewmodel has changed. This will trigger the component /// to rerender, so that it can show the correct state in the user interface. This rerendering triggers the user defined View /// function, which signifies how the view should be rendered /// </summary> /// <param name="target">The aggrgate that will handle the command</param> /// <param name="command">The validate command that the aggregate will handle, if it is valid. </param> /// <returns>When the command is not valid, it will return Some errors, None otherwise</returns> protected async Task <Option <Error[]> > Dispatch(Aggregate <TCommand, TEvent> target, Validated <TCommand> command) { Result <CommandResult <TEvent>, Error[]> result = await target.Accept(command); switch (result) { case Ok <CommandResult <TEvent>, Error[]>(var commandResult): _shouldRender = commandResult.Events.Any(); ViewModel = Update(ViewModel, commandResult.Events); StateHasChanged(); return(None <Error[]>()); case Error <CommandResult <TEvent>, Error[]>(var errors): _shouldRender = true; ViewModel.Errors = errors; StateHasChanged(); return(Some(errors)); default: _shouldRender = false; throw new ArgumentOutOfRangeException(nameof(result)); } }
public static Validated <TResult> Bind <T, TResult>(this Validated <T> result, Func <T, Validated <TResult> > function) => result switch {
// ReSharper disable UnusedParameter.Local private static void assertValid <E, A>(A expected, Validated <E, A> v) { Assert.True(v.isValid); Assert.Equal(expected, v.getValid); }
public void Create(TaskList tasklist) { _db.TaskLists.Add(tasklist); Validated.SaveIt(_db); }
public async Task <HttpResponseMessage> DeleteAsync(Validated <int> id) { await _userService.DeleteUserAsync(id); return(Request.CreateResponse(HttpStatusCode.OK)); }