Пример #1
0
        public ActionResult AddTeamApplication(TeamApplication app, Guid TournamentID, Guid OrganizationID)
        {
            TeamApplication temp = new TeamApplication(TournamentID, OrganizationID);

            temp.TeamName  = app.TeamName;
            temp.Category  = app.Category;
            temp.CoachName = app.CoachName;
            temp.Status    = 0;
            bool   successbool = false;
            string resultmessage;

            try
            {
                successbool = rep.CreateNewTeamApplication(temp);
            }
            catch (Exception e)
            {
                successbool = false;
            }

            if (successbool)
            {
                resultmessage = "Team application successfully created (not yet submitted).";
            }
            else
            {
                resultmessage = "Please fill in all fields when creating a team application.";
            }

            ModelState.Clear();
            return(RedirectToAction("ManageTeamApplications", new { TournamentID = TournamentID, message = resultmessage }));
        }
Пример #2
0
        public bool CreateNewTeamApplication(TeamApplication app)
        {
            SqlCommand cmd = new SqlCommand("CreateNewTeamApplication", new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString));

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@teamapplicationid", SqlDbType.UniqueIdentifier)).Value = Guid.NewGuid();
            cmd.Parameters.Add(new SqlParameter("@organizationid", SqlDbType.UniqueIdentifier)).Value    = app.OrganizationID;
            cmd.Parameters.Add(new SqlParameter("@tournamentid", SqlDbType.UniqueIdentifier)).Value      = app.TournamentID;
            cmd.Parameters.Add(new SqlParameter("@teamname", SqlDbType.VarChar, 50)).Value   = app.TeamName;
            cmd.Parameters.Add(new SqlParameter("@category", SqlDbType.VarChar, 20)).Value   = app.Category;
            cmd.Parameters.Add(new SqlParameter("@coachname", SqlDbType.VarChar, 100)).Value = app.CoachName;

            try
            {
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                return(true);
            }
            catch (Exception e)
            {
                cmd.Connection.Close();
            }
            return(false);
        }
Пример #3
0
        public ActionResult DeleteTeamApplication(ThirdPartyTeamApplicationInfoView appInfo)
        {
            if (!ModelState.IsValid)
            {
                return(RedirectToAction("ManageTeamApplications", new { TournamentID = appInfo.TournamentID, message = "There was an error in processing your request." }));
            }

            bool            successbool;
            string          resultmessage;
            Guid            OrgID = rep.GetOrgId(System.Web.HttpContext.Current.User.Identity.Name);
            TeamApplication app   = new TeamApplication(appInfo.TournamentID, OrgID, appInfo.ApplicationID);

            try
            {
                successbool = rep.DeleteTeamApplication(app);
            }
            catch (Exception e)
            {
                successbool = false;
            }

            if (successbool)
            {
                resultmessage = "Successfully deleted team application.";
            }
            else
            {
                resultmessage = "There was an error in deleting chosen team application.";
            }

            ModelState.Clear();
            return(RedirectToAction("ManageTeamApplications", new { TournamentID = appInfo.TournamentID, message = resultmessage }));
        }
Пример #4
0
        public async Task <IActionResult> OnGetAddMemberAsync(int teamId, int userId, int applicationId)
        {
            if (EventRole == EventRole.play && !Event.IsTeamMembershipChangeActive)
            {
                return(NotFound("Team membership change is not currently active."));
            }

            TeamApplication application = await(from app in _context.TeamApplications
                                                where app.ID == applicationId
                                                select app).FirstOrDefaultAsync();

            if (application == null)
            {
                return(NotFound("Could not find application"));
            }

            if (application.Player.ID != userId)
            {
                return(NotFound("Mismatched player and application"));
            }
            Team team = await _context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);

            if (application.Team != team)
            {
                return(Forbid());
            }

            Tuple <bool, string> result = TeamHelper.AddMemberAsync(_context, Event, EventRole, teamId, userId).Result;

            if (result.Item1)
            {
                return(RedirectToPage("./Details", new { teamId = teamId }));
            }
            return(NotFound(result.Item2));
        }
