public Hoofdstuk getSingleHoofdstuk(int hfdstkID, int VerhaalID) { Hoofdstuk H = new Hoofdstuk(); using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); string query = "select ID, Titel, Body, Nummer from Hoofdstuk where VerhaalID = @VerhaalID and ID = @HfdstkID"; using (SqlCommand cmd = new SqlCommand(query, conn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@VerhaalID", VerhaalID); cmd.Parameters.AddWithValue("@hfdstkID", hfdstkID); cmd.ExecuteNonQuery(); using (SqlDataReader reader = cmd.ExecuteReader()) { while (reader.Read()) { string Titel = (string)reader["Titel"]; string Body = (string)reader["Body"]; int Nummer = (int)reader["Nummer"]; int HfdstkID = (int)reader["ID"]; H = new Hoofdstuk(Titel, Body, Nummer, VerhaalID, HfdstkID); } } } } return(H); }
public ActionResult SubmitChapter(HoofdstukViewModel H) { string Titel = H.Titel; string Body = H.Body; int Nummer = Convert.ToInt32(H.nummer); int storyID = Convert.ToInt32(Session["StoryID"]); Hoofdstuk D = new Hoofdstuk(Titel, Body, Nummer, storyID); Repo.AddHoofdstuk(D); return(RedirectToAction("Index", "Verhaal")); }
public void AddHoofdstuk(Hoofdstuk H) { using (SqlConnection conn = new SqlConnection(ConnectionString)) { conn.Open(); string query = "INSERT INTO Hoofdstuk(Titel, Body, Nummer, VerhaalID) values (@Titel, @Body, @Nummer, @VerhaalID)"; using (SqlCommand cmd = new SqlCommand(query, conn)) { cmd.CommandType = CommandType.Text; cmd.Parameters.AddWithValue("@Titel", H.Titel); cmd.Parameters.AddWithValue("@Body", H.Body); cmd.Parameters.AddWithValue("@Nummer", H.Nummer); cmd.Parameters.AddWithValue("@VerhaalID", H.VerhaalID); cmd.ExecuteNonQuery(); } } }
public HoofdstukViewModel ToViewModel(Hoofdstuk H) { return(context.ToViewModel(H)); }
public void AddHoofdstuk(Hoofdstuk H) { this.context.AddHoofdstuk(H); }
public HoofdstukViewModel ToViewModel(Hoofdstuk H) { HoofdstukViewModel F = new HoofdstukViewModel(H.Titel, H.Body, H.Nummer, H.VerhaalID, H.HoofdstukID); return(F); }