Exemplo n.º 1
0
        public async Task <IActionResult> CheckPrime([FromBody] ModelCls number)
        {
            Service service = new Service();
            bool    result  = service.isPrime(number);

            if (result == false)
            {
                return(this.BadRequest());
            }
            return(Ok(result));
        }
Exemplo n.º 2
0
        public bool isPrime(ModelCls model)
        {
            int n, i, m = 0, flag = 0;

            n = model.Number;
            m = n / 2;
            for (i = 2; i <= m; i++)
            {
                if (n % i == 0)
                {
                    return(false);

                    break;
                }
            }
            if (flag == 0)
            {
                return(true);
            }

            return(false);
        }
Exemplo n.º 3
0
        public async Task <ModelCls> GetCartItemsAsync()
        {
            ModelCls modelCls = new ModelCls();

            using (var firstConnection = new SqliteConnection(DbConnection.connectionString))
            {
                firstConnection.Open();
                var updateCommand = firstConnection.CreateCommand();
                updateCommand.CommandText =
                    @"
                        SELECT *
                        FROM NUMBER
                    ";
                SqliteDataReader adr = updateCommand.ExecuteReader();

                while (adr.Read())
                {
                    modelCls.Number = adr.GetInt32(1);
                }
            }
            return(await Task.FromResult(modelCls));
        }