Beispiel #1
0
        public ActionResult CreatePost()
        {
            using (education_systemEntities1 db = new education_systemEntities1())
            {
                int     profesor_id = Int32.Parse(Request.Form["profesor_id"]);
                quota   q           = new quota();
                subject s           = new subject();
                s.id_subject     = 1;
                s.nombre_subject = Request.Form["nombre_subject"];
                s.codigo_subject = Request.Form["codigo_subject"];
                s.max_alumnos    = Int32.Parse(Request.Form["max_alumnos"]);
                s.descripcion    = Request.Form["descripcion"];
                s.hora_entrada   = TimeSpan.Parse(Request.Form["hora_entrada"]);
                s.hora_salida    = TimeSpan.Parse(Request.Form["hora_salida"]);
                db.subject.Add(s);
                db.SaveChanges();

                s             = db.subject.Where(m => m.codigo_subject == s.codigo_subject).First();
                q.profesor_id = profesor_id;
                q.subject_id  = s.id_subject;
                q.periodo     = DateTime.Now.Year.ToString();
                db.quota.Add(q);
                db.SaveChanges();

                TempData["Message"] = "Create sucess!";
            }

            return(RedirectToAction("Index"));
        }
Beispiel #2
0
        public ActionResult EditPost()
        {
            using (education_systemEntities1 db = new education_systemEntities1())
            {
                int id_subject = Int32.Parse(Request.Form["id_subject"]);
                int id_quota   = Int32.Parse(Request.Form["id_quota"]);

                subject s = db.subject.Find(id_subject);
                //var su = db.subject.Find(id);


                int profesor_id = Int32.Parse(Request.Form["profesor_id"]);

                quota q = db.quota.Where(m => m.id_quota == id_quota).First();

                s.nombre_subject = Request.Form["nombre_subject"];
                s.codigo_subject = Request.Form["codigo_subject"];
                s.max_alumnos    = Int32.Parse(Request.Form["max_alumnos"]);
                s.descripcion    = Request.Form["descripcion"];
                s.hora_entrada   = TimeSpan.Parse(Request.Form["hora_entrada"]);
                s.hora_salida    = TimeSpan.Parse(Request.Form["hora_salida"]);


                q.profesor_id = profesor_id;
                q.subject_id  = s.id_subject;
                q.periodo     = DateTime.Now.Year.ToString();


                db.Entry(s).State = System.Data.EntityState.Modified;
                db.Entry(q).State = System.Data.EntityState.Modified;
                db.SaveChanges();
                TempData["Message"] = "Edit sucess!";
            }
            return(RedirectToAction("Index"));
        }
Beispiel #3
0
        public ActionResult DeleteConfirmed(int id)
        {
            quota quota = db.quotas.Find(id);

            db.quotas.Remove(quota);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Beispiel #4
0
 public ActionResult Edit(quota quota)
 {
     if (ModelState.IsValid)
     {
         db.Entry(quota).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(quota));
 }
Beispiel #5
0
        public ActionResult Create(quota quota)
        {
            if (ModelState.IsValid)
            {
                db.quotas.Add(quota);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(quota));
        }
        public ActionResult CreatePost()
        {
            using (education_systemEntities1 db = new education_systemEntities1())
            {
                int   id_quota = Int32.Parse(Request.Form["id_quota"]);
                quota q        = new quota();

                var qt = db.quota.Find(id_quota);
                qt.subject.max_alumnos = qt.subject.max_alumnos - 1;
                q.subject_id           = qt.subject_id;
                q.alumno_id            = Int32.Parse(HttpContext.Session["id_person"].ToString());
                q.profesor_id          = qt.profesor_id;

                db.quota.Add(q);
                db.Entry(qt).State = System.Data.EntityState.Modified;

                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
        }
Beispiel #7
0
        public ActionResult Delete(int id)
        {
            quota quota = db.quotas.Find(id);

            return(View(quota));
        }
Beispiel #8
0
        public ViewResult Details(int id)
        {
            quota quota = db.quotas.Find(id);

            return(View(quota));
        }