public async Task <IActionResult> CreateAsync(string Name) { var createCommand = new CreateRole.Command(Name); var res = await _mediator.Send(createCommand); return(Ok(res)); }
public async Task <IActionResult> Create(CreateRole.Command command) { var result = await Mediator.Send(command); return(result.IsSuccessful ? Ok(result) : BadRequest(result)); }
public async Task <ActionResult> Create(CreateRole.Command command) { if (ModelState.IsValid) { await _mediator.Send(command); return(RedirectToAction(nameof(Index))); } return(View(command)); }
public static async Task <Role> CreateRole(Action <CreateRole.Command> customize = null) { var command = new CreateRole.Command { Name = SampleRole().Name }; customize?.Invoke(command); var roleId = (await Send(command)).RoleId; return(Query <Role>(roleId)); }
public async Task ShouldRequireUniqueName() { var preexistingRole = await CreateRole(); var command = new CreateRole.Command { Name = SampleRole().Name }; command.ShouldValidate(); command.Name = preexistingRole.Name; command.ShouldNotValidate( $"There is already a role named '{command.Name}'. " + "Please enter a unique role name."); }
public async Task <ActionResult <Unit> > CreateRole(CreateRole.Command command) { return(await _mediator.Send(command)); }
public async Task <RoleDto> Create( [FromBody] CreateRole.Command command) { return(await _mediator.Send(command)); }
public ActionResult Create() { var command = new CreateRole.Command(); return(View(command)); }