public string Create(Network network) { var networkIdentity = Identity.Next(); var networkKey = PartionKeyRowKeyPair.CreateFromIdentity(networkIdentity); var networkRepository = new NetworkRepository(_tableEntityOperation); var networkTableEntity = new NetworkTableEntity( networkKey, network.Name, network.ParentNetwork != null ? network.ParentNetwork.Id : null, network.Service.Id, network.Company.Id, network.NetworkKey); networkRepository.Create(networkTableEntity); if (network.ParentNetwork == null) { var serviceKey = PartionKeyRowKeyPair.CreateFromIdentity(network.Service.Id); TransientErrorHandling.Run(() => { var serviceRepository = new ServiceRepository(_tableEntityOperation); var service = serviceRepository.Get(serviceKey); service.Networks.Add(new Small() { Id = networkIdentity, Name = network.Name }); serviceRepository.Update(service); }); } else { TransientErrorHandling.Run(() => { var parentNetworkKey = PartionKeyRowKeyPair.CreateFromIdentity(network.ParentNetwork.Id); var parentNetwork = networkRepository.Get(parentNetworkKey); parentNetwork.Networks.Add(new Small() { Id = networkIdentity, Name = network.Name }); networkRepository.Update(parentNetwork); }); } return(networkIdentity); }
private void Seed() { Networks.Create(new Network() { Tag = "3G", ISO_Code = "ISO-1234" }); Networks.Create(new Network() { Tag = "4G", ISO_Code = "ISO-2345" }); Networks.Create(new Network() { Tag = "5G", ISO_Code = "ISO-3456" }); Telefontarife.Create(new Telefontarif() { Name = "Phone_Basic", AllowedNetworks = new List <Network>() { Networks.Get("3G"), Networks.Get("4G") } }); Telefontarife.Create(new Telefontarif() { Name = "Phone_Deluxe", AllowedNetworks = new List <Network>() { Networks.Get("3G"), Networks.Get("4G"), Networks.Get("5G") } }); Datentarife.Create(new Datentarif() { Name = "Data_Basic", MaxAllowedBandwith = 512000, AllowedNetworks = new List <Network>() { Networks.Get("3G"), Networks.Get("4G"), } }); Datentarife.Create(new Datentarif() { Name = "Data_Deluxe", MaxAllowedBandwith = 1024000, AllowedNetworks = new List <Network>() { Networks.Get("3G"), Networks.Get("4G"), Networks.Get("5G") } }); var kunde = new Kunde() { Vorname = "Hans", Name = "Hermann" }; kunde.Rechnungsadresse = new Rechnungsadresse(kunde) { Straße = "Hanshermannstraße", Hausnummer = "22", ZipCode = 12345 }; kunde.Mobilfunkvertraege = new List <Mobilfunkvertrag>(); kunde.Mobilfunkvertraege.Add(new Mobilfunkvertrag(kunde) { MonatlicherPreis = 25d, Rufnummer = "12345678", Telefontarif = Telefontarife.Get("Phone_Basic"), Datentarif = Datentarife.Get("Data_Basic"), }); kunde.Mobilfunkvertraege.Add(new Mobilfunkvertrag(kunde) { MonatlicherPreis = 45d, Rufnummer = "12345679", Telefontarif = Telefontarife.Get("Phone_Basic"), Datentarif = Datentarife.Get("Data_Deluxe"), }); Kunden.Create(kunde); kunde = new Kunde() { Vorname = "Manuela", Name = "Mustermann", }; kunde.Rechnungsadresse = new Rechnungsadresse(kunde) { Straße = "Musterstraße", Hausnummer = "25", ZipCode = 34567 }; kunde.Lieferadresse = new Lieferadresse(kunde) { Straße = "Lieferstraße", Hausnummer = "33", ZipCode = 12999 }; kunde.Mobilfunkvertraege = new List <Mobilfunkvertrag>(); kunde.Mobilfunkvertraege.Add(new Mobilfunkvertrag(kunde) { MonatlicherPreis = 25d, Rufnummer = "5554443", Telefontarif = Telefontarife.Get("Phone_Deluxe"), Datentarif = Datentarife.Get("Data_Deluxe"), }); Kunden.Create(kunde); }