Exemplo n.º 1
0
        public static void InitCompanyData(GenesisContext context)
        {
            try
            {
                //hejehj
                var adr   = new Address("Nejlikegatan 3", "70353", "Örebro");
                var comp1 = context.Companies.Find("o1");
                if (comp1 != null)
                {
                    context.Companies.Remove(comp1);

                    context.SaveChanges();
                }
                var comp = new Company("o1", "n1", "*****@*****.**", "p1", adr);
                var dep1 = new Department("Olaigatan", adr, "phone1");
                dep1.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                dep1.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(15));
                dep1.AddExceptionDay(new DateTime(2018, 2, 24));
                dep1.AddExceptionDay(new DateTime(2018, 2, 28));
                comp.Departments.Add(dep1);
                context.Companies.Add(comp);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        }
Exemplo n.º 2
0
        private void BuildContext()
        {
            var companyGuid   = Guid.NewGuid();
            var companyEntity = CompanyEntity.MapFromBusinessObject(new Company()
            {
                Id                   = companyGuid,
                Name                 = "Test company",
                VatNumber            = "BE0123456789",
                EstablishmentAddress = new Address()
                {
                    AddressLine1 = "Company Address Line 1",
                    AddressLine2 = null,
                    PostCode     = "1234",
                    City         = "Company City"
                },
                SubsidiaryAddresses = new List <Address>()
            });

            _context.Companies.Add(companyEntity);
            _context.SaveChanges();
        }
        public async void Analyze()
        {
            currentAnalysis = new FrequencyAnalyzer(AnalysisName, new FrequencyAnalyzer.Settings()
            {
                Traits = Traits.Where(g => g.Selected).Select(g => g.Trait).ToList()
            });

            var context = new GenesisContext();
            var result = await Task.Run(() => currentAnalysis.Analyse(context));
            context.FrequencyAnalysis.Add(result);
            context.SaveChanges();
            ReloadData();
        }
Exemplo n.º 4
0
 public int SaveChanges()
 {
     return(_genesisContext.SaveChanges());
 }
Exemplo n.º 5
0
        public async void Analyze()
        {
            currentAnalysis = new FstAnalyzer(AnalysisName, new FstAnalyzer.Settings()
            {
                Genes = Genes.Where(g => g.Selected).Select(g => g.Gene).ToList(),
                Species = SelectedSpecies
            });

            var context = new GenesisContext();
            var result = await Task.Run(() => currentAnalysis.Analyse(context));
            context.FstAnalysis.Add(result);
            context.SaveChanges();
        }
