public async System.Threading.Tasks.Task<ActionResult> AddContact() { ContactCollection coll = new ContactCollection(); using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString)) { await connection.OpenAsync(); var result2 = new SchoolRepository(connection).GetSchools(); coll.allSchools = (IEnumerable<Models.School>)result2.Result.ToArray(); coll.schoolselectlist = new SelectList(result2.Result.ToList(), "school_id", "name", new { @required = "required" }); } return View(coll); }
// GET: AddOfficeVisit public async System.Threading.Tasks.Task<ActionResult> EditContact(int id) { ContactCollection coll = new ContactCollection(); using (var connection = new MySqlConnection(ConfigurationManager.ConnectionStrings[Constants.ConnectionStringName].ConnectionString)) { await connection.OpenAsync(); var result = new ContactRepository(connection).GetContact(id); var result2 = new ContactRepository(connection).GetContacts(); var result3 = new SchoolRepository(connection).GetSortedSchools(result.Result.First().school_id.ToString()); coll.singleContact = (IEnumerable<Models.Contact>)result.Result.ToArray(); coll.allContacts = (IEnumerable<Models.Contact>)result2.Result.ToArray(); coll.schoolselectlist = new SelectList(result3.Result.ToList(), "school_id", "name", new { id = "TxtSchool", @required = "required" }); } return View(coll); }