private AbstractRobotServer <AbstractRobot> RobotServerModelPodleDodavatele(long SupplierId) { AbstractRobotServer <AbstractRobot> vysledek = null; switch (SupplierId) { case 1: vysledek = new OmronRobotServer(); break; default: throw new ArgumentException(nameof(SupplierId)); } return(vysledek); }
public RobotServerKolekce ServeryZDatabaze(bool IsActive = true) { List <AbstractRobotServer <AbstractRobot> > vysledneServery = new List <AbstractRobotServer <AbstractRobot> >(); using (AlitaDatabase db = VytvorInstanci()) { SetOnline(db); var obsah = db.RobotServer.Include(x => x.Device).Where(x => x.Device.IsActive == IsActive); List <RobotServer> servers = obsah.ToList(); servers.ForEach(delegate(RobotServer server) { Device zarizeni = server.Device; long supplierId = zarizeni.Supplier_FK ?? 0; AbstractRobotServer <AbstractRobot> robotServer = RobotServerModelPodleDodavatele(supplierId); AbstractZarizeni.DeviceToZarizeni(robotServer, zarizeni); vysledneServery.Add(robotServer); }); SetOffline(db); } return(new RobotServerKolekce(vysledneServery)); }