public IHttpActionResult PostINSTRUCTOR(INSTRUCTOR iNSTRUCTOR)
        {
            db.INSTRUCTOR.Add(iNSTRUCTOR);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = iNSTRUCTOR.Instructor_ID }, iNSTRUCTOR));
        }
        public IHttpActionResult PutINSTRUCTOR(int id, INSTRUCTOR iNSTRUCTOR)
        {
            if (id != iNSTRUCTOR.Instructor_ID)
            {
                return(BadRequest());
            }

            db.Entry(iNSTRUCTOR).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!INSTRUCTORExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Ejemplo n.º 3
0
        public ActionResult DeleteConfirmed(int id)
        {
            INSTRUCTOR iNSTRUCTOR = db.INSTRUCTORs.Find(id);

            db.INSTRUCTORs.Remove(iNSTRUCTOR);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 4
0
 public ActionResult Edit([Bind(Include = "ID,FULLNAME,EMAIL,ADDRES,TELEPHONE,LISENCES,GENDER,EDUCATIONAL_LEVEL")] INSTRUCTOR iNSTRUCTOR)
 {
     if (ModelState.IsValid)
     {
         db.Entry(iNSTRUCTOR).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(iNSTRUCTOR));
 }
Ejemplo n.º 5
0
        public ActionResult Create([Bind(Include = "ID,FULLNAME,EMAIL,ADDRES,TELEPHONE,LISENCES,GENDER,EDUCATIONAL_LEVEL")] INSTRUCTOR iNSTRUCTOR)
        {
            if (ModelState.IsValid)
            {
                db.INSTRUCTORs.Add(iNSTRUCTOR);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(iNSTRUCTOR));
        }
        public IHttpActionResult GetINSTRUCTOR(int id)
        {
            INSTRUCTOR iNSTRUCTOR = db.INSTRUCTOR.Find(id);

            if (iNSTRUCTOR == null)
            {
                return(NotFound());
            }

            return(Ok(iNSTRUCTOR));
        }
Ejemplo n.º 7
0
        // GET: INSTRUCTOR/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            INSTRUCTOR iNSTRUCTOR = db.INSTRUCTOR.Find(id);

            if (iNSTRUCTOR == null)
            {
                return(HttpNotFound());
            }
            return(View(iNSTRUCTOR));
        }
        public IHttpActionResult DeleteINSTRUCTOR(int id)
        {
            INSTRUCTOR iNSTRUCTOR = db.INSTRUCTOR.Find(id);

            if (iNSTRUCTOR == null)
            {
                return(NotFound());
            }

            db.INSTRUCTOR.Remove(iNSTRUCTOR);
            db.SaveChanges();

            return(Ok(iNSTRUCTOR));
        }
Ejemplo n.º 9
0
 public ActionResult Edit([Bind(Include = "IdInstructor,Nombre,Celular1,Celular2,Estado")] INSTRUCTOR iNSTRUCTOR)
 {
     if (ModelState.IsValid)
     {
         bool existeUsuario = db.INSTRUCTOR.Any(x => x.Nombre.ToUpper() == iNSTRUCTOR.Nombre.ToUpper());
         if (!existeUsuario)
         {
             db.Entry(iNSTRUCTOR).State = EntityState.Modified;
             db.SaveChanges();
             return(RedirectToAction("Index"));
         }
         else
         {
             ViewBag.Message = "Ya existe un registro con este nombre," + iNSTRUCTOR.Nombre + " por favor revise...";
         }
     }
     return(View(iNSTRUCTOR));
 }
Ejemplo n.º 10
0
        public ActionResult Create([Bind(Include = "IdInstructor,Nombre,Celular1,Celular2,Estado")] INSTRUCTOR iNSTRUCTOR)
        {
            if (ModelState.IsValid)
            {
                bool existeUsuario = db.INSTRUCTOR.Any(x => x.Nombre.ToUpper() == iNSTRUCTOR.Nombre.ToUpper());
                if (!existeUsuario)
                {
                    iNSTRUCTOR.Nombre = iNSTRUCTOR.Nombre.ToUpper();
                    db.INSTRUCTOR.Add(iNSTRUCTOR);
                    db.SaveChanges();
                }
                else
                {
                    ViewBag.Message = "Ya existe un registro con este nombre," + iNSTRUCTOR.Nombre + " por favor revise...";
                }
            }

            return(View(iNSTRUCTOR));
        }
Ejemplo n.º 11
0
        public ActionResult INSTRUCTOR_Destroy([DataSourceRequest] DataSourceRequest request, INSTRUCTOR iNSTRUCTOR)
        {
            if (ModelState.IsValid)
            {
                var entity = new INSTRUCTOR
                {
                    inst_id    = iNSTRUCTOR.inst_id,
                    inst_name  = iNSTRUCTOR.inst_name,
                    inst_phone = iNSTRUCTOR.inst_phone,
                    inst_mail  = iNSTRUCTOR.inst_mail,
                    user_id    = iNSTRUCTOR.user_id,
                };

                db.INSTRUCTOR.Attach(entity);
                db.INSTRUCTOR.Remove(entity);
                db.SaveChanges();
            }

            return(Json(new[] { iNSTRUCTOR }.ToDataSourceResult(request, ModelState)));
        }
Ejemplo n.º 12
0
        public ActionResult INSTRUCTOR_Update([DataSourceRequest] DataSourceRequest request, INSTRUCTOR iNSTRUCTOR)
        {
            if (ModelState.IsValid)
            {
                int user   = Convert.ToInt32(Session["user_id"].ToString());
                var entity = new INSTRUCTOR
                {
                    inst_id    = iNSTRUCTOR.inst_id,
                    inst_name  = iNSTRUCTOR.inst_name,
                    inst_phone = iNSTRUCTOR.inst_phone,
                    inst_mail  = iNSTRUCTOR.inst_mail,
                    user_id    = user,
                };

                db.INSTRUCTOR.Attach(entity);
                db.Entry(entity).State = EntityState.Modified;
                db.SaveChanges();
            }

            return(Json(new[] { iNSTRUCTOR }.ToDataSourceResult(request, ModelState)));
        }