public Enrollment StudentEnrollment( string indexNumber, string firstName, string lastName, DateTime birthDate, string name) { var st = GetStudyName(name); var enrollment = GetEnrollment(st.IdStudy, 1); if (enrollment == null) { enrollment = new Enrollment { IdEnrollment = _dbcont.Enrollments.Max(e => e.IdEnrollment) + 1, IdStudy = st.IdStudy, Semester = 1, StartDate = DateTime.Now }; _dbcont.Attach(enrollment); _dbcont.Add(enrollment); } return(enrollment); }
public ActionResult DeleteStudentEF(string id) { var db = new s16061Context(); var res = new Students { IndexNumber = id }; db.Attach(res); db.Remove(res); db.SaveChangesAsync(); return(Ok("Usunieto")); }