public void SaveLack(Lacks lack) { try { db.Lacks.Add(lack); db.SaveChanges(); } catch (Exception) { throw; } }
public ActionResult Edit([Bind(Include = "IdLack,Date,IdCourse,IdStudent,IdSubject,IdTeacher,IdJustification")] Lacks lacks) { if (ModelState.IsValid) { //db.Entry(lacks).State = EntityState.Modified; //db.SaveChanges(); //return RedirectToAction("Index"); } ViewBag.IdTeacher = new SelectList(validationUser.GetAllTeachers(), "Id", "Email", lacks.IdTeacher); ViewBag.IdCourse = new SelectList(validationsCourse.GetAllCourses(), "IdCourse", "Description", lacks.IdCourse); ViewBag.IdStudent = new SelectList(validationStudents.GetAllStudents(), "IdStudent", "Names", lacks.IdStudent); ViewBag.IdSubject = new SelectList(validationsSubject.GetAllSubjects(), "IdSubjects", "name", lacks.IdSubject); return(View(lacks)); }
// GET: Lacks/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Lacks lacks = validationsLacks.FindById(id); if (lacks == null) { return(HttpNotFound()); } ViewBag.IdTeacher = new SelectList(validationUser.GetAllTeachers(), "Id", "Email", lacks.IdTeacher); ViewBag.IdCourse = new SelectList(validationsCourse.GetAllCourses(), "IdCourse", "Description", lacks.IdCourse); ViewBag.IdStudent = new SelectList(validationStudents.GetAllStudents(), "IdStudent", "Names", lacks.IdStudent); ViewBag.IdSubject = new SelectList(validationsSubject.GetAllSubjects(), "IdSubjects", "name", lacks.IdSubject); return(PartialView(lacks)); }
public bool SaveLacks(List <Students> fails, int idCourse, int idSubject, DateTime today, string user) { try { foreach (Students student in fails) { Lacks lack = new Lacks { IdCourse = idCourse, IdTeacher = user, IdSubject = idSubject, Date = today, IdStudent = student.IdStudent }; SaveLack(lack); } return(true); } catch (Exception) { return(false); } }