public void PopulateData(string filePath, ExposureDb db)
        {
            var fileReader = new ExcelFileReader();

            db.Branches.AddOrUpdate(branch => branch.Name, fileReader.ReadDistinctBrnaches(filePath).ToArray());
            db.Brands.AddOrUpdate(brand => brand.Name, fileReader.ReadDistinctBrands(filePath).ToArray());
            db.Disciplines.AddOrUpdate(discipline => discipline.Name,
                                       fileReader.ReadDistinctDisciplines(filePath).ToArray());

            var records = fileReader.ReadExposureRecords(filePath).ToArray();

            foreach (var exposureRecord in records)
            {
                db.ExposureRecords.AddOrUpdate(record => new { record.Brand, record.Month }, exposureRecord);
                db.SaveChanges();
            }
        }
Beispiel #2
0
        public ExposureRecordsController()
        {
            db           = new ExposureDb();
            model        = new ExposurePresenterViewModel();
            model.Brands = db.Brands.Select(brand => brand.Name).ToList();
            model.Brands.Sort(String.Compare);
            model.Disciplines = db.Disciplines.Select(discipline => discipline.Name).ToList();
            model.Disciplines.Sort(String.Compare);

            model.Branches = db.Branches.Select(branch => branch.Name).ToList();
            model.Branches.Sort(String.Compare);

            Palete = new List <Color>()
            {
                Color.Gray,
                Color.LightSalmon,
                Color.LightPink,
                Color.PaleGreen,
                Color.LightSeaGreen,
                Color.IndianRed,
                Color.Yellow
            };
        }