Ejemplo n.º 1
0
 /// <summary>
 /// Creates a new connection record
 /// </summary>
 /// <param name="Connection"></param>
 /// <returns></returns>
 public static Connection CreateConnection(Connection Connection)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         db.Connections.Add(Connection);
         db.Entry(Connection).State = System.Data.Entity.EntityState.Added;
         db.SaveChanges();
         return Connection;
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new solution record and returns the updated object
 /// </summary>
 /// <param name="solution"></param>
 /// <returns></returns>
 public static Solution CreateSolution(Solution solution)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         db.Solutions.Add(solution);
         db.Entry(solution).State = System.Data.Entity.EntityState.Added;
         db.SaveChanges();
         return solution;
     }
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Saves the settings
 /// </summary>
 /// <param name="settings"></param>
 public static void SaveSettings(Settings settings)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         db.Settings.Add(settings);
         db.Entry(settings).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Updates a solution record
 /// </summary>
 /// <param name="solution"></param>
 /// <returns></returns>
 public static void UpdateSolution(Solution solution)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         db.Solutions.Add(solution);
         db.Entry(solution).State = System.Data.Entity.EntityState.Modified;
         db.SaveChanges();
     }
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Gets a solution by ID
 /// </summary>
 /// <param name="SolutionId"></param>
 /// <returns></returns>
 public static Solution GetSolution(int SolutionId)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         Solution solution = db.Solutions.Find(SolutionId);
         solution.DatabaseConnection = db.Connections.Find(solution.DatabaseConnectionId);
         return solution;
     }
 }
Ejemplo n.º 6
0
 /// <summary>
 /// Gets a connection by id
 /// </summary>
 /// <param name="ConnectionId"></param>
 /// <returns></returns>
 public static Connection GetConnection(int ConnectionId)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         return db.Connections.Find(ConnectionId);
     }
 }
Ejemplo n.º 7
0
 /// <summary>
 /// Gets a connection by name
 /// </summary>
 /// <param name="ConnectionName"></param>
 /// <returns></returns>
 public static Connection GetConnection(string ConnectionName)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         return db.Connections.Where(c => c.ConnectionName == ConnectionName).FirstOrDefault();
     }
 }
Ejemplo n.º 8
0
        /// <summary>
        /// Deletes a solution
        /// </summary>
        /// <param name="solution"></param>
        public static void DeleteSolution(Solution solution)
        {
            using (DatabaseContext db = new DatabaseContext())
            {
                db.Entry(solution).State = System.Data.Entity.EntityState.Deleted;
                db.Solutions.Remove(solution);
                db.SaveChanges();

            }
        }
Ejemplo n.º 9
0
 /// <summary>
 /// Deletes a connection
 /// </summary>
 /// <param name="Connection"></param>
 public static void DeleteConnection(Connection Connection)
 {
     using (DatabaseContext db = new DatabaseContext())
     {
         db.Entry(Connection).State = System.Data.Entity.EntityState.Deleted;
         db.SaveChanges();
     }
 }