Exemplo n.º 1
0
        public async Task <HttpResponseMessage> Events(EventModel e)
        {
            int id = UoW.EventRepository.AddEvent(new Event
            {
                MatchId        = e.MatchId,
                Type           = e.Type,
                Time           = e.Time,
                PlayerId       = e.PlayerId,
                EventMessageId = e.EventMessageId,
                TeamId         = e.TeamId
            });

            e.Id = id;

            Communicator comm     = new Communicator();
            string       leagueId = UoW.LeagueRepository.GetLeagueByEvent(e.Id).Id.ToString();

            comm.AddEventToMatch(e, leagueId);

            await Messanger.Instance.SendNewEventAsync(
                JsonConvert.SerializeObject(e),
                NotificationHelper.GetEventTitleArgs(UoW.EventRepository.GetEventById(e.Id)),
                NotificationHelper.GetEventBodyArgs(UoW.EventRepository.GetEventById(e.Id)),
                "/topics/event_" + leagueId);


            return(Request.CreateResponse(HttpStatusCode.OK, id));
        }