コード例 #1
0
        private LadderDTO GenerateDTOFromRow(string[] row)
        {
            LadderDTO ladderDTO = new LadderDTO()
            {
                ID         = row[0],
                Name       = row[1],
                MinimumElo = Convert.ToInt32(row[2]),
                MaximumElo = Convert.ToInt32(row[3]),
                Game       = (Games)Convert.ToInt32(row[4])
            };

            return(ladderDTO);
        }
コード例 #2
0
        public bool EditLadder(LadderDTO ladderDTO)
        {
            List <string[]> param = new List <string[]>()
            {
                new string[] { "@ID", ladderDTO.ID },
                new string[] { "@Name", ladderDTO.Name },
                new string[] { "@MinimumElo", ladderDTO.MinimumElo.ToString() },
                new string[] { "@MaximumElo", ladderDTO.MaximumElo.ToString() },
                new string[] { "@Game", ((int)ladderDTO.Game).ToString() },
            };
            var result = SQLConnection.ExecuteNonSearchQueryParameters($"Update Ladder SET 'Name' = @Name, 'MinimumElo' = @MinimumElo, 'MaximumElo' = @MaximumElo, 'Game' = @Game WHERE ID= @ID;", param);

            return(result);
        }
コード例 #3
0
        public bool CreateLadder(LadderDTO ladderDTO)
        {
            List <string[]> param = new List <string[]>()
            {
                new string[] { "@ID", ladderDTO.ID },
                new string[] { "@Name", ladderDTO.Name },
                new string[] { "@MinimumElo", ladderDTO.MinimumElo.ToString() },
                new string[] { "@MaximumElo", ladderDTO.MaximumElo.ToString() },
                new string[] { "@Game", ((int)ladderDTO.Game).ToString() },
            };
            var result = SQLConnection.ExecuteNonSearchQueryParameters($"INSERT INTO Ladder (ID,Name,MinimumElo,MaximumElo,Game) VALUES (@ID, @Name,@MinimumElo,@MaximumElo,@Game);", param);

            return(result);
        }
コード例 #4
0
        public LadderErrorCodes CreateLadder(LadderDTO ladderDTO)
        {
            if (ladderDTO.MinimumElo >= ladderDTO.MaximumElo)
            {
                return(LadderErrorCodes.MinHigherThanMax);
            }
            ladderDTO.ID = generator.GenerateID(12);
            var result = ladderDB.CreateLadder(ladderDTO);

            if (result == false)
            {
                return(LadderErrorCodes.UnknownException);
            }
            return(LadderErrorCodes.NoError);
        }
コード例 #5
0
        public void CreateLadder_MinHigherThanMax()
        {
            //Arrange
            LadderManager ladderManager = new LadderManager("test");
            LadderDTO     ladderDTO     = new LadderDTO()
            {
                ID         = "",
                Game       = Games.CallOfDuty,
                MaximumElo = 1500,
                MinimumElo = 2000,
                Name       = "Bronze Call of Duty Ladder"
            };

            //Act
            var result = ladderManager.CreateLadder(ladderDTO);

            //Assert
            Assert.AreEqual(LadderErrorCodes.MinHigherThanMax, result);
        }
コード例 #6
0
        public IActionResult CreateLadder(CreateLadderViewModel model)
        {
            LadderDTO ladderDTO = new LadderDTO()
            {
                Game       = model.Game,
                MinimumElo = model.MinimumElo,
                MaximumElo = model.MaximumElo,
                Name       = model.Name
            };
            var result = ladderManager.CreateLadder(ladderDTO);

            switch (result)
            {
            case LadderErrorCodes.NoError:
                return(RedirectToAction("Index"));

            case LadderErrorCodes.UnknownException:
                return(RedirectToAction("Error", "Home", new { errorMessage = "An Unknown error occured while creating a ladder", errorDate = DateTime.Now }));
            }
            return(RedirectToAction("Index"));
        }
コード例 #7
0
 public bool CreateLadder(LadderDTO ladderDTO)
 {
     return(true);
 }