Exemplo n.º 6
0
        public static void InitCompanyDataOrg(GenesisContext context)
        {
            try
            {
                var adr  = new Address("Nejlikegatan 3", "70353", "Örebro");
                var adr2 = new Address("Nejlikegatan 3", "70353", "Örebro");
                //context.Database.EnsureCreated();

                var comp = new Company("o1", "n1", "*****@*****.**", "p1", adr);
                comp = context.Companies.FirstOrDefault(c => c.OrgNumber == comp.OrgNumber);
                if (comp != null)
                {
                    context.Set <Company>().Remove(comp);
                    //context.SaveChanges();
                }

                comp = new Company("o1", "n1", "*****@*****.**", "p1", adr);

                /*
                 *              var cat1 = new Category(0, 0, "Tårta", "d1");
                 *              var cat2 = new Category(0, 0, "Fikabröd", "d2");
                 *              var cat3 = new Category(0, 0, "SM Tårtor", "d3");
                 *
                 *              var info = new ProductDetailInfo("Storlek", TypeEnum.StringType);
                 *              cat1.ProductDetailInfos.Add(info);
                 *              var pris = new ProductDetailInfo("Pris", TypeEnum.DoubleType);
                 *              cat1.ProductDetailInfos.Add(pris);
                 *              cat2.ProductDetailInfos.Add(pris);
                 *              cat2.ProductDetailInfos.Add(info);
                 *              cat3.ProductDetailInfos.Add(pris);
                 *              cat3.ProductDetailInfos.Add(info);
                 *
                 *              var products1 = new List<Product>() {
                 *              new  Product("Princess", "Grädde, vaniljkräm, hallonsylt, anslag" , "princess.png" ,100, "supplierId"),
                 *              new Product("Prince", "Krämgrädde, chokladpenslad maräng, hallon, anslag", "prince.png", 100, "supplierId"),
                 *              new Product("Gräddtårta", "Grädde, hallongsylt, vaniljkräm, anslag", "graddtarta.png", 100, "supplierId"),
                 *              new Product("Sacher", "Choklad, aprikoskräm, chokladanslag", "sacher.png", 100, "supplierId"),
                 *              new Product("Fruktis", "Sylt, vaniljkräm, grädde, smörkräm", "fruktis.png", 100, "supplierId"),
                 *              new Product("Blåbär", "Blåbärsgrädde, vaniljkräm, blåbärssylt, anslag", "blueberry.png", 100, "supplierId"),
                 *              new Product("Spegel", "Chokladmousse, vaniljkräm, chokladglasyr, anslag", "spegel.png", 100, "supplierId"),
                 *              new Product("William", "Pärongrädde, vaniljkräm, päronbitar, anslag", "william.png", 100, "supplierId"),
                 *              new Product("Willma", "Hallongrädde, vaniljkräm, hela hallon, anslag", "willma.png", 100, "supplierId"),
                 *              };
                 *
                 *               var products2 = new List<Product>() {
                 *              new Product("Kanelbullar", "Vetedeg, kanel", "Kanelbulle.jpg", 100, "supplierId"),
                 *              new Product("Kardemummabullar", "Vetedeg, kardemumma, mandelmassa", "Kanelbulle.jpg", 100, "supplierId"),
                 *              new  Product("Blåbärsbulle", "Vetedeg, blåbärssylt, vaniljkräm", "blabarsbulle.png", 100, "supplierId"),
                 *              new Product("Winerbröd hallon", "Spandau med hallonsylt", "spandaujam.jpg", 100, "supplierId"),
                 *              new  Product("Wienerbröd choklad", "Spandau med choklad", "spandau.jpg", 100, "supplierId"),
                 *              new  Product("Desireebulle", "Vetebulle fylld med vaniljgrädde", "Desireebulle.jpg", 100, "supplierId"),
                 *              new  Product("Krämbulle", "Vetedeg med vanilkräm", "krambulle.jpg", 100, "supplierId")
                 *              };
                 *              var products3 = new List<Product>() {
                 *              new Product("SM tårta skagen", "Smörgåsårta med handskalde räkor, grönsaker & skagenröra", "smtarta.jpg", 100, "supplierId"),
                 *              new Product("SM tårta Skinka", "Smörgåstårta med rökt skinka, skinkröra & grönsaker", "smtarta.jpg", 100, "supplierId"),
                 *              new Product("SM tårta Kyckling curry", "Curry, kyckling & grönsaker", "smtarta.jpg", 100, "supplierId")
                 *              };
                 *              var groupKey = products1.FirstOrDefault().ProductDetails.Select(s => s.GroupKey).FirstOrDefault();
                 *              ProductDetail pd = new ProductDetail(groupKey, "Storlek", "10 personer");
                 *              products1.FirstOrDefault().ProductDetails.Add(pd);
                 *              ProductDetail pd2 = new ProductDetail(groupKey, "Pris", "249");
                 *              products1.FirstOrDefault().ProductDetails.Add(pd2);
                 *              cat1.Products.AddRange(products1);
                 *              cat2.Products.AddRange(products2);
                 *              cat3.Products.AddRange(products3);
                 *              comp.Categories.AddRange(new List<Category>() { cat1, cat2, cat3 });
                 *              var adr1 = new Address("s1", "p1", "c1");
                 *              var dep1 = new Department("Olaigatan", adr1, "phone1");
                 *              dep1.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                 *              dep1.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                 *              dep1.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                 *              dep1.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                 *              dep1.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(15));
                 *              dep1.AddExceptionDay(new DateTime(2018, 2, 24));
                 *              dep1.AddExceptionDay(new DateTime(2018, 2, 28));
                 *              comp.Departments.Add(dep1);
                 *              var dep2 = new Department("Stallbacken", adr2, "phone2");
                 *              dep2.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(19));
                 *              dep2.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(19));
                 *              dep2.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(19));
                 *              dep2.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(19));
                 *              dep2.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(18));
                 *              dep2.AddExceptionDay(new DateTime(2018, 2, 24));
                 *              dep2.AddExceptionDay(new DateTime(2018, 2, 26));
                 *              comp.Departments.Add(dep2);
                 *              var NewOrder = new Order("customerID1", "o1", new DateTime(2018, 3, 18), adr1, new DateTime(2018, 3, 25));
                 *              var newOrderDetail = new OrderDetail(groupKey, "Äppelpaj", "bästa äppelpajen", 19.90, "Gabriel kommentar", 4);
                 *              NewOrder.AddDetail(newOrderDetail);
                 *              comp.Orders.Add(NewOrder);
                 */
                //context.Companies.Add(comp);
                var comp2 = new Company("o2", "n1", "*****@*****.**", "p1", adr);
                //comp2.Inactive = true;
                context.Companies.Add(comp2);
                context.SaveChanges();
            }
            catch (Exception exp)
            {
                var xx = exp.Message;
            }
        }
