Ejemplo n.º 1
0
 public RolesController(IGetRolesCommand getRoles, IGetRoleCommand getRole, IAddRoleCommand addRole, IEditRoleCommand editRole, IDeleteRoleCommand deleteRole)
 {
     this.getRoles   = getRoles;
     this.getRole    = getRole;
     this.addRole    = addRole;
     this.editRole   = editRole;
     this.deleteRole = deleteRole;
 }
Ejemplo n.º 2
0
 public RolesController(IGetRolesCommand searchRolesCommand, IGetRoleCommand getOneRoleCommand, ICreateRoleCommand createRoleCommand, IEditRoleCommand editRoleCommand, IDeleteRoleCommand deleteRoleCommand)
 {
     _searchRolesCommand = searchRolesCommand;
     _getOneRoleCommand  = getOneRoleCommand;
     _createRoleCommand  = createRoleCommand;
     _editRoleCommand    = editRoleCommand;
     _deleteRoleCommand  = deleteRoleCommand;
 }
Ejemplo n.º 3
0
 public RolesController(IGetRolesCommand getRolesCommand, IGetRoleCommand getRoleCommand, IAddRoleCommand addRoleCommand, IEditRoleCommand editRoleCommand, IDeleteRoleCommand deleteRoleCommand)
 {
     this.getRolesCommand   = getRolesCommand;
     this.getRoleCommand    = getRoleCommand;
     this.addRoleCommand    = addRoleCommand;
     this.editRoleCommand   = editRoleCommand;
     this.deleteRoleCommand = deleteRoleCommand;
 }
Ejemplo n.º 4
0
 public RolesController(IAddRoleCommand addRole, IGetRolesCommand getRoles, IGetRoleComand getRole, IEditRoleCommand editRole, IDeleteRoleCommand deleteRole)
 {
     _addRole    = addRole;
     _getRoles   = getRoles;
     _getRole    = getRole;
     _editRole   = editRole;
     _deleteRole = deleteRole;
 }
Ejemplo n.º 5
0
 public RoleController(IAddRolleCommand addRoleCommand, IGetRolesCommand getRolesCommand, IGetRoleCommand getRoleCommand, IEditRoleCommand editRoleCommand, IDeleteRoleCommand deleteRoleCommand)
 {
     _addRoleCommand    = addRoleCommand;
     _getRolesCommand   = getRolesCommand;
     _getRoleCommand    = getRoleCommand;
     _editRoleCommand   = editRoleCommand;
     _deleteRoleCommand = deleteRoleCommand;
 }
Ejemplo n.º 6
0
 public RolesController(IGetRolesCommand getRoles, IGetRoleCommand getRole, IAddRoleCommand addRole, IEditRoleCommand editRole, IDeleteRoleCommand deleteRole, UseCaseExecutor executor)
 {
     this.getRoles   = getRoles;
     this.getRole    = getRole;
     this.addRole    = addRole;
     this.editRole   = editRole;
     this.deleteRole = deleteRole;
     this.executor   = executor;
 }
Ejemplo n.º 7
0
 public RolesController(IGetRoleCommand getRoleCommand, IGetRolesCommand getRolesCommand, IAddRoleCommand addRoleCommand, IEditRoleCommand editRoleCommand, IDeleteRoleCommand deleteRoleCommand, LoggedUser loggedUser)
 {
     _getRoleCommand    = getRoleCommand;
     _getRolesCommand   = getRolesCommand;
     _addRoleCommand    = addRoleCommand;
     _editRoleCommand   = editRoleCommand;
     _deleteRoleCommand = deleteRoleCommand;
     _loggedUser        = loggedUser;
 }
Ejemplo n.º 8
0
        public async Task <ActionResult> Edit([FromRoute] string roleId,
                                              [FromBody] RoleCreateModel changes,
                                              [FromServices] IValidatorFactory validatorFactory,
                                              [FromServices] IEditRoleCommand editRoleCommand)
        {
            try
            {
                if (roleId == null || changes == null)
                {
                    return(BadRequest());
                }

                IValidator validator = validatorFactory.Create();
                await editRoleCommand.Execute(roleId, changes, validator);

                if (validator.HasErrors)
                {
                    return(BadRequest(validator.Errors));
                }
                else
                {
                    return(Created("", roleId));
                }
            }
            catch (Exception ex)
            {
                //Log error
                _logger.LogError("RoleController.Edit", "Exception was thrown", new
                {
                    RoleId    = roleId,
                    Changes   = changes,
                    Exception = ex
                });

                return(BadRequest(new Message("Something bad happened. Try again")));
            }
        }
 public IActionResult Put(int id, [FromBody] EditRoleDto request, [FromServices] IEditRoleCommand command)
 {
     request.Id = id;
     _executor.ExecuteCommand(command, request);
     return(StatusCode(StatusCodes.Status204NoContent));
 }