Пример #1
0
 public static bool SaveValuation(Valuation model)
 {
     using (var db = new SQLiteConnection(ConnectionString))
     {
         var result = db.InsertOrReplace(model);
         return((result > 0)? true: false);
     }
 }
Пример #2
0
        private Valuation BuscaEstabelecimento(string cnpj)
        {
            // var client = new RestClient("https://www.receitaws.com.br");
            // var request = new RestRequest("/v1/cnpj/{cnpj}", Method.GET);
            // request.AddUrlSegment("cnpj", cnpj);
            // var response = client.Execute<ReceitaWs>(request);

            var estabelecimento = new Valuation()
            {
                Time  = DateTime.Now,
                Price = 5.6M
            };

            return(estabelecimento);
        }
Пример #3
0
        static DbManager()
        {
            var databaseDir = Environment.CurrentDirectory;

            databaseDir = Path.Combine(databaseDir, "App_Data");
            var databasePath = Path.Combine(databaseDir, "example.db");

            if (!Directory.Exists(databaseDir))
            {
                Directory.CreateDirectory(databaseDir);
            }
            if (!File.Exists(databasePath))
            {
                var fs = File.Create(databasePath);
                fs.Close();
                using (var db = new SQLiteConnection(databasePath))
                {
                    db.CreateTable <Stock>();
                    db.CreateTable <Valuation>();
                    var euro = new Stock()
                    {
                        Symbol = "�"
                    };
                    db.Insert(euro);   // Insert the object in the database

                    var valuation = new Valuation()
                    {
                        Price = 15,
                        Time  = DateTime.Now,
                    };
                    db.Insert(valuation);   // Insert the object in the database

                    // Objects created, let's stablish the relationship
                    euro.Valuations = new List <Valuation> {
                        valuation
                    };

                    db.UpdateWithChildren(euro);   // Update the changes into the database
                    if (valuation.Stock == euro)
                    {
                        Console.WriteLine("Inverse relationship already set, yay!");
                    }
                }
            }

            ConnectionString = databasePath;//string.Format(@"Filename={0}", databasePath);
        }