public async Task <BrokerResult> ReceiveMessage(string topicName, CancellationToken cancellationToken) { BrokerResult message = null; using (var consumer = GenerateConsumer()) { try { consumer.Subscribe(topicName); if (!cancellationToken.IsCancellationRequested) { var result = consumer.Consume(cancellationToken); consumer.Commit(result); message = new BrokerResult(true, result.Message.Value); } } catch (System.Exception ex) { message = new BrokerResult(false, ex.Message); } } return(message); }
public bool PutInviteResponse(Guid userID, Guid eventID, bool accept) { IUser user = _userRepo.Find(u => u.ID == userID).FirstOrDefault(); BrokerResult result = _broker.RespondToInvite(user, eventID, accept); if (result.type == ResultType.fullsuccess && accept) { IEvent ev = _eventRepo.Find(e => e.ID == eventID).FirstOrDefault(); // Use EventFacade --> EventAttendeesByStatus(Guid userId, Guid eventId, EventAttendantsStatus attendStatus) // ev.attendingUsers.Add(user); // ev.invitedUsers.Remove(user); } return(result.ok()); }