Пример #5
0
        public TeamApplication GetTeamApplication(Guid TeamapplicationID)
        {
            SqlCommand cmd = new SqlCommand("GetTeamApplication", new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString));

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@teamappid", SqlDbType.UniqueIdentifier)).Value = TeamapplicationID;

            try
            {
                cmd.Connection.Open();
                DataTable      dt          = new DataTable();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
                dataAdapter.Fill(dt);
                cmd.Connection.Close();

                List <TeamApplication> applications = new List <TeamApplication>();

                TeamApplication application = new TeamApplication(Guid.Parse(dt.Rows[0]["tournamentid"].ToString()), Guid.Parse(dt.Rows[0]["orgid"].ToString()), Guid.Parse(dt.Rows[0]["teamappid"].ToString()));
                application.TeamName    = dt.Rows[0]["teamname"].ToString();
                application.Category    = dt.Rows[0]["category"].ToString();
                application.CoachName   = dt.Rows[0]["coachname"].ToString();
                application.Status      = (int)dt.Rows[0]["statusfield"];
                application.TeamMessage = dt.Rows[0]["teammessage"].ToString();

                return(application);
            }
            catch (Exception e)
            {
                cmd.Connection.Close();
            }

            return(null);
        }
Пример #6
0
        public async Task <IActionResult> OnGet(int teamID)
        {
            if (LoggedInUser == null)
            {
                return(Challenge());
            }

            if (EventRole != EventRole.play)
            {
                return(Forbid());
            }

            if (!Event.IsTeamMembershipChangeActive)
            {
                return(NotFound("Team membership change is not currently allowed."));
            }

            TeamMembers playerTeam = await(from member in _context.TeamMembers
                                           where member.Member == LoggedInUser &&
                                           member.Team.Event == Event
                                           select member).FirstOrDefaultAsync();

            if (playerTeam != null)
            {
                return(RedirectToPage("./Details", new { eventId = Event.ID, eventRole = EventRole, teamId = playerTeam.Team.ID }));
            }

            Team = await(from Team t in _context.Teams
                         where t.ID == teamID && t.Event == Event
                         select t).FirstOrDefaultAsync();

            if (Team == null)
            {
                return(NotFound());
            }

            // Only handle one application at a time for a player to avoid spamming all teams
            IEnumerable <TeamApplication> oldApplications = from TeamApplication oldApplication in _context.TeamApplications
                                                            where oldApplication.Player == LoggedInUser && oldApplication.Team.Event == Event
                                                            select oldApplication;

            _context.TeamApplications.RemoveRange(oldApplications);

            TeamApplication application = new TeamApplication()
            {
                Team   = Team,
                Player = LoggedInUser
            };

            _context.TeamApplications.Add(application);

            await _context.SaveChangesAsync();

            return(Page());
        }
Пример #7
0
        public List <TeamApplication> GetAllTeamApplicationsByTournamentID(Guid TournamentID)
        {
            SqlConnection conn = new SqlConnection();

            conn.ConnectionString = ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString;

            SqlCommand cmd = new SqlCommand();

            cmd.Connection = conn;

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "GetAllTeamApplicationByTournamentID";
            cmd.Parameters.Add(new SqlParameter("@tournamentID", SqlDbType.UniqueIdentifier)).Value = TournamentID;

            try
            {
                cmd.Connection.Open();
                DataTable      dt          = new DataTable();
                SqlDataAdapter dataAdapter = new SqlDataAdapter(cmd);
                dataAdapter.Fill(dt);
                cmd.Connection.Close();

                List <TeamApplication> teamApplications = new List <TeamApplication>();

                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    Organization org = new Organization(Guid.NewGuid());
                    org.Name = dt.Rows[i]["OrganizationName"].ToString();
                    TeamApplication team = new TeamApplication(TournamentID, org.Id, Guid.Parse(dt.Rows[i]["TeamApplicationID"].ToString()));
                    team.TeamName       = dt.Rows[i]["TeamName"].ToString();
                    team.Category       = dt.Rows[i]["Category"].ToString();
                    team.CoachName      = dt.Rows[i]["CoachName"].ToString();
                    team.Status         = (int)dt.Rows[i]["StatusField"];
                    team.TeamMessage    = dt.Rows[i]["TeamMessage"].ToString();
                    team.SubmissionDate = DateTime.Parse(dt.Rows[0]["SubmissionDate"].ToString());
                    team.Organization   = org;
                    teamApplications.Add(team);
                }
                return(teamApplications);
            }
            catch (Exception e)
            {
                cmd.Connection.Close();
            }
            return(null);
        }
