/// <summary> /// this method is for create history opening and closing of the roulettes /// </summary> /// <param name="idRoulette">roulette identifier</param> /// <returns>int value identifier of this</returns> public async Task <int> createAsync(openingClosingRoulette objOpeningClosingRoulette) { int idOpeningClousingRoulete = 0; try { string _Result = ""; Dictionary <string, object> lstParametros = new Dictionary <string, object>(); lstParametros.Add("@idRoulette", objOpeningClosingRoulette.idRoulette); lstParametros.Add("@createType", 1); _Result = await commandExecuteDBAsync("SP_OPENNINGCLOSINGROULETTE_CREATE", lstParametros, new SqlParameter() { ParameterName = "@Result", Value = _Result }); if (Convert.ToInt32(_Result) > 0) { idOpeningClousingRoulete = Convert.ToInt32(_Result); } else { throw new Exception("No se obtuvo un identificador válido."); } } catch (Exception ex) { throw new Exception(string.Format("Se presentó un error {0} al intentar crear la apertura de la ruleta. ", ex.Message)); } return(idOpeningClousingRoulete); }
/// <summary> /// this method is used for opening a roulette /// </summary> /// <param name="idRoulette">input parameter, is a roulette identifier for open</param> /// <returns>boolean value, indicates status of opennign roulette</returns> public async Task <bool> RouletteOpen(int idRoulette) { bool isOpen = false; try { if (ValidateRouletteStatus(idRoulette)) { throw new Exception(string.Format("La ruleta {0} ya se encuentra abierta.", idRoulette)); } else { isOpen = await UpdateRoulette(idRoulette, true); if (isOpen) { openingClosingRoulette objopeningClosingRoulette = new openingClosingRoulette(); objopeningClosingRoulette.idRoulette = idRoulette; int Res = await _dbAcces._repository.openingClousingRoulete.createAsync(objopeningClosingRoulette); _dbAcces.SaveChange(); } } } catch (Exception ex) { _dbAcces.DiscardChange(); throw new Exception(string.Format("Se presentó un error {0} al intentar abrir la ruleta. ", ex.Message)); } return(isOpen); }
/// <summary> /// method to read the last roulette opening record /// </summary> /// <param name="idRoulette">Roulette identifier</param> /// <returns></returns> public async Task <openingClosingRoulette> ReadByIdAsync(int idRoulette) { openingClosingRoulette objRoulette = new openingClosingRoulette(); try { Dictionary <string, object> lstParametros = new Dictionary <string, object>(); lstParametros.Add("@idRoulette", idRoulette); lstParametros.Add("@queryType", 1); objRoulette = Utilities.MapObjectInstance <openingClosingRoulette>(await commandExecuteDBAsync("SP_OPENINGCLOSINGROULETTE_READ", lstParametros)).FirstOrDefault(); } catch (Exception ex) { throw new Exception(string.Format("Se presentó un error {0} al consultar la ruleta {1}", ex.Message, idRoulette)); } return(objRoulette); }