// GET: Subjets/Edit/5 public ActionResult Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Subjet subjet = db.Subjets.Find(id); if (subjet == null) { return(HttpNotFound()); } //Busco solo los profesores activos. var result = from profes in db.Professors where profes.activity == true select profes; //Paso la lista al DrowDownList. ViewBag.id_profesor = new SelectList(result.ToList(), "id", "name", subjet.id_profesor); ViewBag.id_day = new SelectList(db.Days, "id", "day_name", subjet.id_day); return(View(subjet)); }
public ActionResult Edit([Bind(Include = "id,name,description,start_time,end_time,id_profesor,vacancies,id_day")] Subjet subjet) { if (ModelState.IsValid) { db.Entry(subjet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.id_profesor = new SelectList(db.Professors, "id", "name", subjet.id_profesor); ViewBag.id_day = new SelectList(db.Days, "id", "day_name", subjet.id_day); return(View(subjet)); }
// GET: Subjets/Details/5 public ActionResult Details(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Subjet subjet = db.Subjets.Find(id); if (subjet == null) { return(HttpNotFound()); } return(View(subjet)); }
public ActionResult DeleteConfirmed(int id) { Subjet subjet = db.Subjets.Find(id); //Busco las incripciones a la materia. var incripciones = from incr in db.Student_subjet where incr.id_subjet == subjet.id select incr; //elimino las incripciones. db.Student_subjet.RemoveRange(incripciones); //elimino la materia. db.Subjets.Remove(subjet); db.SaveChanges(); return(RedirectToAction("Index")); }
public bool ConflictorHorarioMateria(Subjet materiaAInscribirce) { List <Subjet> incripciones; bool conflictoHorario = false; using (var db = new RegistryEntities()) { int id_student = GetStudentId(); //get id estudiante var student_subjet = db.Student_subjet.Where(d => d.id_student == id_student).ToList(); //get lista materias anotadas. var subjets = db.Subjets.Include(s => s.Professor).Include(s => s.Day).ToList(); //get lista materias. var result = from a in subjets //Consulta. where student_subjet.Select(b => b.id_subjet).Contains(a.id) select a; incripciones = result.ToList(); //Materias incriptas del alumno. Debug.WriteLine(incripciones.Count()); } var materiasMismoDia = incripciones.FindAll(incr => incr.Day.id.Equals(materiaAInscribirce.Day.id)); if (materiasMismoDia.Count() > 0) { int i = 0; while (i < materiasMismoDia.Count() && !conflictoHorario) { if (materiaAInscribirce.start_time.Hour >= materiasMismoDia[i].start_time.Hour && materiaAInscribirce.start_time.Hour < materiasMismoDia[i].end_time.Hour) { conflictoHorario = true; } else if (materiaAInscribirce.end_time.Hour > materiasMismoDia[i].start_time.Hour && materiaAInscribirce.end_time.Hour < materiasMismoDia[i].end_time.Hour) { conflictoHorario = true; } i++; } } return(conflictoHorario); }