Пример #8
0
        public IHttpActionResult ApproveApplication(TeamApplication application)
        {
            CSGOTeam team = UserIsTeamAdmin(application.TeamId);

            if (team == null)
            {
                return(BadRequest("You need to be team admin."));
            }

            TeamApplication entity = team.Applications.SingleOrDefault(a => a.ApplicantId == application.ApplicantId);

            entity.State = NotificationState.Accepted;

            ApplicationUser user = _dbContext.Users.Find(application.ApplicantId);

            team.Members.Add(new TeamMember()
            {
                Member   = user,
                IsActive = true,
                IsAdmin  = false,
                IsEditor = false
            });
            try
            {
                _dbContext.SaveChanges();
            }
            catch (DbUpdateException e)
            {
                System.Diagnostics.Trace.TraceError($"Team application approve error: ${e.Message}");
                return(BadRequest("Something went wrong..."));
            }

            try
            {
                List <BellumGensPushSubscription> subs = _dbContext.PushSubscriptions.Where(s => s.userId == entity.ApplicantId).ToList();
                NotificationsService.SendNotification(subs, application, NotificationState.Accepted);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.TraceWarning($"Team application approve push notification fail: ${e.Message}");
            }

            return(Ok(entity));
        }
        public async Task <IActionResult> ApplyToTeam(TeamApplication application)
        {
            if (ModelState.IsValid)
            {
                TeamApplication entity = await _dbContext.TeamApplications.FindAsync(application.ApplicantId, application.TeamId);

                if (entity != null)
                {
                    entity.Message = application.Message;
                    entity.Sent    = DateTimeOffset.Now;
                    entity.State   = NotificationState.NotSeen;
                }
                else
                {
                    _dbContext.TeamApplications.Add(application);
                }

                try
                {
                    await _dbContext.SaveChangesAsync();
                }
                catch (DbUpdateException e)
                {
                    System.Diagnostics.Trace.TraceError($"Team application error: ${e.Message}");
                    return(BadRequest("Something went wrong..."));
                }
                TeamMember admin = await _dbContext.TeamMembers.Where(m => m.TeamId == application.TeamId && m.IsAdmin).FirstOrDefaultAsync();

                try
                {
                    List <BellumGensPushSubscription> subs = await _dbContext.BellumGensPushSubscriptions.Where(s => s.UserId == admin.UserId).ToListAsync();

                    await _notificationService.SendNotificationAsync(subs, application);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.TraceError($"Push sub error: ${e.Message}");
                }
                return(Ok(application));
            }
            return(BadRequest("Something went wrong with your application validation"));
        }
        public async Task <IActionResult> ApproveApplication(TeamApplication application)
        {
            if (!await UserIsTeamAdmin(application.TeamId))
            {
                return(BadRequest("You need to be team admin."));
            }

            TeamApplication entity = await _dbContext.TeamApplications.FindAsync(application.ApplicantId, application.TeamId);

            entity.State = NotificationState.Accepted;

            _dbContext.TeamMembers.Add(new TeamMember()
            {
                UserId   = application.ApplicantId,
                TeamId   = application.TeamId,
                IsActive = true,
                IsAdmin  = false,
                IsEditor = false
            });
            try
            {
                await _dbContext.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                System.Diagnostics.Trace.TraceError($"Team application approve error: ${e.Message}");
                return(BadRequest("Something went wrong..."));
            }

            try
            {
                List <BellumGensPushSubscription> subs = await _dbContext.BellumGensPushSubscriptions.Where(s => s.UserId == entity.ApplicantId).ToListAsync();

                await _notificationService.SendNotificationAsync(subs, application, NotificationState.Accepted);
            }
            catch (Exception e)
            {
                System.Diagnostics.Trace.TraceWarning($"Team application approve push notification fail: ${e.Message}");
            }

            return(Ok(entity));
        }
        public static void SendNotification(List <BellumGensPushSubscription> subs, TeamApplication notification, NotificationState state)
        {
            var subject = @"https://bellumgens.com";

            foreach (BellumGensPushSubscription sub in subs)
            {
                var subscription = new PushSubscription(sub.endpoint, sub.p256dh, sub.auth);
                var vapidDetails = new VapidDetails(subject, NotificationsService._publicVapidKey, NotificationsService._privateVapidKey);

                var webPushClient = new WebPushClient();
                var payload       = new BellumGensNotificationWrapper(notification, state);
                try
                {
                    webPushClient.SendNotification(subscription, payload.ToString(), vapidDetails);
                }
                catch (WebPushException exception)
                {
                    Console.WriteLine(exception);
                }
            }
        }
        public async Task <IActionResult> RejectApplication(TeamApplication application)
        {
            if (!await UserIsTeamAdmin(application.TeamId))
            {
                return(BadRequest("You need to be team admin."));
            }

            TeamApplication entity = await _dbContext.TeamApplications.FindAsync(application.ApplicantId, application.TeamId);

            entity.State = NotificationState.Rejected;
            try
            {
                await _dbContext.SaveChangesAsync();
            }
            catch (DbUpdateException e)
            {
                System.Diagnostics.Trace.TraceError($"Team application reject error: ${e.Message}");
                return(BadRequest("Something went wrong... "));
            }
            return(Ok("ok"));
        }
