public async Task DeleteAccount(Account account) { var dbAccount = await _context.Account.FirstAsync(e => e.Id == account.Id); _context.Remove(dbAccount); await _context.SaveChangesAsync(); await _eventsBus.PublicEventAsync(new AccountDeletedEvent { AccountId = account.Id }); }
public async Task <IActionResult> CreateAccount([FromBody] Account account) { if (account == null) { return(BadRequest("Account parameter not found.")); } account.UserId = _identityService.GetUserId(); account.CreatedAt = DateTime.UtcNow; var res = await _accountRepository.CreateAccount(account); var routeValues = new { id = res.Id }; await _eventsBus.PublicEventAsync(new AccountCreatedEvent { AccountId = res.Id, AccountTitle = res.Title }); return(CreatedAtAction(nameof(GetAccount), routeValues, routeValues)); }
public async Task Handle(CreateUserCommand command) { var id = await _userService.CreateUser(new CreateUserArgs { Username = command.Username, Email = command.Email, Password = command.Password }); await _eventBus.PublicEventAsync(new UserCreatedEvent { Username = command.Username, Email = command.Email, Id = id }); }