예제 #1
0
        public void CloseRoueletteWinningByNumberAndColorTest()
        {
            var cache  = new MockCache();
            var random = new MockGenerateRandom();
            IRouletteService service = new RouletteService(cache, random);
            var dtoAdd   = service.AddRoulette();
            var dtoStart = service.StartRoulette(new Domain.Dtos.RouletteStartDto
            {
                Id = dtoAdd.Id
            });

            service.Bet("mna", new Domain.Dtos.RouletteBetDto
            {
                IdRoulette = dtoAdd.Id,
                CashAmount = 1000,
                Color      = Domain.Enums.ColorEnum.Red,
                Number     = 10
            });
            var dtoClose = service.CloseRoulette(new Domain.Dtos.RouletteCloseDto()
            {
                Id = dtoAdd.Id
            });

            Assert.IsTrue(dtoClose.WinningNumber == 10);
            Assert.IsTrue(dtoClose.Bets[0].WinnerAmount == 6800);
        }
        public IEnumerable <Bet> Close(string id)
        {
            Roulette _roulette = new Roulette()
            {
                Id        = id,
                Open      = "false",
                CloseDate = DateTime.Now.ToString()
            };

            return(_rouleteService.CloseRoulette(_roulette));
        }
예제 #3
0
        public async Task <IActionResult> CloseRoulette(int rouletteId)
        {
            try
            {
                var result = await _rouletteService.CloseRoulette(rouletteId);

                if (result != 0)
                {
                    return(Ok(result));
                }
                return(BadRequest(result));
            }
            catch (Exception ex)
            {
                return(BadRequest(ResponseMessages[ResponseCode.InternalError]));
            }
        }
예제 #4
0
        public async Task <IActionResult> ClouseRoulette(int id)
        {
            var request = await _rouletteService.CloseRoulette(id);

            return(Ok(ResponseMapper.MapClose(request)));
        }