/// <summary> /// Removes the user from the application. /// </summary> /// <param name="command">The command.</param> public virtual void RemoveUser(RemoveUserCommand command) { Guard.Will.ProtectAgainstNullArgument(() => command); var existingUser = this.applicationUsers.FirstOrDefault(x => x.User.Login.Equals(command.Login, StringComparison.OrdinalIgnoreCase)); this.applicationUsers.Remove(existingUser); }
public async Task <bool> Handle(RemoveUserCommand message, CancellationToken cancellationToken) { await _userRepository.RemoveAsync(message.AggregateId); await Commit(); return(true); }
public async Task <APIResult> RemoveUser([FromBody] RemoveUserCommand command) { return(new APIResult() { Result = 0, Data = await mediator.Send(command) }); }
public void RemoveUserCommandTest() { var removeUserComman = new RemoveUserCommand { PersonId = "9558128e683a4793b148728d640681cf" }; var result = _service.InvokeCommand(removeUserComman); Assert.IsTrue(result.IsSuccess); }
private void RaiseCanExecuteCommands() { NextMonthCommand.RaiseCanExecuteChanged(); PreviousMonthCommand.RaiseCanExecuteChanged(); RemoveUserCommand.RaiseCanExecuteChanged(); CurrentMonthCommand.RaiseCanExecuteChanged(); SearchCommand.RaiseCanExecuteChanged(); ClearAllCommand.RaiseCanExecuteChanged(); PrintCommand.RaiseCanExecuteChanged(); }
private void RaiseCanExecuteChanged() { AddNewGroupCommand.RaiseCanExecuteChanged(); RemoveGroupCommand.RaiseCanExecuteChanged(); AddNewUserCommand.RaiseCanExecuteChanged(); RemoveUserCommand.RaiseCanExecuteChanged(); RenameGroupCommand.RaiseCanExecuteChanged(); ResetTypePermissionCommand.RaiseCanExecuteChanged(); RemoveGroupFromUserCommand.RaiseCanExecuteChanged(); }
public MainWindowViewModel() { ExecuteOpenAddUserWindow = new OpenAddUserWindowCommand(OpenAddUserWindow); ExecuteRemoveUser = new RemoveUserCommand(RemoveUser); ExecuteSaveUsers = new DelegateCommandExecutor(SaveUsers); ExecuteLoadUsers = new DelegateCommandExecutor(LoadUsers); UsersContainer.GetInstance(this); LoadUsers(); RegisterMessengerNotifications(); }
public async Task DeleteUser( int userId, CancellationToken cancellationToken ) { cancellationToken.ThrowIfCancellationRequested(); var command = new RemoveUserCommand(userId); await _mediator.Send(command, cancellationToken); }
public async Task Handle(RemoveUserCommand command) { var login = await eventSource.Pull <UserLoginName>(command.Login); var user = await eventSource.Pull <UserDom>(login.UserId); login.Delete(); user.Delete(); await eventSource.PushChanges(command); }
public async Task <IResult> Execute(RemoveUserCommand request) { await _userService.Remove(request.Id); var success = await _unitOfWork.Commit(); if (success) { return(await Result.SuccessAsync()); } return(await Result.FailAsync("Internal error, please try again.")); }
public async Task <IActionResult> RemoveUserAsync(string userId) { var claimsIdentity = this.User.Identity as ClaimsIdentity; var adminId = claimsIdentity.Claims.ToList().FirstOrDefault(x => x.Type == "id").Value; var command = new RemoveUserCommand { UserId = userId, AdminId = adminId }; return(await _mediator.Send(command)); }
public UsersController( GetUsersQuery getUsersQuery, GetUserTodoListsQuery getUserTodoListsQuery, CreateUserCommand createUserCommand, UpdateUserCommand updateUserCommand, RemoveUserCommand removeUserCommand ) { this.getUsersQuery = getUsersQuery; this.getUserTodoListsQuery = getUserTodoListsQuery; this.createUserCommand = createUserCommand; this.updateUserCommand = updateUserCommand; this.removeUserCommand = removeUserCommand; }
public async Task Handle(RemoveUserCommand notification, CancellationToken cancellationToken) { if (!notification.IsValid()) { NotifyValidationErrors(notification); return; } _userRepository.Remove(notification.Id); if (await CommitAsync()) { } }
public async Task <CommandResult> Remove([FromServices] RemoveUserCommand _removeUserCommand, [FromBody] RemoveUserInput removeUserInput) { var userInput = new UserInput <RemoveUserInput> { UserId = User.GetUserId(), Data = removeUserInput }; var result = await Business.InvokeAsync <RemoveUserCommand, UserInput <RemoveUserInput>, CommandResult>(_removeUserCommand, userInput).ConfigureAwait(false); return(result); }
public void TestCleanup() { using (var unitOfWork = this.UnitOfWorkFactory.Create()) { var entities = unitOfWork.ResolveQuery <IGetAllQuery>() .Execute <UserDto>(); foreach (var entity in entities) { var command = new RemoveUserCommand(entity.Id); unitOfWork.ExecuteCommand(command); } unitOfWork.Commit(); } }
public void Handle(RemoveUserCommand message) { if (!message.IsValid()) { NotifyValidationErrors(message); return; } _userRepository.Remove(_userRepository.Get(message.UserId)); if (Commit()) { _bus.RaiseEvent(new UserRemovedEvent(message.UserId)); } }
public IActionResult RemoveUser([FromBody] RemoveUserCommand user) { try { var userRemoved = _usersService.RemoveUser(user); return(Ok(userRemoved)); } catch (UnauthorizedAccessException) { return(StatusCode(401)); } catch (Exception ex) { throw ex; } }
public Task <bool> Handle(RemoveUserCommand message, CancellationToken cancellationToken) { if (!message.IsValid()) { NotifyValidationErrors(message); return(Task.FromResult(false)); } _userRepository.Remove(message.Id); if (Commit()) { Bus.RaiseEvent(new UserRemovedEvent(message.Id)); } return(Task.FromResult(true)); }
public void Handle(RemoveUserCommand command) { using (var dbContext = new UserAccountDataContext()) { User user = dbContext.Users.SingleOrDefault(u => u.Id == command.UserId); if (user == null) { throw new ServerSideException("Ups, something went wrong! Refresh page and try agine"); } // TODO Check if user have league or team // if user have league or team then cant delete account dbContext.Users.Remove(user); dbContext.SaveChanges(); // TODO create event - user removed - LogOff } }
public void RemoveObject() { // Arrange this._dbFixture.TestInitialize(); int initialCount = 0; var cmd = new RemoveUserCommand(this._sampleData.Id); // Act initialCount = this._unitOfWorkFactory .ExecuteSingleQuery <IGetCountQuery, int>(q => q.Execute <UserDto>()); this._unitOfWorkFactory.ExecuteSingleCommand(cmd); int resultCount = this._unitOfWorkFactory .ExecuteSingleQuery <IGetCountQuery, int>(q => q.Execute <UserDto>()); // Assert Assert.Equal(initialCount - 1, resultCount); }
public override async Task RemoveAsync(Guid id) { var command = new RemoveUserCommand(id); if (!command.IsValid()) { await RaiseValidationErrorsAsync(command); return; } if ((await _userRepository.GetByIdAsync(command.AggregateId)) == null) { await _mediatorHandler.RaiseDomainNotificationAsync(new DomainNotification(command.MessageType, CoreUserMessages.RegistroNaoEncontrado.Message)); return; } await _mediatorHandler.SendCommandAsync(command); }
public Task Handle(RemoveUserCommand notification, CancellationToken cancellationToken) { notification.FillEntities(); if (notification.Invalid) { NotifyValidationErrors(notification); return(Task.CompletedTask); } userRepository.Delete(notification.UserId); if (Commit()) { return(Task.CompletedTask); } else { _bus.RaiseEvent(new DomainNotification(notification.MessageType, "Não foi possivel alterar cliente.")); return(Task.CompletedTask); } }
public async Task <Unit> Handle(RemoveUserCommand request, CancellationToken cancellationToken) { if (!await request.IsValidAsync()) { NotifyValidationErrors(request); return(new Unit()); } if ((await _userRepository.GetEntitieByIdAsync(request.Id)) == null) { await _bus.RaiseEvent(new DomainNotification("", "该用户不存在")); return(new Unit()); } await _userRepository.RemoveAsync(request.Id); if (Commit()) { } return(new Unit()); }
public Users RemoveUser(RemoveUserCommand account) { using (var db = _paintStoreContext) { var userToRemove = db.Users.First(x => x.Id == account.Id); try { _signInService.SignInCheck(new SignInCommand { Email = account.Email, Password = account.Password }, db); foreach (var post in db.Posts.Where(x => x.UserId == userToRemove.Id)) { _postsService.PostRemover(post.Id); } foreach (var follow in db.UserFollowers. Where(x => x.FollowedUserId == userToRemove.Id || x.FollowingUserId == userToRemove.Id)) { _followersService.FollowRemove(follow.FollowingUserId, follow.FollowedUserId); } db.Users.Remove(userToRemove); db.SaveChanges(); return(userToRemove); } catch (UnauthorizedAccessException) { throw new UnauthorizedAccessException(); } catch (Exception ex) { throw ex; } } }
public async Task Remove(Guid id) { var removeCommand = new RemoveUserCommand(id); await _bus.SendCommand(removeCommand); }
public async Task <IActionResult> Remove([FromBody] RemoveUserCommand removeUserCommand) { await this.Mediator.Send(removeUserCommand); return(Ok()); }
public void TestCleanup() { using (var unitOfWork = this.UnitOfWorkFactory.Create()) { var entities = unitOfWork.ResolveQuery<IGetAllQuery>() .Execute<UserDto>(); foreach (var entity in entities) { var command = new RemoveUserCommand(entity.Id); unitOfWork.ExecuteCommand(command); } unitOfWork.Commit(); } }
public ActionResult RemoveAccount(RemoveUserCommand command) { HandleCommand(command, Json("User removed")); return(RedirectToAction("Index")); }
public async Task <ActionResult> RemoveUser([FromBody] RemoveUserCommand removeUser) { await Mediator.Send(removeUser); return(Ok()); }
public void RemoveObject() { // Arrange this._dbFixture.TestInitialize(); int initialCount = 0; var cmd = new RemoveUserCommand(this._sampleData.Id); // Act initialCount = this._unitOfWorkFactory .ExecuteSingleQuery<IGetCountQuery, int>(q => q.Execute<UserDto>()); this._unitOfWorkFactory.ExecuteSingleCommand(cmd); int resultCount = this._unitOfWorkFactory .ExecuteSingleQuery<IGetCountQuery, int>(q => q.Execute<UserDto>()); // Assert Assert.Equal(initialCount - 1, resultCount); }
public async Task <IActionResult> Remove([FromBody] RemoveUserCommand removeUserCommand, CancellationToken cancellationToken = default) { await _mediator.Send(removeUserCommand, cancellationToken); return(Ok()); }
public void Remove(Guid id) { var removeCommand = new RemoveUserCommand(id); _bus.SendCommand(removeCommand); }
public ActionResult RemoveAccount(RemoveUserCommand command) { HandleCommand(command, Json("User removed")); return RedirectToAction("Index"); }