public ActionResult <IEnumerable <string> > CloseRoulette(ResponseBetModel objBet) { try { ResponseAPI <BetModel> response = new ResponseAPI <BetModel>(Parameters.OK_REQUEST, "Success", _BetService.CloseRoulette(objBet)); var Winners = response.lstResponseList.Where(a => a.objResponseBetModel.iIdRoulette == -999).FirstOrDefault(); if (Winners != null) { response.strResponseMessage += " No hubo ganadores !!"; } else { response.strResponseMessage += " Los ganadores son !!"; } return(Ok( response )); } catch (Exception ex) { ResponseAPI <BetModel> response = new ResponseAPI <BetModel>(Parameters.INTERNAL_SERVER_ERROR, ex.Message, false); return(Ok( response )); } }
public IEnumerable <BetModel> CloseRoulette(ResponseBetModel objBetResponse) { List <BetModel> lstResponse = new List <BetModel>(); try { var command = CrearComando("spCloseRoulette"); command.CommandType = System.Data.CommandType.StoredProcedure; command.Parameters.Add("@ROULETTE_ID", SqlDbType.Int).Value = objBetResponse.iIdRoulette; command.Parameters.Add("@WINNING_NUMBER", SqlDbType.Int).Value = objBetResponse.iWinningNumber; command.Parameters.Add("@WINNING_COLOR", SqlDbType.VarChar).Value = objBetResponse.strWinningColor; using (var reader = command.ExecuteReader()) { DataTable dt = new DataTable(); dt.Load(reader); if (dt.Rows.Count > 0) { foreach (DataRow item in dt.Rows) { BetModel objBet = new BetModel(); objBet.iFkClientId = int.Parse(item["FK_CLIENT_ID"].ToString()); objBet.lgBetValue = double.Parse(item["BET_VALUE"].ToString()); objBet.strBetColor = item["BET_COLOR"].ToString(); objBet.iBetNumber = int.Parse(item["BET_NUMBER"].ToString()); objBet.objResponseBetModel.iWinningNumber = objBetResponse.iWinningNumber; objBet.objResponseBetModel.strWinningColor = objBetResponse.strWinningColor; lstResponse.Add(objBet); } } else { BetModel objBet = new BetModel(); objBet.objResponseBetModel.iWinningNumber = objBetResponse.iWinningNumber; objBet.objResponseBetModel.strWinningColor = objBetResponse.strWinningColor; objBet.objResponseBetModel.iIdRoulette = -999; lstResponse.Add(objBet); } } var Winners = lstResponse.Find(a => a.objResponseBetModel.iIdRoulette == -999); if (Winners == null) { BetWinners(lstResponse); } return(lstResponse); } catch (Exception ex) { throw ex; } }
public IEnumerable <BetModel> CloseRoulette(ResponseBetModel objBetResponse) { IEnumerable <BetModel> lstResponse = null; try { ResponseBetModel ValuesWinners = new ResponseBetModel(); ValuesWinners = BetUtilities.CalculateWinnersBet(); ValuesWinners.iIdRoulette = objBetResponse.iIdRoulette; using (var context = _unitOfWork.Create()) { lstResponse = context.Repositories.BetRepository.CloseRoulette(ValuesWinners); context.SaveChanges(); return(lstResponse); } } catch (Exception ex) { throw ex; } }
public static ResponseBetModel CalculateWinnersBet() { ResponseBetModel objResponse = new ResponseBetModel(); try { objResponse.iWinningNumber = RandomNumber(0, 36); if (objResponse.iWinningNumber % 2 == 0) { objResponse.strWinningColor = Parameters.ROJO; } else { objResponse.strWinningColor = Parameters.NEGRO; } return(objResponse); } catch (Exception ex) { throw ex; } }