public ActionResult NewIndex(RegistrationExt model)
        {
            //if (SecurityUtils.IsRestrictedEmailDomainDetected(model.EmailAddress))
            //{
            //    SecurityUtils.AddAuditLog("Restricted Email Address Detected", "Restricted Email Address: " + model.EmailAddress);

            //    return RedirectToAction("RestrictedEmailDomain", "Error");
            //}
            PlayersExt pModel = MAP_Registration(model);
            string     Msg    = "";
            bool       status = true;

            ModelState.Remove("id");
            pModel.Notes = "";
            PlayersRepository modelRepo = new PlayersRepository();

            pModel.PlayerID = modelRepo.CreateOrUpdate(ref pModel, ref Msg, ref status, this, false, 0);
            if (pModel.PlayerID > 0)
            {
                ViewBag.RegSuccess = true;
            }
            else
            {
                ViewBag.RegSuccess = false;
            }
            return(View());
        }
Exemplo n.º 2
0
        public void PlayersAll()
        {
            var playersRepository = new PlayersRepository();
            var players           = playersRepository.GetAll().ToList();

            Assert.NotNull(players);
        }
        public async Task GetsPlayers()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                context.Players.AddRange(
                    new Player {
                    Id = 1
                },
                    new Player {
                    Id = 2
                },
                    new Player {
                    Id = 3
                });

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var playersRepository = new PlayersRepository(context);

                var players = await playersRepository.GetAll(0, 2);

                Assert.Equal(2, players.Count);
                Assert.NotNull(players.SingleOrDefault(x => x.Id == 1));
                Assert.NotNull(players.SingleOrDefault(x => x.Id == 2));
            }
        }
        public ActionResult Details(long id)
        {
            if (id != 0)
            {
                //Already Exist
                PlayersRepository modelRepo = new PlayersRepository();
                var model = modelRepo.ReadOne(id);

                //Create Player Premium Dashboard view bag only if Admin user is Logged in
                PlayerDashboardRepository pdRepo = new PlayerDashboardRepository();
                ViewBag.PlayerPremiumDashboard = pdRepo.ReadOne(model.PlayerID);

                if (Request.QueryString["m"] != null)
                {
                    List <MessagesExt> ListOfMsgs = new List <MessagesExt>();

                    new MessagesRepository().BuildMessageList(SecurityUtils.DecryptCypher(Request.QueryString["m"].ToString()), TypeOfMessage.Success, ref ListOfMsgs);

                    model.ListOfMsgs.AddRange(ListOfMsgs);
                }

                BindViewBags(ref model);
                return(View(model));
            }
            else
            {
                //For New Customer Record
                var model = new PlayersExt();
                model.PlayerID = 0;
                BindViewBags(ref model);
                return(View(model));
            }
        }
        public async Task GetsPlayerById()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                context.Players.AddRange(
                    new Player {
                    Id = 1
                },
                    new Player {
                    Id = 2
                });

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var playersRepository = new PlayersRepository(context);

                var player = await playersRepository.GetById(1);

                var player2 = await playersRepository.GetById(2);

                Assert.NotNull(player);
                Assert.NotNull(player2);
                Assert.Equal(1, player.Id);
                Assert.Equal(2, player2.Id);
            }
        }
Exemplo n.º 6
0
        public JsonResult GetHeights()
        {
            PlayersRepository modelRepo = new PlayersRepository();
            var data = modelRepo.ReadAll_Heights();

            return(Json(data.Select(c => new { HeightID = c.HeightID, Height_Display = c.Height_Display }), JsonRequestBehavior.AllowGet));
        }
        public ActionResult Registration(RegistrationExt model)
        {
            //Redirect the User to Error/RestrictedEmailDomain if user enter any Restricted Email Domain while Registration
            string _Msg    = "";
            bool   _status = true;

            if (ModelState.IsValid)
            {
                if (SecurityUtils.IsRestrictedEmailDomainDetected(model.EmailAddress))
                {
                    SecurityUtils.AddAuditLog("Restricted Email Address Detected", "Restricted Email Address: " + model.EmailAddress);

                    return(Json(new { status = false, Msg = "Restricted Email Address: " + model.EmailAddress }, JsonRequestBehavior.AllowGet));
                }

                PlayersExt        player     = MAP_Registration(model);
                PlayersRepository playerRepo = new PlayersRepository();
                playerRepo.CreateOrUpdate(ref player, ref _Msg, ref _status, this);


                return(Json(new { status = _status, Msg = _Msg }, JsonRequestBehavior.AllowGet));
            }

            foreach (ModelState modelState in ViewData.ModelState.Values)
            {
                foreach (ModelError error in modelState.Errors)
                {
                    _Msg = _Msg + " " + error.ErrorMessage;
                }
            }

            return(Json(new { status = false, Msg = _Msg }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 8
0
        public async Task AddAsync_TeamDoesNotExistAndPlayerIsValid_TeamNotFoundExceptionIsThrown()
        {
            // Arrange
            using var connection = new SqliteConnection("DataSource=:memory:");
            connection.Open();

            var options = new DbContextOptionsBuilder()
                          .UseSqlite(connection)
                          .Options;

            using (var context = new AppDbContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                var repository = new PlayersRepository(context);
                var player     = new Player
                {
                    FirstName = "Test",
                    LastName  = "Player",
                    Position  = PositionType.Defender,
                    TeamId    = Guid.NewGuid()
                };

                // Act && Assert
                await Assert.ThrowsAsync <TeamNotExistsException>(() => repository.AddAsync(player));
            }
        }
Exemplo n.º 9
0
        private async Task <ServiceProvider> ConfigureServicesAsync(Database database)
        {
            DiscordSocketClient client = new DiscordSocketClient();

            Container playersRepositoryContainer = await PlayersRepository.CreateContainer(database);

            PlayersRepository playersRepository = new PlayersRepository(playersRepositoryContainer);

            Container adventuresRepositoryContainer = await AdventuresRepository.CreateContainer(database);

            AdventuresRepository adventuresRepository = new AdventuresRepository(adventuresRepositoryContainer);

            TickService tickService = new TickService(playersRepository, adventuresRepository);
            UIService   uiService   = new UIService(client, playersRepository, adventuresRepository);

            return(new ServiceCollection()
                   .AddSingleton(client)
                   .AddSingleton <CommandService>()
                   .AddSingleton <CommandHandlingService>()
                   .AddSingleton <HttpClient>()
                   .AddSingleton(tickService)
                   .AddSingleton(uiService)
                   .AddSingleton(playersRepository)
                   .AddSingleton(adventuresRepository)
                   .BuildServiceProvider());
        }
Exemplo n.º 10
0
        private void RatingForm_Load(object sender, EventArgs e)
        {
            // TODO: данная строка кода позволяет загрузить данные в таблицу "playersDBDataSet.BattlePlayer". При необходимости она может быть перемещена или удалена.

            IRepository <BattlePlayer> topPlayersRepository = new PlayersRepository();

            dataGridView1.DataSource = topPlayersRepository.GetTopTen();
        }
Exemplo n.º 11
0
        public UnitOfWork(ImportLeagueContext importLeagueContext)
        {
            this.importLeagueContext = importLeagueContext;

            Competitions = new CompetitionsRepository(importLeagueContext);
            Players      = new PlayersRepository(importLeagueContext);
            Teams        = new TeamsRepository(importLeagueContext);
        }
Exemplo n.º 12
0
 public UnitOfWork(ApplicationDbContext context)
 {
     _context        = new ApplicationDbContext();
     Tournaments     = new TournamentsRepository(_context);
     Players         = new PlayersRepository(_context);
     TournamentTypes = new Repository <TournamentType>(_context);
     Teams           = new Repository <Team>(_context);
     Matches         = new Repository <Match>(_context);
 }
        public void AddGetPlayerTest()
        {
            PlayersRepository repository = new PlayersRepository(MainTest.ConnectionString);
            string            name       = MainTest.GetRandomName(10);

            repository.AddPlayer(new Player(name));
            _playersList.Add(name);

            Assert.AreEqual(name, repository.GetPlayer(name).Name);
        }
Exemplo n.º 14
0
        public GameProcessService(BulkaContext context)
        {
            _gameProcessRepository = new GameProcessRepository(context);
            _playersRepository     = new PlayersRepository(context);
            _clubRepository        = new ClubRepository(context);

            PaymentService       = new PaymentService(new PaymentRepository(context));
            PlayerSessionService = new PlayerSessionService(context);

            DateTime = DateTime.Now;
        }
        public ActionResult DeletePlayer(long PlayerID)
        {
            string            Msg       = "";
            bool              status    = true;
            PlayersRepository modelRepo = new PlayersRepository();

            status = modelRepo.Delete_Archive(PlayerID, ref Msg, this);

            return(new JsonResult {
                Data = new { status = status, Msg = Msg }
            });
        }
Exemplo n.º 16
0
        public CreatePlayerDTO Create(string name)
        {
            var player           = new Player(name);
            var playerValidation = player.Validate();

            if (playerValidation.IsValid)
            {
                PlayersRepository.Add(player);
                return(new CreatePlayerDTO(player.Id));
            }
            return(new CreatePlayerDTO(playerValidation.errors));
        }
        public void CleanUp()
        {
            if (_playersList.Count == 0)
            {
                return;
            }
            PlayersRepository repository = new PlayersRepository(MainTest.ConnectionString);

            foreach (string playerName in _playersList)
            {
                repository.DeletePlayer(playerName);
            }
        }
Exemplo n.º 18
0
        public ActionResult View(int Id)
        {
            TeamsRepository TeamsRep = new TeamsRepository();
            var             allteams = TeamsRep.GetAllTeams().Where(t => t.Id != Id).OrderBy(t => t.Name);


            if (allteams.Count() > 0)
            {
                ViewData["AllTeams"] = allteams;
            }

            var myteam = TeamsRep.GetAllTeams().Where(t => t.Id == Id).FirstOrDefault();

            if (myteam != null)
            {
                PlayersRepository playerrep = new PlayersRepository();
                ReportsRepository ReportRep = new ReportsRepository();
                var allreports = ReportRep.GetAllReports().Where(r => r.Match.Fixture.HomeTeamId == Id || r.Match.Fixture.AwayTeamId == Id).OrderByDescending(r => r.Match.Fixture.TimeStamp);



                if (Request.QueryString["opponent"] != null)
                {
                    var opponent = allteams.Where(t => t.Id.ToString() == Request.QueryString["opponent"].ToString()).FirstOrDefault();
                    if (opponent != null)
                    {
                        ViewData["OpponentTeamName"] = opponent.Name;
                        allreports = allreports.Where(k => k.Match.Fixture.HomeTeamId == opponent.Id || k.Match.Fixture.AwayTeamId == opponent.Id).OrderByDescending(k => k.Match.Fixture.TimeStamp);
                        ///return
                    }
                }

                var allhomegames = allreports.Where(h => h.Match.Fixture.HomeTeamId == Id);
                var allawaygames = allreports.Where(h => h.Match.Fixture.AwayTeamId == Id);

                if (allhomegames.Count() > 0)
                {
                    ViewData["HomeGames"] = allhomegames;
                }

                if (allawaygames.Count() > 0)
                {
                    ViewData["AwayGames"] = allawaygames;
                }
                return(View(myteam));
            }
            else
            {
                return(Redirect("/"));
            }
        }
Exemplo n.º 19
0
        public ActionResult View(int Id)
        {
            PlayersRepository PlayerRep = new PlayersRepository();
            var myplayer = PlayerRep.GetAllPlayers().Where(r => r.Id == Id).FirstOrDefault();

            if (myplayer != null)
            {
                return(View(myplayer));
            }
            else
            {
                return(Redirect("/"));
            }
        }
Exemplo n.º 20
0
    public void GenerateTokenForNewPlayer()
    {
        IPlayersRepository playersRepository = new PlayersRepository(this.moqDbContext.Object);
        var testPlayer = new Player()
        {
            Id = Guid.NewGuid(), Name = "TestName"
        };
        var testKey = Encoding.ASCII.GetBytes("The secret must be long");

        string token = playersRepository.GenerateToken(testPlayer, testKey);

        Assert.IsNotNull(token);
        Assert.IsNotEmpty(token);
    }
Exemplo n.º 21
0
        public async Task AddAsync_TeamExistsAndPlayerIsValid_PlayerIsAdded()
        {
            // Arrange
            using var connection = new SqliteConnection("DataSource=:memory:");
            connection.Open();

            var options = new DbContextOptionsBuilder()
                          .UseSqlite(connection)
                          .Options;

            var team = new Team
            {
                Name        = "Test team",
                FoundedYear = 2020
            };
            Guid playerAddedId;

            using (var context = new AppDbContext(options))
            {
                await context.Database.EnsureCreatedAsync();

                context.Teams.Add(team);
                await context.SaveChangesAsync();
            }

            using (var context = new AppDbContext(options))
            {
                var repository = new PlayersRepository(context);
                var player     = new Player
                {
                    FirstName = "Test",
                    LastName  = "Player",
                    Position  = PositionType.Defender,
                    TeamId    = team.Id
                };

                // Act
                playerAddedId = await repository.AddAsync(player);
            }

            using (var context = new AppDbContext(options))
            {
                // Assert
                var result = await context.Players
                             .AnyAsync(player => player.TeamId == team.Id &&
                                       player.Id == playerAddedId);

                Assert.True(result);
            }
        }
        public async Task CreatesPlayer()
        {
            using (var context = new ApplicationDbContext(_options))
            {
                var playersRepository = new PlayersRepository(context);

                await playersRepository.Create(new Player { Id = 1 });
            }

            using (var context = new ApplicationDbContext(_options))
            {
                Assert.Equal(1, context.Players.Count());
                Assert.Equal(1, context.Players.Single().Id);
            }
        }
        public ActionResult _Read([DataSourceRequest] DataSourceRequest request)
        {
            long?CoachUserID = null;
            //Check if Coach Logged in then coach can only see leagues where he is coach for.
            var LoggedInUser = SecurityUtils.GetUserDetails();

            if (LoggedInUser.RoleID == (long)Permissions.Coaches)
            {
                CoachUserID = LoggedInUser.UserID;
            }

            PlayersRepository modelRepo = new PlayersRepository();
            DataSourceResult  result    = null;// modelRepo.ReadAll_ForGrid(request,CoachUserID);

            return(Json(result));
        }
Exemplo n.º 24
0
        public static SelectList GetHowActives(long?HowActiveID)
        {
            List <SelectListItem> _ListOfObjects = new List <SelectListItem>();

            PlayersRepository modelRepo = new PlayersRepository();
            var _HowActive = modelRepo.ReadAll_HowActive().OrderBy(o => o.HowActiveID);

            foreach (var item in _HowActive)
            {
                SelectListItem itr = new SelectListItem();
                itr.Text     = item.HowActive;
                itr.Value    = item.HowActiveID.ToString();
                itr.Selected = false;

                _ListOfObjects.Add(itr);
            }

            return(new SelectList(_ListOfObjects, "Value", "Text", HowActiveID));
        }
Exemplo n.º 25
0
        public static SelectList GetHeights(long?HeightID)
        {
            List <SelectListItem> _ListOfObjects = new List <SelectListItem>();

            _ListOfObjects.AddRange(CreateBlankListItem("-- Select your height --"));

            PlayersRepository modelRepo = new PlayersRepository();

            foreach (var item in modelRepo.ReadAll_Heights())
            {
                SelectListItem itr = new SelectListItem();
                itr.Text     = item.Height_Display;
                itr.Value    = item.HeightID.ToString();
                itr.Selected = false;

                _ListOfObjects.Add(itr);
            }

            return(new SelectList(_ListOfObjects, "Value", "Text", HeightID));
        }
Exemplo n.º 26
0
        public TickService
        (
            PlayersRepository playersRepository,
            AdventuresRepository adventuresRepository
        )
        {
            PlayersRepository    = playersRepository;
            AdventuresRepository = adventuresRepository;

            Timer =
                new Timer
                (
                    async _ =>
            {
                await Tick();
            },
                    null,
                    TimeSpan.FromSeconds(0),
                    TimeSpan.FromSeconds(1)
                );
        }
Exemplo n.º 27
0
        public void CleanUp()
        {
            var scoresRepository  = new ScoresRepository(ConnectionString);
            var gamesRepository   = new GamesRepository(ConnectionString);
            var playersRepository = new PlayersRepository(ConnectionString);

            foreach (Guid scoreId in _scoresList)
            {
                scoresRepository.DeleteScore(scoreId);
            }

            foreach (string gameName in _gamesList)
            {
                gamesRepository.DeleteGame(gameName);
            }

            foreach (string playerName in _playersList)
            {
                playersRepository.DeletePlayer(playerName);
            }
        }
        public async Task UpdatesPlayer()
        {
            var playerName  = "Player";
            var playerName2 = "Player1";

            var mockPlayers = new List <Player>
            {
                new Player {
                    Id = 1, Name = playerName
                },
                new Player {
                    Id = 2
                },
                new Player {
                    Id = 3
                }
            };

            using (var context = new ApplicationDbContext(_options))
            {
                context.Players.AddRange(mockPlayers);

                context.SaveChanges();
            }

            using (var context = new ApplicationDbContext(_options))
            {
                var playersRepository = new PlayersRepository(context);
                var existingPlayer    = mockPlayers[0];
                var updatedPlayer     = mockPlayers[0];
                updatedPlayer.Name = playerName2;
                await playersRepository.Update(existingPlayer, updatedPlayer);
            }

            using (var context = new ApplicationDbContext(_options))
            {
                Assert.NotNull(context.Players.SingleOrDefault(x => x.Id == 1));
                Assert.Equal(playerName2, context.Players.Single(x => x.Id == 1).Name);
            }
        }
Exemplo n.º 29
0
        public ActionResult Index()
        {
            var dbContext = new TennisTrackerContext();

            _playerRepository = new PlayersRepository(dbContext);
            var players = _playerRepository.GetAllPlayers();
            var singlesMatchRepository = new SinglesMatchRepository(dbContext);
            var singlesMatchService    = new SinglesMatchService(singlesMatchRepository);

            var winLossDictionary = new List <Dictionary <int, string> >();

            foreach (var player in players)
            {
                var winLoss =
                    singlesMatchService.CalculateWinLoss(player.PlayerId);
                winLossDictionary.Add(winLoss);
            }

            var playersWithWinLoss = new PlayersWithWinLoss(players, winLossDictionary);

            return(View(playersWithWinLoss));
        }
Exemplo n.º 30
0
        public UIService
        (
            DiscordSocketClient discordSocketClient,
            PlayersRepository playersRepository,
            AdventuresRepository adventuresRepository
        )
        {
            DiscordSocketClient  = discordSocketClient;
            PlayersRepository    = playersRepository;
            AdventuresRepository = adventuresRepository;

            Timer =
                new Timer
                (
                    async _ =>
            {
                await UIUpdate();
            },
                    null,
                    TimeSpan.FromSeconds(0),
                    TimeSpan.FromSeconds(2)
                );
        }
Exemplo n.º 31
0
 protected void InitDataObjects()
 {
     eventsRepo = new EventsRepository();
     scoreMethodRepo = new ScoreMethodRepository();
     seriesRepo = new SeriesRepository();
     teamsRepo = new TeamsRepository();
     eventTeamsRepo = new EventTeamsRepository();
     playersRepo = new PlayersRepository();
     eventPlayersRepo = new EventPlayersRepository();
     matchRepo = new MatchesRepository();
     matchTeamsRepo = new MatchTeamsRepository();
     packsetRepo = new PacksetsRepository();
     matchPlayerRepo = new MatchPlayersRepository();
 }