initial commit
[CPE_learningsite] / CPE / CPE.App / CPE.App.Notify / Models / CPEDataContext.cs
1 /*
2 Developer: Tyler Allen
3 Date Created: 08/24/2016
4 ---------------------------------------------------
5 */
6
7 using System.Configuration;
8
9 namespace CPE.App.Notify.Models {
10     // ReSharper disable once InconsistentNaming
11     public partial class CPEWebDataContext {
12         private static CPEWebDataContext _context;
13
14         public static CPEWebDataContext Context() {
15             return GetContext();
16         }
17
18         public static CPEWebDataContext GetContext() {
19             var connectionString = ConfigurationManager.ConnectionStrings["CPE.Data"].ConnectionString;
20             return GetContext(connectionString);
21         }
22
23         /// <summary>
24         ///     Returns the DataContext shared for the current request (or creates one if necessary)
25         /// </summary>
26         /// <param name="connectionString">The connection string to use.</param>
27         public static CPEWebDataContext GetContext(string connectionString) {
28             if(_context == null) {
29                 _context = new CPEWebDataContext(connectionString);
30             }
31             return _context;
32         }
33     }
34 }