Пример #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);
        }
        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);
 }