Пример #13
0
        public IHttpActionResult ApplyToTeam(TeamApplication application)
        {
            if (ModelState.IsValid)
            {
                TeamApplication entity = _dbContext.TeamApplications.Find(application.ApplicantId, application.TeamId);
                if (entity != null)
                {
                    entity.Message = application.Message;
                    entity.Sent    = DateTimeOffset.Now;
                    entity.State   = NotificationState.NotSeen;
                }
                else
                {
                    _dbContext.TeamApplications.Add(application);
                }

                try
                {
                    _dbContext.SaveChanges();
                }
                catch (DbUpdateException e)
                {
                    System.Diagnostics.Trace.TraceError($"Team application error: ${e.Message}");
                    return(BadRequest("Something went wrong..."));
                }
                List <TeamMember> admins = _dbContext.Teams.Find(application.TeamId).Members.Where(m => m.IsAdmin).ToList();
                try
                {
                    List <BellumGensPushSubscription> subs = _dbContext.PushSubscriptions.ToList();
                    subs = subs.FindAll(s => admins.Any(a => a.UserId == s.userId));
                    NotificationsService.SendNotification(subs, application);
                }
                catch (Exception e)
                {
                    System.Diagnostics.Trace.TraceError($"Push sub error: ${e.Message}");
                }
                return(Ok(application));
            }
            return(BadRequest("Something went wrong with your application validation"));
        }
Пример #14
0
        public async Task <IActionResult> OnGetRejectMemberAsync(int teamId, int applicationId)
        {
            var authResult = await AuthChecks(teamId);

            if (!authResult.passed)
            {
                return(authResult.redirect);
            }

            TeamApplication application = await(from app in _context.TeamApplications
                                                where app.ID == applicationId
                                                select app).FirstOrDefaultAsync();

            if (application == null)
            {
                return(NotFound("Could not find application"));
            }

            Team team = await _context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);

            if (application.Team != team)
            {
                return(Forbid());
            }

            var allApplications = from app in _context.TeamApplications
                                  where app.Player == application.Player &&
                                  app.Team.Event == Event
                                  select app;

            _context.TeamApplications.RemoveRange(allApplications);
            await _context.SaveChangesAsync();

            MailHelper.Singleton.SendPlaintextWithoutBcc(new string[] { application.Player.Email },
                                                         $"{Event.Name}: Your application to {team.Name} was not approved",
                                                         $"Sorry! You can apply to another team if you wish.");

            return(RedirectToPage("./Details", new { teamId = teamId }));
        }
Пример #15
0
        public bool DeleteTeamApplication(TeamApplication app)
        {
            SqlCommand cmd = new SqlCommand("DeleteTeamApplication", new SqlConnection(ConfigurationManager.ConnectionStrings["DBConnectionString"].ConnectionString));

            cmd.CommandType = CommandType.StoredProcedure;
            cmd.Parameters.Add(new SqlParameter("@tournid", SqlDbType.UniqueIdentifier)).Value   = app.TournamentID;
            cmd.Parameters.Add(new SqlParameter("@orgid", SqlDbType.UniqueIdentifier)).Value     = app.OrganizationID;
            cmd.Parameters.Add(new SqlParameter("@teamappid", SqlDbType.UniqueIdentifier)).Value = app.ApplicationID;

            try
            {
                cmd.Connection.Open();
                cmd.ExecuteNonQuery();
                cmd.Connection.Close();
                return(true);
            }
            catch (Exception e)
            {
                cmd.Connection.Close();
            }
            return(false);
        }
