public Roulette Open(string Id) { Roulette roulette = _rouletteRepository.GetById(Id); if (roulette == null) { throw new CustomException(400, new ServiceResponse { Code = 0, Message = "No se encontró la ruleta." }); } if (roulette.Open != null) { throw new CustomException(400, new ServiceResponse { Code = 0, Message = "Ruleta ya está aperturada." }); } roulette.Open = DateTime.UtcNow.AddHours(-5); roulette.IsOpen = true; return(_rouletteRepository.Update(Id, roulette)); }
public Roulette Bet(string Id, string UserId, int position, double money) { if (money > 10000 || money < 1) { throw new CashOutRangeException(); } Roulette roulette = rouletteRepository.GetById(Id); if (roulette == null) { throw new RouletteNotFound(); } if (roulette.IsOpen == false) { throw new RouletteClosedException(); } double value = 0d; roulette.board[position].TryGetValue(UserId, out value); roulette.board[position].Remove(UserId + ""); roulette.board[position].TryAdd(UserId + "", value + money); return(rouletteRepository.Update(roulette.Id, roulette)); }
public Roulette Open(string Id) { Roulette roulette = rouletteRepository.GetById(Id); if (roulette == null) { throw new RouletteNotFound(); } if (roulette.OpenedAt != null) { throw new NotAllowedOpenException(); } roulette.OpenedAt = DateTime.Now; roulette.IsOpen = true; return(rouletteRepository.Update(Id, roulette)); }