public ResponseModel Close(int id, bool state) { object obj; int status = 404; var result = new BetResponseModel(); try { var roulette = rouletteRepo.GetById(id); result.Message = ValidateClose(roulette); if (result.Message.Count == 0) { roulette.State = state; obj = rouletteRepo.Update(roulette); if (obj != null) { var betList = betRepo.GetByRouleteId(id); foreach (var item in betList) { betResponseModel.Color = item.Color; betResponseModel.IdRoulette = item.IdRoulette; betResponseModel.Message = null; betResponseModel.Number = item.Number; betResponseModelList.Add(betResponseModel); } if (betResponseModelList.Count > 0) { status = 200; obj = betResponseModelList; } else { obj = "La consulta no produjo ningun resultado."; } } else { obj = "Ha ocurrido un error mientras se actualizaban lso datos."; } } else { obj = result.Message; } } catch (Exception) { status = 500; obj = "Ha ocurrido un error inesperado, por favor inténtalo nuevamente"; } SetObjectResponse(obj, status); return(response); }