Пример #16
0
        public IHttpActionResult RejectApplication(TeamApplication application)
        {
            CSGOTeam team = UserIsTeamAdmin(application.TeamId);

            if (team == null)
            {
                return(BadRequest("You need to be team admin."));
            }

            TeamApplication entity = team.Applications.SingleOrDefault(a => a.ApplicantId == application.ApplicantId);

            entity.State = NotificationState.Rejected;
            try
            {
                _dbContext.SaveChanges();
            }
            catch (DbUpdateException e)
            {
                System.Diagnostics.Trace.TraceError($"Team application reject error: ${e.Message}");
                return(BadRequest("Something went wrong... "));
            }
            return(Ok("ok"));
        }
Пример #17
0
        public void Run()
        {
            var user = new User("Jody_Program_User");

            Thread.CurrentPrincipal = user;

            var teamApp = new TeamApplication();

            teamApp.SetupConfig(true, true, true);
            var stop = false;

            //track this so we can repeat a year if needed
            //var seed = 156;// DateTime.Now.Millisecond;
            //var random = new Random(seed);
            //WriteLine("Seed: " + seed);
            var random = new Random();


            while (!stop)
            {
                teamApp.ClearScreen();
                var leagueView = teamApp.LeagueService.GetByName("NHL");

                WriteLine("League: " + leagueView.Name + " loaded.");

                var currentData = teamApp.GameDataService.GetGameSummary().Result;
                teamApp.GameDataService.SetupComeptitionsForDay(currentData.CurrentDay, currentData.CurrentYear);
                teamApp.GameDataService.ProcessDay();
                teamApp.GameDataService.PlayDay(random);
                teamApp.GameDataService.ProcessDay();

                WriteLine("Year: " + currentData.CurrentYear);
                WriteLine("Day: " + currentData.CurrentDay);

                teamApp.ScheduleGameService.GetGamesForDay(currentData.CurrentDay, currentData.CurrentYear).ToList().ForEach(game =>
                {
                    WriteLine(game.ToString());
                });

                if (!teamApp.GameDataService.IncrementDay())
                {
                    WriteLine("Could not increment day.");
                }
                else
                {
                    WriteLine("Day: " + currentData.CurrentDay);
                    teamApp.ScheduleGameService.GetGamesForDay(currentData.CurrentDay, currentData.CurrentYear).ToList().ForEach(game =>
                    {
                        WriteLine(game.ToString());
                    });
                }


                var displayComps = teamApp.CompetitionService.GetCompetitionsByYear(currentData.CurrentYear).Result.ToList();
                var activeComps  = teamApp.CompetitionService.GetActiveCompetitions(currentData.CurrentYear).ToList();

                if (activeComps.Count > 0)
                {
                    displayComps.ToList().ForEach(m =>
                    {
                        if (m.Type == "Season")
                        {
                            var standings = teamApp.StandingsService.GetStandings(m.Id, 1).Result;
                            var view      = new StandingsView(standings);

                            WriteLine(view.GetView(StandingsView.LEAGUE));
                        }
                        else if (m.Type == "Playoff")
                        {
                            var playoffs = teamApp.PlayoffService.GetPlayoffSummary(m.Id);

                            var format = "{0,2} {1,5}{2,12}: {3,2}{4,3}{5,2} :{6,-12}";
                            playoffs.Result.Series.ToList().ForEach(series =>
                            {
                                var output = string.Format(format, series.Round, series.Name, series.HomeTeamName, series.HomeWins, "-", series.AwayWins, series.AwayTeamName);
                                WriteLine(output);
                            });
                        }
                        else
                        {
                            WriteLine("No type defined");
                        }
                    });
                }
                else
                {
                    teamApp.CompetitionService.GetCompetitionsByYear(currentData.CurrentYear).Result.ToList().ForEach(m =>
                    {
                        if (
                            m.Type == "Season")
                        {
                            var standings = teamApp.StandingsService.GetStandings(m.Id, 1).Result;
                            var view      = new StandingsView(standings);

                            WriteLine(view.GetView(StandingsView.LEAGUE));
                        }
                        else if (m.Type == "Playoff")
                        {
                            var playoffs = teamApp.PlayoffService.GetPlayoffSummary(m.Id);

                            var format = "{0,2} {1,5}{2,12}: {3,2}{4,3}{5,2} :{6,-12}";
                            playoffs.Result.Series.ToList().ForEach(series =>
                            {
                                var output = string.Format(format, series.Round, series.Name, series.HomeTeamName, series.HomeWins, "-", series.AwayWins, series.AwayTeamName);
                                WriteLine(output);
                            });
                        }
                        else
                        {
                            WriteLine("No type defined");
                        }
                    });

                    teamApp.GameDataService.IncrementYear();
                    teamApp.GameDataService.RandomlyChangeSkillLevels(random);
                }
                WriteLine("Press Enter to continue or type 'quit'");
                var input = ReadLine();
                if (input.Equals("quit"))
                {
                    stop = true;
                }
            }

            WriteLine("Press Enter to Close the app");
            ReadLine();
        }
