public static ISimulationProducerContract Get(string name) { using (TurbineModelContainer container = new TurbineModelContainer()) { Simulation obj = container.Simulations.Single <Simulation>(s => s.Name == name); } AspenSimulationContract sc = new AspenSimulationContract(); sc.name = name; return(sc); }
public static ISimulationProducerContract Create(string name) { string owner = AppUtility.GetAppContext().UserName; using (TurbineModelContainer container = new TurbineModelContainer()) { User user = container.Users.Single <User>(s => s.Name == owner); Simulation obj = container.Simulations.SingleOrDefault <Simulation>(s => s.Name == name); if (obj != null) { throw new InvalidStateChangeException("Simulation with Name {0} already exists"); } container.Simulations.AddObject(new Simulation() { Name = name, User = user }); container.SaveChanges(); } AspenSimulationContract sc = new AspenSimulationContract(); sc.name = name; return(sc); }