protected void btn_savenewcourse_Click(object sender, EventArgs e) { var course = new EntityFrameworkProject.Courses(); if (ddl_teachers.SelectedValue != "-1" && ddl_education.SelectedValue != "-1") { course.CourseName = txtbox_newcourse.Text; course.Education_Id = int.Parse(ddl_education.SelectedValue); course.Grade = "IG - MVG"; course.Staff_Id = int.Parse(ddl_teachers.SelectedValue); cc.InsertorUpdateCourse(course); Response.Redirect($"Course"); } }
public Courses CourseByID(int id) { Courses course = ctx.Courses.Where(x => x.Id == id).FirstOrDefault(); return(course); }
public void RemoveCourse(Courses course) { ctx.Courses.Attach(course); ctx.Courses.Remove(course); ctx.SaveChanges(); }
public void UpdateCourse(Courses course) { ctx.Entry(course).State = EntityState.Modified; ctx.SaveChanges(); }
public void InsertorUpdateCourse(Courses course) { ctx.Courses.Add(course); ctx.SaveChanges(); }