public Client FindClient(int id) { using (var db = new DataContext()) { return db.Client.Find(id); } }
public int GetPolicyCount() { using (var db = new DataContext()) { return db.Policy.Count(); } }
public bool SaveClient(Client client) { using (var db = new DataContext()) { db.Client.Add(client); return db.SaveChanges() > 0; } }
public Policy[] FindClientPolicies(int clientId) { using (var db = new DataContext()) { var client = db.Client.Include("Policy").FirstOrDefault(c => c.id == clientId); return client != null ? client.Policy.ToArray() : new Policy[0]; } }
public bool SavePolicy(Policy policy) { using (var db = new DataContext()) { db.InsuredObject.Add(policy.InsuredObject); db.Policy.Add(policy); return db.SaveChanges() > 0; } }
public static void RegisterMembership() { Database.SetInitializer<DataContext>(null); try { using (var context = new DataContext()) { if (!context.Database.Exists()) { ((IObjectContextAdapter)context).ObjectContext.CreateDatabase(); } } WebSecurity.InitializeDatabaseConnection("DefaultConnection", "mw_Users", "Id", "Email", true); } catch (Exception e) { throw new InvalidOperationException("The ASP.NET Simple Membership database could not be initialized. For more information, please see http://go.microsoft.com/fwlink/?LinkId=256588", e); } }
public AppUserSecretStore(DataContext db) { dataContext = db; store = new UserSecretStore<UserSecret>(db); }
public AppIdentityStoreContext(DataContext dataContext) : base(dataContext) { Secrets = new AppUserSecretStore(dataContext); }