public ActionResult EditarMateria(subjects a)
        {
            try
            {
                using (Models.universityEntities db = new Models.universityEntities())
                {
                    subjects mat = db.subjects.Find(a.id_subject);

                    mat.subject_name = a.subject_name;
                    mat.id_teacher   = a.id_teacher;
                    mat.start_time   = a.start_time;
                    mat.end_time     = a.end_time;
                    mat.students_max = a.students_max;
                    mat.students     = a.students;
                    mat.description  = a.description;

                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("Se ha producido un error - ", ex.Message);
                return(View());
            }
        }
        //[Route("GetAllByStudent")]

        public JsonResult GetAllByStudent(long StudentId)
        {
            try
            {
                var SubjectsData = (from tableSubject in db.tblSubjects
                                    join tableCourseSubjects in db.tblCourse_Subject on tableSubject.Id equals tableCourseSubjects.SubjectId
                                    join tableBatchAdmission in db.tblBatchAdmissions on tableCourseSubjects.CourseId equals tableBatchAdmission.CourseId
                                    join tableTimeTableDetail in db.tblTimeTableDetails on tableSubject.Id equals tableTimeTableDetail.SubjectId
                                    join tabletimetable in db.tblTimeTables on tableTimeTableDetail.TimeTableId equals tabletimetable.Id
                                    join tableEmployee in db.tblEmployees on tableTimeTableDetail.FacultyId equals tableEmployee.Id
                                    where tableBatchAdmission.StudentId == StudentId && tabletimetable.IsActive == true
                                    select new { tableSubject.Id, tableSubject.Name, tableEmployee.FirstName }).ToList().Distinct();

                SubjectObj.subjectsList = new List <subjects>();
                foreach (var item in SubjectsData)
                {
                    var subjectTemp = new subjects();
                    SubjectObj.subjectsList.Add(subjectTemp);

                    subjectTemp.Id           = item.Id;
                    subjectTemp.SubjectName  = item.Name;
                    subjectTemp.EmployeeName = item.FirstName;
                }

                return(Json(SubjectObj, JsonRequestBehavior.AllowGet));
            }
            catch (Exception e)
            {
                return(Json(e.ToString(), JsonRequestBehavior.AllowGet));
            }
        }
 public ActionResult InscripcionMateria(int id)
 {
     try
     {
         using (Models.universityEntities db = new Models.universityEntities())
         {
             subjects mat = db.subjects.Find(id);
             if (mat.students < mat.students_max)
             {
                 mat.students++;
                 db.SaveChanges();
                 return(RedirectToAction("Index"));
             }
             else
             {
                 //aca faltaria el mensaje informando que no es posible inscribir
                 return(RedirectToAction("Index"));
             }
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Se ha producido un error - ", ex.Message);
         return(View());
     }
 }
예제 #4
0
        public ActionResult DeleteConfirmed(string id)
        {
            subjects subjects = db.subjects.Find(id);

            db.subjects.Remove(subjects);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
예제 #5
0
 public ActionResult Edit([Bind(Include = "code,name,term,credit")] subjects subjects)
 {
     if (ModelState.IsValid)
     {
         db.Entry(subjects).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(subjects));
 }
예제 #6
0
 public Announcement(string teacherName, string title, string date, string time, string deadline, string location, string description, string subject)
 {
     this.teacherName = teacherName;
     this.title       = title;
     this.date        = date;
     this.time        = time;
     this.deadline    = deadline;
     this.location    = location;
     this.description = description;
     this.subject     = (subjects)Enum.Parse(typeof(subjects), subject);
 }
예제 #7
0
        public ActionResult Create([Bind(Include = "code,name,term,credit")] subjects subjects)
        {
            if (ModelState.IsValid)
            {
                db.subjects.Add(subjects);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(subjects));
        }
예제 #8
0
 public void unregisterFromSubject(subjects.ISubject subject)
 {
     try
     {
         this.subject.Find((searchSubject => { return (searchSubject == subject); })).removeObserver(this);
     }
     catch (Exception e)
     {
         Console.WriteLine("subject not found for this reader: " + e);
     }
 }
예제 #9
0
        // GET: subjects/Delete/5
        public ActionResult Delete(string id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            subjects subjects = db.subjects.Find(id);

            if (subjects == null)
            {
                return(HttpNotFound());
            }
            return(View(subjects));
        }
 public ActionResult DetallesMateria(int id)
 {
     try
     {
         using (Models.universityEntities db = new Models.universityEntities())
         {
             subjects mat = db.subjects.Find(id);
             return(View(mat));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Se ha producido un error - ", ex.Message);
         return(View());
     }
 }
 public ActionResult EliminarMateria(int id)
 {
     try
     {
         using (Models.universityEntities db = new Models.universityEntities())
         {
             subjects mat = db.subjects.Find(id);
             db.subjects.Remove(mat);
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
     }
     catch (Exception ex)
     {
         ModelState.AddModelError("Se ha producido un error - ", ex.Message);
         return(View());
     }
 }
        public ActionResult AgregarMateria(subjects a)
        {
            if (!ModelState.IsValid)
            {
                return(View());
            }

            try
            {
                using (Models.universityEntities db = new Models.universityEntities())
                {
                    db.subjects.Add(a);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (Exception ex)
            {
                ModelState.AddModelError("", "Error al agregar materia - " + ex.Message);
                return(View());
            }
        }
예제 #13
0
 public void removeSubject(subjects.ISubject subject)
 {
     unregisterFromSubject(subject);
     this.subject.Remove(subject);
 }
예제 #14
0
 public void registerToSubject(subjects.ISubject subject)
 {
     subject.registerObserver(this);
 }
예제 #15
0
 public void addSubject(subjects.ISubject subject)
 {
     this.subject.Add(subject);
     registerToSubject(subject);
 }
예제 #16
0
 public Lezer(subjects.ISubject subjectToRegisterTo)
 {
     subject.Add(subjectToRegisterTo);
 }