Exemplo n.º 7
0
        public static void Init(GenesisContext context)
        {
            try
            {
                var adrHalls = new Address("Engelbrektsgatan 12", "702 12", "Örebro");
                var adrOlai  = new Address("Olaigatan 17a", "703 61", "Örebro");

                var comp1 = context.Companies.Find("5567569008");
                if (comp1 != null)
                {
                    context.Companies.Remove(comp1);

                    context.SaveChanges();
                }
                var comp = new Company("5567569008", "Konditorn i Örebro AB", "*****@*****.**", "0196110766", adrHalls);
                var Olai = new Department("Olaigatan", adrOlai, "0196110766");
                Olai.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Olai.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Olai.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Olai.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                Olai.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(16));
                Olai.AddExceptionDay(new DateTime(2018, 2, 24));
                Olai.AddExceptionDay(new DateTime(2018, 2, 28));
                comp.Departments.Add(Olai);
                var Stallis = new Department("Stallbacken", adrHalls, "0196110766");
                Stallis.AddOpenHoursOfDay(DayOfWeek.Monday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Stallis.AddOpenHoursOfDay(DayOfWeek.Tuesday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Stallis.AddOpenHoursOfDay(DayOfWeek.Wednesday, TimeSpan.FromHours(8), TimeSpan.FromHours(18));
                Stallis.AddOpenHoursOfDay(DayOfWeek.Friday, TimeSpan.FromHours(8), TimeSpan.FromHours(16));
                Stallis.AddOpenHoursOfDay(DayOfWeek.Saturday, TimeSpan.FromHours(10), TimeSpan.FromHours(16));
                Stallis.AddExceptionDay(new DateTime(2018, 2, 24));
                Stallis.AddExceptionDay(new DateTime(2018, 2, 28));
                comp.Departments.Add(Stallis);



                var catCake   = new Category(Guid.Empty, 0, "Tårta", "d1");
                var catFika   = new Category(Guid.Empty, 0, "Fikabröd", "d2");
                var catSmCake = new Category(Guid.Empty, 0, "SM Tårtor", "d3");

                var info = new ProductDetailInfo("Storlek", TypeEnum.StringType);
                catCake.ProductDetailInfos.Add(info);
                var pris = new ProductDetailInfo("Pris", TypeEnum.DoubleType);
                catCake.ProductDetailInfos.Add(pris);
                catFika.ProductDetailInfos.Add(pris);
                catFika.ProductDetailInfos.Add(info);
                catSmCake.ProductDetailInfos.Add(pris);
                catSmCake.ProductDetailInfos.Add(info);

                var prodCake = new List <Product>()
                {
                    new  Product("Princess", "Grädde, vaniljkräm, hallonsylt, anslag", "princess.png", 100, "supplierId"),
                    new Product("Prince", "Krämgrädde, chokladpenslad maräng, hallon, anslag", "prince.png", 100, "supplierId"),
                    new Product("Gräddtårta", "Grädde, hallongsylt, vaniljkräm, anslag", "graddtarta.png", 100, "supplierId"),
                    new Product("Sacher", "Choklad, aprikoskräm, chokladanslag", "sacher.png", 100, "supplierId"),
                    new Product("Fruktis", "Sylt, vaniljkräm, grädde, smörkräm", "fruktis.png", 100, "supplierId"),
                    new Product("Blåbär", "Blåbärsgrädde, vaniljkräm, blåbärssylt, anslag", "blueberry.png", 100, "supplierId"),
                    new Product("Spegel", "Chokladmousse, vaniljkräm, chokladglasyr, anslag", "spegel.png", 100, "supplierId"),
                    new Product("William", "Pärongrädde, vaniljkräm, päronbitar, anslag", "william.png", 100, "supplierId"),
                    new Product("Willma", "Hallongrädde, vaniljkräm, hela hallon, anslag", "willma.png", 100, "supplierId"),
                };

                var prodFika = new List <Product>()
                {
                    new Product("Kanelbullar", "Vetedeg, kanel", "Kanelbulle.jpg", 100, "supplierId"),
                    new Product("Kardemummabullar", "Vetedeg, kardemumma, mandelmassa", "Kanelbulle.jpg", 100, "supplierId"),
                    new  Product("Blåbärsbulle", "Vetedeg, blåbärssylt, vaniljkräm", "blabarsbulle.png", 100, "supplierId"),
                    new Product("Winerbröd hallon", "Spandau med hallonsylt", "spandaujam.jpg", 100, "supplierId"),
                    new  Product("Wienerbröd choklad", "Spandau med choklad", "spandau.jpg", 100, "supplierId"),
                    new  Product("Desireebulle", "Vetebulle fylld med vaniljgrädde", "Desireebulle.jpg", 100, "supplierId"),
                    new  Product("Krämbulle", "Vetedeg med vanilkräm", "krambulle.jpg", 100, "supplierId")
                };
                var prodSmCake = new List <Product>()
                {
                    new Product("SM tårta skagen", "Smörgåsårta med handskalde räkor, grönsaker & skagenröra", "smtarta.jpg", 100, "supplierId"),
                    new Product("SM tårta Skinka", "Smörgåstårta med rökt skinka, skinkröra & grönsaker", "smtarta.jpg", 100, "supplierId"),
                    new Product("SM tårta Kyckling curry", "Curry, kyckling & grönsaker", "smtarta.jpg", 100, "supplierId")
                };

                //var groupKey = prodCake.FirstOrDefault().ProductDetails.Select(s => s.GroupKey).FirstOrDefault();

                int x = 0;



                foreach (var item in prodCake)
                {
                    x++;
                    ProductDetail pdS6 = new ProductDetail(x, "Storlek", "6 personer");
                    ProductDetail pdP6 = new ProductDetail(x, "Pris", "170");
                    x++;
                    ProductDetail pdS8 = new ProductDetail(x, "Storlek", "8 personer");
                    ProductDetail pdP8 = new ProductDetail(x, "Pris", "220");
                    x++;
                    ProductDetail pdS10 = new ProductDetail(x, "Storlek", "10 personer");
                    ProductDetail pdP10 = new ProductDetail(x, "Pris", "260");
                    x++;
                    ProductDetail pdS15 = new ProductDetail(x, "Storlek", "15 personer");
                    ProductDetail pdP15 = new ProductDetail(x, "Pris", "310");
                    x++;
                    ProductDetail pdS20 = new ProductDetail(x, "Storlek", "20 personer");
                    ProductDetail pdP20 = new ProductDetail(x, "Pris", "360");
                    item.ProductDetails.Add(pdS6);
                    item.ProductDetails.Add(pdP6);
                    item.ProductDetails.Add(pdS8);
                    item.ProductDetails.Add(pdP8);
                    item.ProductDetails.Add(pdS10);
                    item.ProductDetails.Add(pdP10);
                    item.ProductDetails.Add(pdS15);
                    item.ProductDetails.Add(pdP15);
                    item.ProductDetails.Add(pdS20);
                    item.ProductDetails.Add(pdP20);
                }

                foreach (var item in prodSmCake)
                {
                    x++;
                    ProductDetail pdS6       = new ProductDetail(x, "Storlek", "6 personer");
                    ProductDetail pdP6SmCake = new ProductDetail(x, "Pris", "310");
                    x++;
                    ProductDetail pdS8       = new ProductDetail(x, "Storlek", "10-12 personer");
                    ProductDetail pdP8SmCake = new ProductDetail(x, "Pris", "410");
                    x++;
                    ProductDetail pdS10_12       = new ProductDetail(x, "Storlek", "14-16 personer");
                    ProductDetail pdP10_12SmCake = new ProductDetail(x, "Pris", "510");
                    x++;
                    ProductDetail pdS14_16       = new ProductDetail(x, "Storlek", "18-20 personer");
                    ProductDetail pdP14_16SmCake = new ProductDetail(x, "Pris", "610");
                    x++;
                    ProductDetail pdS18_20       = new ProductDetail(x, "Storlek", "8 personer");
                    ProductDetail pdP18_20SmCake = new ProductDetail(x, "Pris", "360");

                    item.ProductDetails.Add(pdS6);
                    item.ProductDetails.Add(pdP6SmCake);
                    item.ProductDetails.Add(pdS8);
                    item.ProductDetails.Add(pdP8SmCake);
                    item.ProductDetails.Add(pdS10_12);
                    item.ProductDetails.Add(pdP10_12SmCake);
                    item.ProductDetails.Add(pdS14_16);
                    item.ProductDetails.Add(pdP14_16SmCake);
                    item.ProductDetails.Add(pdS18_20);
                    item.ProductDetails.Add(pdP18_20SmCake);
                }

                foreach (var item in prodFika)
                {
                    x++;
                    ProductDetail pdS5Pack = new ProductDetail(x, "Storlek", "5 st");
                    ProductDetail pdP5Pack = new ProductDetail(x, "Pris", "75");
                    x++;
                    ProductDetail pdS10Pack = new ProductDetail(x, "Storlek", "10 st");
                    ProductDetail pdP10Pack = new ProductDetail(x, "Pris", "125");
                    item.ProductDetails.Add(pdS5Pack);
                    item.ProductDetails.Add(pdP5Pack);
                    item.ProductDetails.Add(pdS10Pack);
                    item.ProductDetails.Add(pdP10Pack);
                }

                catCake.Products.AddRange(prodCake);
                catFika.Products.AddRange(prodFika);
                catSmCake.Products.AddRange(prodSmCake);
                comp.Categories.AddRange(new List <Category>()
                {
                    catCake, catFika, catSmCake
                });
                context.Companies.Add(comp);
                context.SaveChanges();
            }
            catch (Exception ex)
            {
            }
        } //initHalls