public ActionResult addSection(tbl_SectionValidation sv) { try { Section s = new Section(); s.SchoolId = Convert.ToInt32(Session["school"]); s.SectionName = sv.SectionName; db.Sections.Add(s); db.SaveChanges(); ModelState.Clear(); ViewBag.Message = "Data Submitted"; } catch (Exception ex) { ViewBag.Message = "Not Submitted"; return(View()); } return(View()); }
public List <tbl_SectionValidation> GetSection(int schoolid) { List <tbl_SectionValidation> SectionInformation = new List <tbl_SectionValidation>(); SqlCommand sc = new SqlCommand("[Digital_School].get_SchoolSection", Connections.GetConnection()); sc.CommandType = CommandType.StoredProcedure; sc.Parameters.AddWithValue("@SchoolId", schoolid); SqlDataReader sdr = sc.ExecuteReader(); while (sdr.Read()) { tbl_SectionValidation gc = new tbl_SectionValidation(); //gc.CourseId = Convert.ToInt32(sdr["courseId"]); gc.SectionName = sdr["SectionName"].ToString(); gc.SectionID = Convert.ToInt32(sdr["SectionID"]); SectionInformation.Add(gc); } sdr.Close(); return(SectionInformation); }