Beispiel #1
0
    public MessageReactionEvent(
        [JsonProperty(Required = Required.Always)]
        EventReaction reaction,

        [JsonProperty(NullValueHandling = NullValueHandling.Ignore)]
        HashId?serverId
        ) =>
    (Reaction, ServerId) = (reaction, serverId);
Beispiel #2
0
        public void Subscribe(EventReaction eventReaction, string eventType)
        {
            if (!subscriberDirectory.ContainsKey(eventType))
            {
                subscriberDirectory.Add(eventType, new List <EventReaction>());
            }

            subscriberDirectory[eventType].Add(eventReaction);
        }
Beispiel #3
0
        public Task UpdateEventReaction(EventReaction updated)
        {
            var existing = _eventReactions.FirstOrDefault(er => er.EventId == updated.EventId && er.UserId == updated.UserId);

            if (existing != null)
            {
                _eventReactions.Remove(existing);
            }
            _eventReactions.Add(updated);
            return(Task.CompletedTask);
        }
        private async Task <EventReaction> CreateReaction(SetReactionViewModel reactionViewModel, Event _event, Guid userId)
        {
            var reaction = new EventReaction()
            {
                EventId = reactionViewModel.EventId,
                Type    = reactionViewModel.ReactionType,
                UserId  = userId
            };

            _event.Reactions.Add(reaction);

            return(reaction);
        }
Beispiel #5
0
        public async Task <bool> AddEventReaction(ulong eventId, ulong userId)
        {
            var existingSet = await _eventReactions.FindAsync(er => er.EventId == eventId && er.UserId == userId);

            if (await existingSet.AnyAsync())
            {
                return(false);
            }
            var newEventReaction = new EventReaction {
                EventId = eventId, UserId = userId
            };
            await _eventReactions.InsertOneAsync(newEventReaction);

            return(true);
        }
        public void Unsubscribe(object subscriber, EventReaction eventReaction, string eventType)
        {
            foreach(EventReaction reaction in reactionDirectory[eventType])
            {
                if(eventReaction == reaction)
                {
                    reactionDirectory[eventType].Remove(eventReaction);
                    subscriberDirectory[subscriber].Remove(new KeyValuePair<string,EventReaction>(eventType, eventReaction));
                    if(subscriberDirectory[subscriber].Count == 0)
                    {
                        subscriberDirectory.Remove(subscriber);
                    }

                    break;
                }
            }
        }
        public void Subscribe(object subscriber, EventReaction eventReaction, string eventType)
        {
            if(!reactionDirectory.ContainsKey(eventType))
            {
                reactionDirectory.Add(eventType, new List<EventReaction>());
            }

            if(!subscriberDirectory.ContainsKey(subscriber))
            {
                subscriberDirectory.Add(subscriber, new List<KeyValuePair<string, EventReaction>>());
                subscriberDirectory[subscriber] = new List<KeyValuePair<string, EventReaction>>();
            }

            subscriberDirectory[subscriber].Add(new KeyValuePair<string, EventReaction>(eventType, eventReaction));

            reactionDirectory[eventType].Add(eventReaction);
        }
        private EventReaction DigestEventReaction(XPathNavigator nav, IFactoryFarm factoryFarm)
        {
            var id           = nav.GetAttribute("id", string.Empty);           // eventReaction.id
            var reactionType = nav.GetAttribute("reactionType", string.Empty); // eventReaction.reactionType

            nav.MoveToFirstChild();                                            // fieldMatch

            List <FieldMatch> fieldMatches = new List <FieldMatch>();

            do
            {
                fieldMatches.Add(this.DigestFieldMatch(nav.Clone(), factoryFarm));
            } while (nav.MoveToNext());

            var evRec = new EventReaction(id, reactionType, fieldMatches);

            return(evRec);
        }
Beispiel #9
0
 public async Task UpdateEventReaction(EventReaction updated)
 {
     await RemoveEventReaction(updated.EventId, updated.UserId);
     await AddEventReaction(updated.EventId, updated.UserId);
 }
Beispiel #10
0
 public void RemoveReaction(EventReaction eventReaction)
 {
     _dbContext.EventReactions.Remove(eventReaction);
 }
Beispiel #11
0
 public void ReactTo(Entity target, EventReaction reaction, float p2 = 7.5f, float p3 = 0f, int flag = 4)
 {
     Function.Call((Hash)0xC4C32C31920E1B70, _ped.Handle, target.Handle, (int)reaction, p2, p3, flag);
 }
Beispiel #12
0
        private async Task <EventReaction> UpdateReaction(SetReactionViewModel reactionViewModel, EventReaction userReaction, Event _event)
        {
            if (userReaction.Type == reactionViewModel.ReactionType)
            {
                _unitOfWork.EventReactionRepository.RemoveReaction(userReaction);
                return(null);
            }

            userReaction.Type = reactionViewModel.ReactionType;
            return(userReaction);
        }