/// <summary>
 /// Sets the DB Context
 /// Loads all groups if asked for
 /// </summary>
 /// <param name="loadAllGroups">Flag to indicate whether to load groups</param>
 public GroupViewModel()
 {
     db = App.ViewModel.db;
     Group = new Group();
     LoadAllGroups();
 }
        /// <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();
        }