/// <summary>
        /// Inserts sample data into the database
        /// </summary>
        /// <param name="db">Database context to use</param>
        private void InsertSampleData(MedicineContext db)
        {
            // Sample Medicines
            Medicine m1 = new Medicine()
            {
                Name = "saridon (sample)",
                MfgDate = DateTime.Now,
                ExpDate = DateTime.Now.AddMonths(3),
                CureFor = "Headache",
                Dosage = "4",
                DosageType = "cups",
                AgeGroup = "18+",
                Price = 20.50F,
                BoughtAddress = "Near Canara bank, Kormangala, Bangalore. Ph: 080-23399239",
                Quantity = 2,
                QuantityType = "pills",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };
            db.Medicines.InsertOnSubmit(m1);

            Medicine m2 = new Medicine()
            {
                Name = "nice (sample)",
                MfgDate = DateTime.Now,
                ExpDate = DateTime.Now.AddMonths(3),
                IsUsing = true,
                CureFor = "Fever",
                Dosage = "3",
                DosageType = "spoons",
                AgeGroup = "20+",
                Price = 25.50F,
                BoughtAddress = "Indiranagar, Bangalore. Ph: 080-23399239",
                Quantity = 4,
                QuantityType = "pills",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };
            db.Medicines.InsertOnSubmit(m2);

            db.SubmitChanges();

            // Sample Groups
            Group g1 = new Group()
            {
                Name = "Is Using (sample)",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };
            db.Groups.InsertOnSubmit(g1);

            Group g2 = new Group()
            {
                Name = "Not Using (sample)",
                CreatedAt = DateTime.Now,
                UpdatedAt = DateTime.Now
            };
            db.Groups.InsertOnSubmit(g2);

            db.SubmitChanges();

            // Sample Associations
            db.MedicinesGroups.InsertOnSubmit(new Medicine_Group()
            {
                Medicine = m1,
                Group = g1
            });

            db.MedicinesGroups.InsertOnSubmit(new Medicine_Group()
            {
                Medicine = m2,
                Group = g2
            });

            db.SubmitChanges();
        }
 /// <summary>
 /// Create a new medicine with current instance
 /// Sets the created_at and updated_at columns also
 /// </summary>
 internal void Create()
 {
     db = App.ViewModel.db;
     db.Medicines.InsertOnSubmit(this.medicine);
     db.SubmitChanges();
 }
 /// <summary>
 /// Creates the Medicines Catalogue DB if it doesn't exist
 /// Adds a sample medicine
 /// </summary>
 private void CreateDB()
 {
     using (var db = new MedicineContext(DbConnection))
     {
         if (!db.DatabaseExists())
         {
             db.CreateDatabase();
             InsertSampleData(db);
             db.SubmitChanges();
             var adapter = db.CreateDatabaseSchemaUpdater();
             adapter.DatabaseSchemaVersion = currentDBVersion;
             adapter.Execute();
         }
     }
 }