Пример #18
0
        public async Task <IActionResult> OnGet(int teamID, string password)
        {
            if (LoggedInUser == null)
            {
                return(Challenge());
            }

            if (EventRole != EventRole.play || IsNotAllowedInInternEvent())
            {
                return(Forbid());
            }

            if (!Event.IsTeamMembershipChangeActive)
            {
                return(NotFound("Team membership change is not currently allowed."));
            }

            TeamMembers playerTeam = await(from member in _context.TeamMembers
                                           where member.Member == LoggedInUser &&
                                           member.Team.Event == Event
                                           select member).FirstOrDefaultAsync();

            if (playerTeam != null)
            {
                return(RedirectToPage("./Details", new { teamId = playerTeam.Team.ID }));
            }

            Team = await(from t in _context.Teams
                         where t.ID == teamID && t.Event == Event
                         select t).FirstOrDefaultAsync();

            if (Team == null)
            {
                return(NotFound());
            }

            if (password != null && password == Team.Password)
            {
                Tuple <bool, string> result = await TeamHelper.AddMemberAsync(_context, Event, EventRole, teamID, LoggedInUser.ID);

                if (result.Item1)
                {
                    return(RedirectToPage("./Details", new { teamId = teamID }));
                }
                return(NotFound(result.Item2));
            }

            // Only handle one application at a time for a player to avoid spamming all teams
            IEnumerable <TeamApplication> oldApplications = from oldApplication in _context.TeamApplications
                                                            where oldApplication.Player == LoggedInUser && oldApplication.Team.Event == Event
                                                            select oldApplication;

            _context.TeamApplications.RemoveRange(oldApplications);

            TeamApplication application = new TeamApplication()
            {
                Team   = Team,
                Player = LoggedInUser
            };

            _context.TeamApplications.Add(application);

            await _context.SaveChangesAsync();

            MailHelper.Singleton.SendPlaintextOneAddress(Team.PrimaryContactEmail,
                                                         $"{Event.Name}: {LoggedInUser.Name} is applying to join {Team.Name}",
                                                         $"You can contact {LoggedInUser.Name} at {LoggedInUser.Email}. To accept or reject this request, visit your team page at http://puzzlehunt.azurewebsites.net/{Event.ID}/play/Teams/{Team.ID}/Details.");

            return(Page());
        }
Пример #19
0
        public async Task SendNotificationAsync(List <BellumGensPushSubscription> subs, TeamApplication notification, NotificationState state)
        {
            var subject = @"https://bellumgens.com";

            foreach (BellumGensPushSubscription sub in subs)
            {
                var subscription = new PushSubscription(sub.Endpoint, sub.P256dh, sub.Auth);
                var vapidDetails = new VapidDetails(subject, _publicVapidKey, _privateVapidKey);

                var webPushClient = new WebPushClient();
                var payload       = new BellumGensNotificationWrapper(notification, state);
                try
                {
                    await webPushClient.SendNotificationAsync(subscription, payload.ToString(), vapidDetails);
                }
                catch
                {
                }
            }
        }