public CalendarioViewModel() { this.db = new Database(App.PathDB); this.db.LoadCollectionsFromDatabase(); DateTime d = (DateTime)appSettings["DataCorrente"]; this._anno = d.Year; this._mese = d.Month; _giorniAttuali = this.db.GiornateDelMese(this._mese, this._anno); calcolaStringaData(); }
public CategoriaViewModel() { this.db = new Database(App.PathDB); this.db.LoadCollectionsFromDatabase(); this._nomeProdottoCercato = "Cerca"; this._prodottiTrovati = new ObservableCollection<Prodotto>(); this._categoriaBevande = db.CategoriaBevande; this._categoriaPanini = db.CategoriaPanini; }
/// <summary> /// Constructor for the Application object. /// </summary> public App() { // Global handler for uncaught exceptions. UnhandledException += Application_UnhandledException; // Standard Silverlight initialization InitializeComponent(); // Phone-specific initialization InitializePhoneApplication(); // Show graphics profiling information while debugging. if (System.Diagnostics.Debugger.IsAttached) { // Display the current frame rate counters. Application.Current.Host.Settings.EnableFrameRateCounter = true; // Show the areas of the app that are being redrawn in each frame. //Application.Current.Host.Settings.EnableRedrawRegions = true; // Enable non-production analysis visualization mode, // which shows areas of a page that are handed off to GPU with a colored overlay. //Application.Current.Host.Settings.EnableCacheVisualization = true; // Disable the application idle detection by setting the UserIdleDetectionMode property of the // application's PhoneApplicationService object to Disabled. // Caution:- Use this under debug mode only. Application that disables user idle detection will continue to run // and consume battery power when the user is not using the phone. PhoneApplicationService.Current.UserIdleDetectionMode = IdleDetectionMode.Disabled; } appSettings.Add("Calorie", 2000); appSettings.Add("Carboidrati", 2000); appSettings.Add("Grassi", 2000); appSettings.Add("Proteine", 2000); appSettings.Add("DataCorrente", DateTime.Today); using(Database db = new Database(App.PathDB)){ if (db.DatabaseExists() == false) { // Create the local database. db.CreateDatabase(); Categoria catPanini = new Categoria { NomeCategoria = "Panini" }; Categoria catBevande = new Categoria { NomeCategoria = "Bevande" }; Categoria catPanificati = new Categoria { NomeCategoria = "Panificati" }; // Prepopulate the categories. db.Categorie.InsertOnSubmit(catPanini); db.Categorie.InsertOnSubmit(catBevande); db.Categorie.InsertOnSubmit(catPanificati); // Create a new to-do item. db.Prodotti.InsertOnSubmit(new Prodotto { NomeProdotto = "crispy", CategoriaFK = catPanini, PathFoto = "crispy.png", Quantita = 1, Carboidrati = 70, UnitaDiMisura = "pz", Grassi = 20, Proteine = 10, Calorie = 150, Media = 1, Piccola = 1, Grande = 1 } ); Prodotto p = new Prodotto { NomeProdotto = "coca coea", CategoriaFK = catBevande, Quantita = 100, PathFoto = "cocacoea.jpg", UnitaDiMisura = "ml", Carboidrati = 10, Grassi = 10, Proteine = 11, Calorie = 200, Media = 250, Piccola = 500, Grande = 1000 }; db.Prodotti.InsertOnSubmit(p); Prodotto p2 = new Prodotto { NomeProdotto = "medoemedo", CategoriaFK = catBevande, Quantita = 100, PathFoto = "cocacoea.jpg", UnitaDiMisura = "ml", Carboidrati = 10, Grassi = 10, Proteine = 11, Calorie = 200, Media = 250, Piccola = 500, Grande = 1000 }; db.Prodotti.InsertOnSubmit(p2); db.Pasti.InsertOnSubmit(new Pasto { ProdottoFK=p2, Quantita=200, Calorie = Math.Round(((200 * p2.Calorie) / p2.Quantita),2), // quantità media prodotto : calorie prodotto = quantità assunta : calorie assunte Grassi=Math.Round(((200*p2.Grassi)/p2.Quantita),2), Carboidrati = Math.Round(((200 * p2.Carboidrati) / p2.Quantita),2), Proteine = Math.Round(((200 * p2.Proteine) / p2.Quantita),2), Data=DateTime.Today }); db.SubmitChanges(); } } categoriaVM = new CategoriaViewModel(); }
//COSTRUTTORE public PreviewGiornataVM() { this.db = new Database(App.PathDB); this.db.LoadCollectionsFromDatabase(); this.dataCorrente = (DateTime)appSettings["DataCorrente"]; this._calorieGiornata = this.db.CalorieDelGiorno(dataCorrente); this._grassiGiornata = this.db.GrassiDelGiorno(dataCorrente); this._proteineGiornata = this.db.ProteineDelGiorno(dataCorrente); this._carboidratiGiornata = this.db.CarboidratiDelGiorno(dataCorrente); }