Esempio n. 1
0
        public void Broadcast(Report report)
        {
            var usersToBroadCastTo = this.users
                .All()
                .Include(x => x.PlayerObject);

            foreach (var user in usersToBroadCastTo)
            {
                user.PlayerObject.Reports.Add(report);
                this.users.Update(user);
            }

            this.users.SaveChanges();
        }
Esempio n. 2
0
        public void CreateReport(string userId, Report report)
        {
            var user = this.users
               .All()
               .Include(x => x.PlayerObject)
               .FirstOrDefault(u => u.Id == userId);

            if (user == null)
            {
                return;
            }

            report.ReceivedOn = DateTime.Now;

            user.PlayerObject.Reports.Add(report);
            this.users.Update(user);
            this.users.SaveChanges();
        }
Esempio n. 3
0
        public void BroadcastToShard(int shardId, Report report)
        {
            var usersToBroadCastTo = this.players
                   .All()
                   .Where(x => x.Planet.ShardId == shardId)
                   .ToList();

            report.ReceivedOn = DateTime.Now;

            foreach (var user in usersToBroadCastTo)
            {
                var reportToAdd = new Report
                {
                    Content = report.Content,
                    ReceivedOn = report.ReceivedOn,
                    Title = report.Title,
                    Type = report.Type
                };

                user.Reports.Add(reportToAdd);
                this.players.Update(user);
            }

            this.players.SaveChanges();
        }