/// <summary> /// пока что без пагинации, если будет реально много. то добавлю пагинацию /// </summary> /// <param name="query"></param> /// <param name="cancellationToken"></param> /// <returns></returns> public async Task <ICollection <OperationListView> > Handle(GetOperationsQuery query, CancellationToken cancellationToken) { var dateMonth = (query.DateMonth ?? DateTime.UtcNow).Trunc(DateTruncType.Month); var operations = await _db.QueryAsync <Entity.OperationListItem>( new CommandDefinition( commandText : Entity.OperationListItem.Sql, parameters : new { GuildId = query.GuildId, DateMonth = dateMonth }, commandType : CommandType.Text, cancellationToken : cancellationToken )); return(operations.Select(_ => new OperationListView( _.Id, _.Amount, _.CreateDate, _.Description, _.Type, Guid.Empty == _.DocumentId ? null : _.DocumentId, Guid.Empty == _.DocumentId ? null : _.DocumentAmount, _.DocumentDescription, _.UserId, _.UserName, _.ParentOperationId != null ? new ParrentOperationView(_.ParentOperationId.Value, _.ParentOperationDescription) : null )).ToImmutableList()); }
public async Task <OperationsReadModel> Find(Guid operationId) { var query = new GetOperationsQuery(); var result = await _operationStorageHandler.Ask <List <OperationsReadModel> >(query); var readModel = result.SingleOrDefault(x => x.Id == operationId); return(readModel); }
public async Task <IReadOnlyCollection <OperationsReadModel> > FindAll() { var query = new GetOperationsQuery(); var result = await _operationStorageHandler.Ask <List <OperationsReadModel> >(query); var sortedResult = result .OrderBy(x => x.Percentage) .ThenBy(x => x.StartedAt) .ToList(); return(sortedResult); }
public bool Handle(GetOperationsQuery query) { Sender.Tell(Operations, Self); return(true); }
public System.Boolean Handle(GetOperationsQuery query) { Sender.Tell(_operations, Self); return(true); }