예제 #1
0
        public List <GamblingResultResponse> BuildGamblingResultResponse(int betId)
        {
            try
            {
                List <GamblingResultResponse> gamblingResultResponse = new List <GamblingResultResponse>();
                foreach (GamblingEntity gambling in gamblingModel.GetGamblings().Where(g => g.BetId == betId).ToList())
                {
                    GamblerEntity objGambler = gamblerModel.GetOneGambler(gambling.GamblerId);
                    gamblingResultResponse.Add(new GamblingResultResponse
                    {
                        GamblerId       = objGambler.Id,
                        GamblerFullName = objGambler.FullName,
                        CreditsBet      = gambling.CreditsBet,
                        BetType         = Enum.GetName(typeof(BetTypeEnum), gambling.BetType),
                        BetNumber       = gambling.BetNumber,
                        BetColor        = gambling.BetColor != null ? Enum.GetName(typeof(ColorBetEnum), gambling.BetColor) : null,
                        WontBet         = gambling.WonBet.Value
                    });
                }

                return(gamblingResultResponse);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #2
0
        public int CloseBet(int rouletteId, CloseBetRequest closeBetRequest)
        {
            try
            {
                if (!rouletteModel.UpdateRoulette(rouletteId, status: false))
                {
                    return(0);
                }
                BetEntity objBet = betModel.GetBets().Where(b => b.RouletteId == rouletteId && b.Status == true).FirstOrDefault();
                betModel.UpdateStatusBet(objBet.Id, status: false);
                betResultModel.InsertBetResult(objBet.Id, closeBetRequest);
                gamblingModel.UpdateGamblingsToSaveResult(objBet.Id, closeBetRequest);
                foreach (GamblingEntity gambling in gamblingModel.GetGamblings().Where(g => g.BetId == objBet.Id && g.WonBet == true).ToList())
                {
                    gamblerModel.UpdateGamblerCredits(gambling.GamblerId, gamblerModel.GetOneGambler(gambling.GamblerId).Credits + (gambling.CreditsBet * 2));
                }

                return(objBet.Id);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }