public RedirectToRouteResult CreateSchoolDatabase(int id) { var schools = UsersContext.Schools; var school = UsersContext.Schools.First(schoolId => schoolId.SchoolId == id); using (var schoolDb = new JournalContext(ConnectionHelper.GetSchoolConnection(school.SchoolId))) { if (!schoolDb.DatabaseExists()) schoolDb.CreateDatabase(); schoolDb.SubmitChanges(); } return RedirectToAction("Index", "Settings"); }
private bool ExistSchoolDatabase(int schoolId) { var school = UsersContext.Schools.First(s => s.SchoolId == schoolId); using (var journalContext = new JournalContext(ConnectionHelper.GetSchoolConnection(school.SchoolId))) { return journalContext.DatabaseExists(); } }