Ejemplo n.º 1
0
        public async Task <IActionResult> CreateAsync(string Name)
        {
            var createCommand = new CreateRole.Command(Name);
            var res           = await _mediator.Send(createCommand);

            return(Ok(res));
        }
Ejemplo n.º 2
0
        public async Task <IActionResult> Create(CreateRole.Command command)
        {
            var result = await Mediator.Send(command);

            return(result.IsSuccessful
                ? Ok(result)
                : BadRequest(result));
        }
Ejemplo n.º 3
0
        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));
        }
Ejemplo n.º 5
0
        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.");
        }
Ejemplo n.º 6
0
 public async Task <ActionResult <Unit> > CreateRole(CreateRole.Command command)
 {
     return(await _mediator.Send(command));
 }
Ejemplo n.º 7
0
 public async Task <RoleDto> Create(
     [FromBody] CreateRole.Command command)
 {
     return(await _mediator.Send(command));
 }
Ejemplo n.º 8
0
        public ActionResult Create()
        {
            var command = new CreateRole.Command();

            return(View(command));
        }