Пример #1
0
        public override ActionResult ChallengeUsers(int id = 0)
        {
            //return PartialView("_challenge");
            //eventid

            UsersManager   manager = new UsersManager();
            ChallengeEvent model   = new ChallengeEvent();

            model = _eventService.QueryableCustom().Where(w => w.EventId == id).Select(s => new ChallengeEvent
            {
                EndDate   = s.EndDate,
                EventId   = s.EventId,
                EventName = s.EventName,
                StartDate = s.StartDate,
                VenueName = s.Venue.VenueName
            }).FirstOrDefault();
            if (model != null)
            {
                model.ToSelectedChallengesList = _challengeService.QueryableCustom().Where(w => w.EventId == id && w.IsActive && !w.IsAccepted).Select(s => new ToChallenge
                {
                    Name = s.ToChallenge.Name,
                    Id   = (long)s.ToChallengeId
                }).ToList();

                model.ToChallengeList = manager.GetAllUsersWithoutCurrent(id, Common.CurrentUser.Id, Common.CurrentUser.IsTeam);
                //if (model.ToChallengeList != null)
                //{
                //    model.ToChallengeList = model.ToChallengeList.Where(w => w.IsActive);
                //}
            }

            return(PartialView("_challenge", model));
        }
Пример #2
0
        public ActionResult Challenge(ChallengeEvent model)
        {
            List <UserChallenges> userChallengesList = new List <UserChallenges>();
            List <Notifications>  notificationsList  = new List <Notifications>();

            userChallengesList = _challengeService.QueryableCustom().Where(w => w.EventId == model.EventId && w.IsActive).ToList();
            if (model.SelectedIds.Count() > 0)
            {
                foreach (var item in userChallengesList)
                {
                    item.IsActive    = false;
                    item.ObjectState = ObjectState.Modified;
                    _challengeService.InsertOrUpdateGraph(item);
                    _unitOfWork.SaveChanges();
                }
                //eventid
                for (int i = 0; i < model.SelectedIds.Length; i++)
                {
                    UserChallenges userChallenge = new UserChallenges();
                    userChallenge.EventId       = model.EventId;
                    userChallenge.IsActive      = true;
                    userChallenge.IsAccepted    = false;
                    userChallenge.UserId        = Common.CurrentUser.Id;
                    userChallenge.DateCreated   = DateTime.Now;
                    userChallenge.ToChallengeId = model.SelectedIds[i];
                    //userChallengesList.Add();
                    _challengeService.Insert(userChallenge);
                }

                saveResult = _unitOfWork.SaveChanges();
                for (int i = 0; i < model.SelectedIds.Length; i++)
                {
                    Notifications notification = new Notifications();
                    notification.ObjectState      = ObjectState.Added;
                    notification.Notification     = Common.CurrentUser.Name + " Challenged you for the event " + model.EventName;
                    notification.Link             = "/Events/Detail/" + model.EventId;
                    notification.IsRead           = false;
                    notification.Icon             = "fa fa-plus-square fa-lg";
                    notification.UserId           = model.SelectedIds[i];
                    notification.NotificationDate = DateTime.Now;
                    notification.ProfilePic       = Common.CurrentUser.ProfilePic == null ? "/assets/images/avatar-1.png" : Common.CurrentUser.ProfilePic;
                    notificationsList.Add(notification);
                }
                NotificationHub.SendNotification(model.SelectedIds.ToList(), " You are challenged for event " + model.EventName, "fa fa-plus-square fa-lg", "/Events/Info/" + model.EventId, Common.CurrentUser.ProfilePic == null ? "/assets/images/avatar-1.png" : Common.CurrentUser.ProfilePic);
                _notificationsService.InsertGraphRange(notificationsList);
                _unitOfWork.SaveChanges();
            }
            return(RedirectToAction("Index"));
        }
        public IGameEvent ReadGameEvent(IBitStream stream, bool useOld = false)
        {
            uint eventId = 0;
            int  v3      = 127;//adjust value depending on game, 127 is for bf2 and bf2142
            int  v4      = 0;

            do
            {
                ++v4;
            }while (v3 > (1 << v4) - 1);//if the event amount defined above is 127 then the result will be 7, meaning we read 7 bits and those 7 bits are the event id
            eventId = stream.ReadBits((uint)v4);
            IGameEvent eventInstance;

            if (!useOld)
            {
                eventInstance = Config.EventRegistry.Trigger(eventId, stream);//dont use in development
            }
            else
            #region old
            {
                if (eventId == 1)
                {
                    eventInstance = new ChallengeEvent().DeSerialize(stream);
                }
                else if (eventId == 2)
                {
                    eventInstance = new ChallengeResponseEvent().DeSerialize(stream);
                }
                else if (eventId == 3)
                {
                    eventInstance = new ConnectionTypeEvent().DeSerialize(stream);
                }
                else if (eventId == 4)
                {
                    eventInstance = new DataBlockEvent().DeSerialize(stream);
                }
                else if (eventId == 5)
                {
                    eventInstance = new CreatePlayerEvent().DeSerialize(stream);
                }
                else if (eventId == 6)
                {
                    eventInstance = new CreateObjectEvent().DeSerialize(stream);
                }
                else if (eventId == 8)
                {
                    eventInstance = new DestroyObjectEvent().DeSerialize(stream);
                }
                else if (eventId == 11)
                {
                    eventInstance = new PostRemoteEvent().DeSerialize(stream);
                }
                else if (eventId == 16)
                {
                    eventInstance = new StringBlockEvent().DeSerialize(stream);
                }
                else if (eventId == 31)
                {
                    eventInstance = new CreateKitEvent().DeSerialize(stream);
                }
                else if (eventId == 35) //voip event
                {
                    stream.ReadBits(9); //just read so we can skip
                    eventInstance = null;
                }
                else if (eventId == 39)
                {
                    eventInstance = new VoteEvent().DeSerialize(stream);
                }
                else if (eventId == 42)
                {
                    eventInstance = new UnlockEvent().DeSerialize(stream);
                }
                else if (eventId == 46)
                {
                    eventInstance = new ContentCheckEvent().DeSerialize(stream);
                }
                else if (eventId == 50)
                {
                    eventInstance = null;
                }
                else if (eventId == 54)    //voip event, we dont care
                {
                    stream.ReadBits(0x10); //just read so we can skip
                    eventInstance = null;
                }
                else if (eventId == 56)
                {
                    eventInstance = new BeginRoundEvent().DeSerialize(stream);
                }
                else if (eventId == 57)
                {
                    eventInstance = new CreateSpawnGroupEvent().DeSerialize(stream);
                }
                else
                {
                    eventInstance = null;
                }
            }
            #endregion
            return(eventInstance);
        }