public async Task <IActionResult> GetAllMovements([FromRoute] Guid userId, [FromRoute] Guid accountId, [FromQuery] int page = 1, [FromQuery] int size = 30) { var userInfo = this.GetUserInfo(); if (!userId.Equals(userInfo.UserId) || !accountId.Equals(userInfo.AccountId)) { return(BadRequest("Invalid token.")); } var query = new GetAllMovementsQuery(userInfo.UserId, userInfo.AccountId, page, size); var result = await _mediator.Send(query); return(Ok(result)); }
public async Task <IEnumerable <GetAllMovementResponse> > Handle(GetAllMovementsQuery request, CancellationToken cancellationToken) { var movements = await _movementRepository.GetMovementsByAccount(request.UserId, request.AccountId, request.Page, request.PageSize); if (movements is null || !movements.Any()) { return(Enumerable.Empty <GetAllMovementResponse>()); } return(movements.Select(m => new GetAllMovementResponse { Id = m.Id, Value = m.Value, Description = m.Description, Category = m.Category, Type = m.Type, CreatedOn = m.CreatedOn })); }