public ActionResult AddToDosToList(AddToDosToListViewModel model) { try { using (SqlConnection sqlConnection = new SqlConnection("Data Source=5SSDHH2;Initial Catalog=JMProjectDB;Integrated Security=True;MultipleActiveResultSets=True;Application Name=EntityFramework")) { using (SqlCommand command = new SqlCommand("AddToDoToList", sqlConnection)) { command.Parameters.Add("@ToDoID", SqlDbType.Int); command.Parameters.Add("@ListID", SqlDbType.Int); command.Parameters["@ToDoID"].Value = Int32.Parse(model.selectedToDoID); command.Parameters["@ListID"].Value = model.CurrentListID; sqlConnection.Open(); command.CommandType = CommandType.StoredProcedure; command.ExecuteNonQuery(); } } return(RedirectToAction("Index")); } catch (SqlException ex) { string msg = "Insert Error:"; msg += ex.Message; throw new Exception(msg); } return(RedirectToAction("AddTasksToList")); }
public ActionResult AddToDosToList(int id) { ToDoList currentToDoList = listOfToDoLists.Single(t => t.ID == id); AddToDosToListViewModel addTodosToListViewModel = new AddToDosToListViewModel(currentToDoList, listOfToDos); return(View(addTodosToListViewModel)); }