public IEnumerable <object> GetAllRoulette() { try { List <RouletteEntity> objRoulettes = rouletteModel.GetRoulettes(); IEnumerable <object> objResponseRoulettes = from roulettes in objRoulettes select new { roulettes.Id, Status = Enum.GetName(typeof(StatusRouletteEnum), Convert.ToInt32(roulettes.Status)) }; return(objResponseRoulettes); } catch (Exception ex) { throw ex; } }
public bool ValidBetData(string gamblerId, BetRequest betRequest) { try { if (!ValidBetRequest(betRequest)) { ErrorMessage = ErrorEnum.ERROR_RULES_BET.ToString(); return(false); } if (!gamblerValidation.ValidGamblerExist(gamblerId)) { ErrorMessage = ErrorEnum.ERROR_GAMBLER_NOT_EXIST.ToString(); return(false); } if (!rouletteValidation.ValidRouletteExist(betRequest.RouletteId)) { ErrorMessage = ErrorEnum.ERROR_ROULETTE_NOT_EXIST.ToString(); return(false); } if (!rouletteValidation.ValidRouletteIsOpen(betRequest.RouletteId, rouletteModel.GetRoulettes())) { ErrorMessage = ErrorEnum.ERROR_ROULETTE_IS_NOT_OPEN.ToString(); return(false); } if ((gamblerModel.GetOneGambler(gamblerId).Credits - betRequest.CreditsBet) < 0) { ErrorMessage = ErrorEnum.ERROR_GAMBLER_DOES_NOT_HAVE_CREDITS.ToString(); return(false); } return(true); } catch (Exception ex) { throw ex; } }
public bool ValidRouletteExist(int id) { try { if (rouletteModel.GetRoulettes().Any(r => r.Id == id)) { return(true); } return(false); } catch (Exception ex) { throw ex; } }