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)); }
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); }
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))); }