Esempio n. 1
0
 public MeasurementsController()
 {
     db          = new ApplicationDbContext();
     userStore   = new UserStore <ApplicationUser>(db);
     userManager = new ApplicationUserManager(userStore);
     weightMeasurementService   = new WeightMeasurementService(db);
     heightMeasurementService   = new HeightMeasurementService(db);
     upperArmMeasurementService = new UpperArmMeasurementService(db);
     foreArmMeasurementService  = new ForeArmMeasurementService(db);
     neckMeasurementService     = new NeckMeasurementService(db);
     chestMeasurementService    = new ChestMeasurementService(db);
     waistMeasurementService    = new WaistMeasurementService(db);
     hipsMeasurementService     = new HipsMeasurementService(db);
     thighMeasurementService    = new ThighMeasurementService(db);
     calfMeasurementService     = new CalfMeasurementService(db);
 }
Esempio n. 2
0
        private void SeedMeasurements(ApplicationDbContext context)
        {
            var userStore   = new UserStore <ApplicationUser>(context);
            var userManager = new ApplicationUserManager(userStore);
            var weightMeasurementService   = new WeightMeasurementService(context);
            var heightMeasurementService   = new HeightMeasurementService(context);
            var upperArmMeasurementService = new UpperArmMeasurementService(context);
            var foreArmMeasurementService  = new ForeArmMeasurementService(context);
            var neckMeasurementService     = new NeckMeasurementService(context);
            var chestMeasurementService    = new ChestMeasurementService(context);
            var waistMeasurementService    = new WaistMeasurementService(context);
            var hipsMeasurementService     = new HipsMeasurementService(context);
            var thighMeasurementService    = new ThighMeasurementService(context);
            var calfMeasurementService     = new CalfMeasurementService(context);

            // adding Measurements
            var weightMeasurements   = new List <WeightMeasurement>(InitialData.WeightMeasurement);
            var heightMeasurements   = new List <HeightMeasurement>(InitialData.HeightMeasurement);
            var upperArmMeasurements = new List <UpperArmMeasurement>(InitialData.UpperArmMeasurement);
            var foreArmMeasurements  = new List <ForeArmMeasurement>(InitialData.ForeArmMeasurement);
            var neckMeasurements     = new List <NeckMeasurement>(InitialData.NeckMeasurement);
            var chestMeasurements    = new List <ChestMeasurement>(InitialData.ChestMeasurement);
            var waistMeasurements    = new List <WaistMeasurement>(InitialData.WaistMeasurement);
            var hipsMeasurements     = new List <HipsMeasurement>(InitialData.HipsMeasurement);
            var thighMeasurements    = new List <ThighMeasurement>(InitialData.ThighMeasurement);
            var calfMeasurements     = new List <CalfMeasurement>(InitialData.CalfMeasurement);
            var applicationUsers     = new List <ApplicationUser>(userManager.Users);

            foreach (var u in applicationUsers)
            {
                foreach (var m in weightMeasurements)
                {
                    m.ApplicationUser = u;              // bind to user
                    weightMeasurementService.Create(m); // add to database
                }
                foreach (var m in heightMeasurements)
                {
                    m.ApplicationUser = u;
                    heightMeasurementService.Create(m);
                }
                foreach (var m in upperArmMeasurements)
                {
                    m.ApplicationUser = u;
                    upperArmMeasurementService.Create(m);
                }
                foreach (var m in foreArmMeasurements)
                {
                    m.ApplicationUser = u;
                    foreArmMeasurementService.Create(m);
                }
                foreach (var m in neckMeasurements)
                {
                    m.ApplicationUser = u;
                    neckMeasurementService.Create(m);
                }
                foreach (var m in chestMeasurements)
                {
                    m.ApplicationUser = u;
                    chestMeasurementService.Create(m);
                }
                foreach (var m in waistMeasurements)
                {
                    m.ApplicationUser = u;
                    waistMeasurementService.Create(m);
                }
                foreach (var m in hipsMeasurements)
                {
                    m.ApplicationUser = u;
                    hipsMeasurementService.Create(m);
                }
                foreach (var m in thighMeasurements)
                {
                    m.ApplicationUser = u;
                    thighMeasurementService.Create(m);
                }
                foreach (var m in calfMeasurements)
                {
                    m.ApplicationUser = u;
                    calfMeasurementService.Create(m);
                }
            }
        }