Ejemplo n.º 1
0
        public async Task <NewRouletteResponse> NewRoulette()
        {
            NewRouletteResponse response = new NewRouletteResponse();

            using (var ctx = GetInstance())
            {
                string query = "INSERT INTO Roulette (State, Bet) VALUES (0, 0)";
                using (var command = new SQLiteCommand(query, ctx))
                {
                    command.ExecuteNonQuery();
                }
                query = "SELECT id FROM Roulette ORDER by id DESC LIMIT 1";
                using (var command = new SQLiteCommand(query, ctx))
                {
                    using (var reader = command.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            response.id = Convert.ToInt32(reader[0]);
                        }
                    }
                }
            }
            return(response);
        }
Ejemplo n.º 2
0
        public async Task <BaseResponse <NewRouletteResponse> > NewRoulete()
        {
            try
            {
                NewRouletteResponse response = await DbContex.NewRoulette();

                if (response.id == 0)
                {
                    return new BaseResponse <NewRouletteResponse> {
                               Reponse = null, message = "Can't create roulette"
                    }
                }
                ;
                return(new BaseResponse <NewRouletteResponse> {
                    Reponse = response
                });
            }
            catch (Exception ex)
            {
                return(new BaseResponse <NewRouletteResponse> {
                    Reponse = null, message = "ERROR: " + ex.Message
                });
            }
        }