Esempio n. 1
0
        private async Task <ReadTicketModel> LoadTicketByAggregateRootIdAsync(string aggregateRootId, CancellationToken cancellationToken)
        {
            var entity = await _databaseContext.ReadTickets.FindAsync(new[] { aggregateRootId }, cancellationToken);

            if (entity == null)
            {
                return(null);
            }

            return(ReadTicketModel.CreateModel(entity.AggregateRootId, entity.UserId, entity.UserName, entity.Title, entity.TicketState, entity.TicketPriority, entity.TicketType, entity.Version));
        }
Esempio n. 2
0
        public async Task <Unit> Handle(UpdateReadTicketCommand request, CancellationToken cancellationToken)
        {
            var result = await _repository.SaveOrUpdateTicketAsync(
                ReadTicketModel.CreateModel(
                    request.AggregateRootId,
                    request.UserId,
                    request.UserName,
                    request.Title,
                    request.TicketState,
                    request.TicketPriority,
                    request.TicketType,
                    request.Version),
                cancellationToken);

            if (string.IsNullOrEmpty(result))
            {
                //we could not save or update the model - gracefully handle this.
            }
            return(Unit.Value);
        }
Esempio n. 3
0
 public async Task <IEnumerable <ReadTicketModel> > LoadAllTicketsForUser(string userName, CancellationToken cancellationToken)
 {
     return((await _databaseContext.ReadTickets.Where(t => t.UserName == userName).ToListAsync(cancellationToken))
            .Select(t => ReadTicketModel.CreateModel(t.AggregateRootId, t.UserId, t.UserName, t.Title, t.TicketState, t.TicketPriority, t.TicketType, t.Version)));
 }